Version 1.3.1
+* Added a config file directive ROLLOVERFORESTFIGHTS which will allow you to keep the forest
+ fights from the previous day - kain (Thanks thelizno)
+* Added a config file directive ROLLOVERPERIOD which will allow you to specify a period of time
+ to rollover the forest fights - kain (Thanks thelizno)
+* Added a config file directive MAXFORESTFIGHTS which allows you to specify a maximum amount of
+ forest fights a player can roll over - kain (Thanks thelizno)
* Fixed a bug causing a crash on /msg GameServ use - kain (Thanks thelizno)
* Fixed a bug in the masteritems.dat file causing the chain saw to take 1 strength point
away instead of add 185 - kain (Thanks Tsukasa)
int defaultexpire; // Days for other levels to expire
int maxitems; // Maximum amount of items a player can carry
long refreshperiod; // Period for refreshing players
-long configflags; // Holds the bit representation of some boolean values
+long rolloverperiod; // Period for rolling over forest fights
+long configflags; // Holds the binary representation of some boolean values
+long maxforestfights; // Maximum amount of forest fights to roll over
// Remote server stuff. This is used for the outgoing connection gameserv needs to make
// to a real ircd.
{
char *buf, *directive, *value;
- #define numdirectives 35
+ #define numdirectives 38
unload_config_file();
directives[32].desc = "MAXITEMS - Maximum number of items a player can carry";
directives[33].desc = "STOREITEMDATA - File in which to store the items that are available in the store";
directives[34].desc = "LOCALHOST - Local hostname or IP to bind to when connecting to the remote server";
+ directives[35].desc = "ROLLOVERFORESTFIGHTS - True/False as to wether or not to roll over forest fights "\
+ "into the next day";
+ directives[36].desc = "MAXFORESTFIGHTS - Maximum amount of forest fights to roll over";
+ directives[37].desc = "ROLLOVERPERIOD - Period (in seconds) to rollover forest fights";
configflags = 0;
strcpy(localhost, value);
directives[34].done = true;
}
+ else if (stricmp(directive, "ROLLOVERFORESTFIGHTS") == 0)
+ {
+ value = strtok(NULL, " ");
+ if (stricmp(value, "TRUE") == 0)
+ {
+ setRolloverForestFights();
+ }
+ directives[35].done = true;
+ }
+ else if (stricmp(directive, "MAXFORESTFIGHTS") == 0)
+ {
+ value = strtok(NULL, "");
+ maxforestfights = stringtoint(value);
+ directives[36].done = true;
+ }
+ else if (stricmp(directive, "ROLLOVERPERIOD") == 0)
+ {
+ value = strtok(NULL, "");
+ rolloverperiod = stringtoint(value);
+ directives[37].done = true;
+ }
else if (stricmp(directive, "WELCOMEMSG") == 0)
{
// This directive is optional
// hash.cpp stuff end
E long lastrefresh;
+E long lastrollover;
E void save_lastrefresh();
E void load_lastrefresh();
+E void save_lastrollover();
+E void load_lastrollover();
// The socket
E int sock;
E long configflags;
E long refreshperiod;
+E long rolloverperiod;
E int level1expire;
E int defaultexpire;
E bool shuttingdown;
E int maxidletime;
E int idlecheckperiod;
E int maxitems;
+E long maxforestfights;
/* config.cpp end */
E void deleteMonster(Monster *m);
E void refresh(Player *p);
E void refreshall();
+E void rolloverall();
+E void rollover(Player *p);
E void updateTS(Player *p);
E bool timedOut(Player *p);
E void timeOutEvent(Player *p);
#define CFLAG_WELCOME 0x00000008
#define CFLAG_SAVEDNOTICE 0x00000010
#define CFLAG_USENICKSERV 0x00000020
+#define CFLAG_ROLLOVERFORESTFIGHTS 0x00000040
+
+#define setRolloverForestFights() (configflags |= CFLAG_ROLLOVERFORESTFIGHTS)
+#define clearRolloverForestFights() (configflags &= ~CFLAG_ROLLOVERFORESTFIGHTS)
+#define isRolloverForestFights() (configflags & CFLAG_ROLLOVERFORESTFIGHTS)
#define setUseNickServ() (configflags |= CFLAG_USENICKSERV)
#define clearUseNickServ() (configflags &= ~CFLAG_USENICKSERV)
char *spaces(int len, char *seperator);
void refresh(Player *p);
void refreshall();
+void rollover(Player *p);
+void rolloverall();
+
void updateTS(Player *p);
void reset(Player *p);
bool load_masters();
notice(s_GameServ, u, "Time left to next refresh: %dd %dh %dm %ds",
days, hours, minutes, seconds);
+
+ if (isRolloverForestFights())
+ {
+ complete = (lastrollover + rolloverperiod) - time(NULL);
+
+ days = complete / 86400;
+ hours = (complete % 86400) / 3600;
+ minutes = (complete % 86400) % 3600 / 60;
+ seconds = (complete % 86400) % 3600 % 60;
+
+ notice(s_GameServ, u, "Time left to next rollover: %dd %dh %dm %ds",
+ days, hours, minutes, seconds);
+ }
}
void do_list(char *u)
}
+void rolloverall()
+{
+ ListNode <aClient> *it;
+ Player *p;
+ for (unsigned long x = 0; x < U_TABLE_SIZE; x++)
+ {
+ it = players[x].First();
+ while (it)
+ {
+ p = it->getData()->stats;
+ rollover(p);
+ it = it->Next();
+ }
+ }
+}
void refreshall()
{
- ListNode <aClient> *it;
- Player *p;
- for (unsigned long x = 0; x < U_TABLE_SIZE; x++)
- {
- it = players[x].First();
-
- while (it)
+ ListNode <aClient> *it;
+ Player *p;
+ for (unsigned long x = 0; x < U_TABLE_SIZE; x++)
{
- p = it->getData()->stats;
- refresh(p);
- it = it->Next();
+ it = players[x].First();
+
+ while (it)
+ {
+ p = it->getData()->stats;
+ refresh(p);
+ it = it->Next();
+ }
}
- }
+}
+
+void rollover(Player *p)
+{
+ if (!p)
+ return;
+
+ p->forest_fights += forestfights;
+
+ if (p->forest_fights > maxforestfights)
+ p->forest_fights = maxforestfights;
}
void refresh(Player *p)
if (p->hp < p->maxhp)
p->hp = p->maxhp;
- p->forest_fights = forestfights;
+ if (p->forest_fights < forestfights)
+ {
+ p->forest_fights = forestfights;
+ }
+
p->player_fights = 3;
setAlive(p);
clearMaster(p);
# 3600 Seconds in an hour
refreshperiod 86400
+# How often (in seconds) ro rollover forest fights
+# 86400 Seconds in a day
+# 43200 Seconds in 12 hours
+# 3600 Seconds in an hour
+rolloverperiod 43200
+
# How many days until unused accounts at level 1 are deleted
level1expire 14
# How many forest fights per day should everyone get
forestfights 100
+# True or False - Should GameServ roll over forest fights into the next day
+rolloverforestfights true
+
+# Maximum number of forest fights to roll over total. Forest fights per player will never
+# Roll over to be above this number
+maxforestfights 300
+
# This is the filename for the gameserv process ID
# This should be different between .conf files so you have different pid
# files saved for each process (if you want)
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();
+}