]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/config.cpp
Updated the change log for the numrolloverfights directive
[irc/gameservirc.git] / gameserv / config.cpp
index 7fce944b4c894675b9d424c0a5e1730d02200f9f..1f23d394807a82153d3f475b0ff4b55bf0cc8665 100644 (file)
@@ -35,15 +35,21 @@ int maxidletime;            // Max time (in seconds) a player can be idle for
 int idlecheckperiod;           // Period for checking every player's idle time
 int level1expire;              // Days for level 1 players to expire
 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
+long numrolloverfights;         // Number 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 *remoteserver;            // Server to connect to
-char *remoteport;              // Port to connect to on remoteserver
+char *localhost;                // Hostname of the local address to bind to
+int  remoteport;               // Port to connect to on remoteserver
 char *remotepass;              // Password for the server link
 
+char *storeitemdata;            // File to store the items available in the store
 char *tavernitemdata;           // File to store the items available in the tavern
 char *itemdata;                 // File to store the items in
 char *playerdata;              // File to store player data in
@@ -58,57 +64,59 @@ char *pidfile;                      // Process ID file
 
 void unload_config_file()
 {
-    if (s_GameServ)
-       delete [] s_GameServ;
-    if (gshost)
-       delete [] gshost;
-    if (gsident)
-       delete [] gsident;
-    if (servername)
-       delete [] servername;
-    if (c_Forest)
-       delete [] c_Forest;
-    if (c_ForestTopic)
-       delete [] c_ForestTopic;
-    if (remoteserver)
-       delete [] remoteserver;
-    if (remoteport)
-       delete [] remoteport;
-    if (remotepass)
-       delete [] remotepass;
-    if (playerdata)
-       delete [] playerdata;
-    if (tavernitemdata)
-        delete [] tavernitemdata;
-    if (itemdata)
-        delete [] itemdata;
-    if (dragondata)
-       delete [] dragondata;
-    if (masterdata)
-       delete [] masterdata;
-    if (adminpass)
-       delete [] adminpass;
-    if (welcomemsg)
-       delete [] welcomemsg;
-    if (pidfile)
-       delete [] pidfile;
-    if (ignoreserverslist)
-       delete [] ignoreserverslist;
-    if (newsdata)
-       delete [] newsdata;
-    if (nsname)
-       delete [] nsname;
-    if (nspass)
-       delete [] nspass;
+  if (s_GameServ)
+    delete [] s_GameServ;
+  if (gshost)
+    delete [] gshost;
+  if (gsident)
+    delete [] gsident;
+  if (servername)
+    delete [] servername;
+  if (c_Forest)
+    delete [] c_Forest;
+  if (c_ForestTopic)
+    delete [] c_ForestTopic;
+  if (remoteserver)
+    delete [] remoteserver;
+  if (localhost)
+    delete [] localhost;
+  if (remotepass)
+    delete [] remotepass;
+  if (playerdata)
+    delete [] playerdata;
+  if (storeitemdata)
+    delete [] storeitemdata;
+  if (tavernitemdata)
+    delete [] tavernitemdata;
+  if (itemdata)
+    delete [] itemdata;
+  if (dragondata)
+    delete [] dragondata;
+  if (masterdata)
+    delete [] masterdata;
+  if (adminpass)
+    delete [] adminpass;
+  if (welcomemsg)
+    delete [] welcomemsg;
+  if (pidfile)
+    delete [] pidfile;
+  if (ignoreserverslist)
+    delete [] ignoreserverslist;
+  if (newsdata)
+    delete [] newsdata;
+  if (nsname)
+    delete [] nsname;
+  if (nspass)
+    delete [] nspass;
 
-    configflags = 0;
+  configflags = 0;
 }
 
 int load_config_file(char *config)
 {
     char *buf, *directive, *value;
 
-    #define numdirectives 32
+    #define numdirectives 39
 
     unload_config_file();
 
@@ -166,6 +174,14 @@ int load_config_file(char *config)
     directives[29].desc = "MASTERDATA - File to store the level master stats in";
     directives[30].desc = "ITEMDATA - File to store the items in";
     directives[31].desc = "TAVERNITEMDATA - File in which to store the items that are available in the tavern";
+    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";
+    directives[38].desc = "NUMROLLOVERFIGHTS - Number of forest fights to roll over";
 
     configflags = 0;
 
@@ -257,8 +273,7 @@ int load_config_file(char *config)
        else if (stricmp(directive, "REMOTEPORT") == 0)
        {
            value = strtok(NULL, " ");
-           remoteport = new char[strlen(value) + 1];
-           strcpy(remoteport, value);
+           remoteport = stringtoint(value);
            directives[7].done = true;
        }
        else if (stricmp(directive, "REMOTEPASS") == 0)
@@ -419,10 +434,63 @@ int load_config_file(char *config)
        else if (stricmp(directive, "TAVERNITEMDATA") == 0)
          {
            value = strtok(NULL, "");
-           itemdata = new char[strlen(value) + 1];
-           strcpy(itemdata, value);
+           tavernitemdata = new char[strlen(value) + 1];
+           strcpy(tavernitemdata, value);
            directives[31].done = true;
          }
+       else if (stricmp(directive, "MAXITEMS") == 0)
+         {
+           value = strtok(NULL, "");
+           maxitems = stringtoint(value);
+           directives[32].done = true;
+         }
+       else if (stricmp(directive, "STOREITEMDATA") == 0)
+         {
+           value = strtok(NULL, "");
+           storeitemdata = new char[strlen(value) + 1];
+           strcpy(storeitemdata, value);
+           directives[33].done = true;
+         }
+       else if (stricmp(directive, "LOCALHOST") == 0)
+         {
+           value = strtok(NULL, "");
+           localhost = new char[strlen(value) + 1];
+           strcpy(localhost, value);
+           directives[34].done = true;
+         }
+       else if (stricmp(directive, "ROLLOVERFORESTFIGHTS") == 0)
+         {
+           value = strtok(NULL, " ");
+           if (stricmp(value, "TRUE") == 0)
+             {
+               setRolloverForestFights();
+             }
+           else
+             {
+               directives[36].done = true;
+               directives[37].done = true;
+               directives[38].done = true;
+             }
+           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, "NUMROLLOVERFIGHTS") == 0)
+         {
+           value = strtok(NULL, "");
+           numrolloverfights = stringtoint(value);
+           directives[38].done = true;
+         }
        else if (stricmp(directive, "WELCOMEMSG") == 0)
        {
            // This directive is optional