#include <properties.h>#include <events.h>#include <time.h>
gehe zum Quellcode dieser Datei
Funktionen | |
| void | WaitForQuarterHour () |
| void | create () |
| int | CheckClockMsg (string str) |
| void | QuarterReached () |
Variablen | |
| private string | ulog = "" |
| int CheckClockMsg | ( | string | str | ) |
Definiert in Zeile 24 der Datei uhr.c.
Benutzt i.
Wird benutzt von QuarterReached().
00025 { 00026 int i = strstr(str, "%", 0); 00027 /* Mehr als 1x %d enthalten, mehr als 1x % enthalten, oder auf das einzige 00028 enthaltene % folgt kein "d". */ 00029 if ( sizeof(explode(str,"%d")) > 2 || 00030 sizeof(explode(str,"%")) > 2 || 00031 (i>-1 && ( i==strlen(str)-1 || str[i+1] != 'd'))) 00032 return 0; 00033 else 00034 return 1; 00035 }

| void create | ( | ) |
Definiert in Zeile 17 der Datei uhr.c.
Benutzt WaitForQuarterHour().
00017 { 00018 WaitForQuarterHour(); 00019 }

| void QuarterReached | ( | ) |
Definiert in Zeile 37 der Datei uhr.c.
Benutzt break_string(), CheckClockMsg(), E_DAY, E_HOUR, E_MINUTES, E_MONTH, E_YEAR, EVENTD, EVT_LIB_CLOCK, EVT_LIB_DATECHANGE, format(), i, log_file, P_CLOCKMSG, P_TIMEZONE, TM_HOUR, TM_MDAY, TM_MIN, TM_MON, TM_YEAR, ulog und WaitForQuarterHour().
00037 { 00038 int std, minuten; 00039 string ct, str, format; 00040 int i; 00041 int off; 00042 00043 int *lt=localtime(time()); 00044 minuten=lt[TM_MIN]; 00045 std=lt[TM_HOUR]; 00046 00047 // Clock-Event triggern 00048 EVENTD->TriggerEvent(EVT_LIB_CLOCK, ([ 00049 E_HOUR: std, E_MINUTES: minuten ]) ); 00050 00051 // bei Datumswechsel DATECHANGE-Event ausloesen. 00052 if (std==0 && minuten < 15) { 00053 EVENTD->TriggerEvent(EVT_LIB_DATECHANGE, ([ 00054 E_DAY: lt[TM_MDAY], E_MONTH: lt[TM_MON]+1, 00055 E_YEAR: lt[TM_YEAR] ]) ); 00056 } 00057 00058 if (minuten <= 2) { 00059 foreach(object u : users()) { 00060 if((off=to_int(u->QueryProp(P_TIMEZONE)))<0)off+=24; 00061 off=(std+off)%24; 00062 format=u->QueryProp(P_CLOCKMSG)||"Du hoerst die Uhr schlagen: " 00063 "Es ist jetzt %d Uhr.\n"; 00064 if ( !CheckClockMsg(format) ) 00065 { 00066 tell_object(u, break_string( 00067 "So kann ich nicht arbeiten! Deine Uhrmeldung funktioniert so " 00068 "nicht. Bitte korrigiere das.", 78, "Die Uhr teilt Dir mit: ")); 00069 continue; 00070 } 00071 if (strstr(format,"%d",0)==-1) 00072 str=format; 00073 else 00074 str=sprintf(format,off); 00075 if (str!="") tell_object(u,str); 00076 } 00077 } 00078 str = ""; 00079 if (minuten < 10) { 00080 log_file("USER_STATISTIK", ulog); 00081 ulog = sprintf("\n%s%02d: ",(!std?("# "+ct+":\n"):""),std); 00082 } 00083 ulog += sprintf("%4d",sizeof(users())); 00084 WaitForQuarterHour(); 00085 }

| void WaitForQuarterHour | ( | ) |
Definiert in Zeile 12 der Datei uhr.c.
Benutzt call_out().
Wird benutzt von create() und QuarterReached().
00012 { 00013 while(remove_call_out("QuarterReached")!=-1); 00014 call_out("QuarterReached",900-(time() % 900)); 00015 }


| private string ulog = "" |
Definiert in Zeile 10 der Datei uhr.c.
Wird benutzt von QuarterReached().
1.6.3