summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
33ac437)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@118
bc333340-6410-0410-a689-
9d09f3c113fa
-// The timestamp from load time to be compared against the current midnight time.
-E long timestamp;
-E void save_timestamp();
-E void load_timestamp();
-E long int midnight(long int offset = 8);
+E int day;
+E void save_day();
+E void load_day();
// The socket
E int sock;
// The socket
E int sock;
log("Source: %s Command: %s", source, cmd);
#endif
log("Source: %s Command: %s", source, cmd);
#endif
- long int mn = midnight() - 12 * 3600; // 12 noon ;)
+ struct tm *tm;
+ time_t ti;
+ time(&ti);
+ tm = localtime(&ti);
+ int curday = tm->tm_mday;
+
+ if (curday != day)
- timestamp = mn;
- save_timestamp();
+ day = curday;
+ save_day();
}
if (strnicmp(cmd, "\1PING", 6) == 0)
}
if (strnicmp(cmd, "\1PING", 6) == 0)
char *VERSION = "1.1.8";
int sock;
char *VERSION = "1.1.8";
int sock;
-void save_timestamp();
-void load_timestamp();
+void save_day();
+void load_day();
// Make this a daemon
int daemon(int nochdir, int noclose);
// Make this a daemon
int daemon(int nochdir, int noclose);
init_masters();
load_gs_dbase();
init_masters();
load_gs_dbase();
long int loadtime = time(NULL);
long int currentTime;
long int oldTime = loadtime;
long int loadtime = time(NULL);
long int currentTime;
long int oldTime = loadtime;
delete_monsters();
delete_masters();
delete_monsters();
delete_masters();
- infile.open(".gstimestamp");
if (infile.fail())
{
#ifdef DEBUGMODE
if (infile.fail())
{
#ifdef DEBUGMODE
- log("Error opening .gstimestamp");
+ log("Error opening .gsday");
#endif
generate:
#ifdef DEBUGMODE
#endif
generate:
#ifdef DEBUGMODE
- log("Generating new timestamp");
+ log("Generating new day");
- timestamp = midnight();
- save_timestamp();
+ struct tm *tm;
+ time_t ti;
+ time(&ti);
+ tm = localtime(&ti);
+
+ day = tm->tm_mday;
+
+ save_day();
- if (timestamp < 1000000)
+ if (day < 1 || day > 31)
- outfile.open(".gstimestamp");
+ outfile.open(".gsday");
- log("Error creating new file .gstimestamp");
+ log("Error creating new file .gsday");
- outfile << timestamp << endl;
+ outfile << day << endl;
-long int midnight(long int offset)
-{
- return (time(NULL) - (time(NULL) % 86400)) + (offset * 3600);
-}
-
/* daemon() - detach process from user and disappear into the background
* returns -1 on failure, but you can't do much except exit in that case
* since we may already have forked. This is based on the BSD version,
/* daemon() - detach process from user and disappear into the background
* returns -1 on failure, but you can't do much except exit in that case
* since we may already have forked. This is based on the BSD version,