int sock;
long lastrefresh;
+long lastrollover;
List<aClient> clients[U_TABLE_SIZE];
void save_lastrefresh();
void load_lastrefresh();
+void load_lastrollover();
+void save_lastrollover();
void prettyIntro();
void check_idles();
{
connected = 1;
load_lastrefresh();
-
+ load_lastrollover();
long int loadtime = time(NULL);
long int currentTime;
// Refresh players and clear news if the time is up
currentTime = time(NULL);
+
+ if (isRolloverForestFights())
+ {
+ if (currentTime - lastrollover >= rolloverperiod)
+ {
+ rolloverall();
+ lastrollover = currentTime;
+ save_lastrollover();
+ notice(s_GameServ, c_Forest, "Adding %d forest fights to all players!", forestfights);
+ }
+ }
+
if (currentTime - lastrefresh >= refreshperiod)
{
refreshall();
}
// Save the player data every updateperiod seconds
- currentTime = time(NULL);
if (currentTime - oldTime >= updateperiod)
{
oldTime = currentTime;
#endif
// Just a safety measure... tho no one should
- // get anywhere near the time as their refreshperiod
+ // get anywhere near the actual time as their refreshperiod
if (refreshperiod >= mytime)
+ {
+ log("Refresh period is greater than or equal to the actual time... setting it to 86400");
refreshperiod = 86400;
-
+ }
+
lastrefresh = mytime - (mytime % refreshperiod);
+
refreshall();
save_lastrefresh();
return;
}
infile >> lastrefresh;
+
infile.close();
if (lastrefresh < 0)
goto generate;
}
+void load_lastrollover()
+{
+ ifstream infile;
+ infile.open(".gsrollover");
+ if (infile.fail())
+ {
+#ifdef DEBUGMODE
+ log("Error opening .gsrollover");
+#endif
+
+ generate:
+ long mytime = time(NULL);
+#ifdef DEBUGMODE
+ log("Generating new rollover time");
+#endif
+ lastrollover = mytime;
+ return;
+ }
+ infile >> lastrollover;
+
+ infile.close();
+ if (lastrollover < 0)
+ goto generate;
+}
+
void save_lastrefresh()
{
ofstream outfile;
log("Error creating new file .gsrefresh");
return;
}
- outfile << lastrefresh << endl;
+ outfile << lastrefresh << endl << lastrollover;
outfile.close();
}
+
+void save_lastrollover()
+{
+ ofstream outfile;
+
+ outfile.open(".gsrollover");
+
+ if (outfile.fail())
+ {
+ log("Error creating new file .gsrollover");
+ return;
+ }
+ outfile << lastrollover << endl;
+ outfile.close();
+}