]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/config.cpp
Added a couple new directives to the config file
[irc/gameservirc.git] / gameserv / config.cpp
index 4d69441a1a1c8127e67d16c4925599ef2fd3acdd..48e4d9ab22e5098b30af6109e894ae6c4019c6c4 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "extern.h"
+#include "flags.h"
 
 using std::ifstream;
 using std::cerr;
@@ -21,9 +22,15 @@ char *c_Forest;                      // Forest channel
 char *c_ForestTopic;           // Forest Channel Topic
 char *adminpass;               // Administrator password
 char *welcomemsg;              // Welcome Message
+char *ignoreserverslist;       // Servernames to ignore
 int welcomedelay;              // Welcome Message Delay
 int updateperiod;              // Seconds until another player database update
 int forestfights;              // Forest fights per day
+int maxafightdistance;         // Max levels above a player they can fight player->player
+int maxbfightdistance;         // Max levels below a player they can fight player->player
+int maxidletime;               // Max time (in seconds) a player can be idle for
+int idlecheckperiod;           // Period for checking every player's idle time
+long configflags;              // Holds the bit representation of some boolean values
 
 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
 // to a real ircd.
@@ -69,13 +76,17 @@ void unload_config_file()
        delete [] welcomemsg;
     if (pidfile)
        delete [] pidfile;
+    if (ignoreserverslist)
+       delete [] ignoreserverslist;
+
+    configflags = 0;
 }
 
 int load_config_file(char *config)
 {
     char *buf, *directive, *value;
 
-    #define numdirectives 17
+    #define numdirectives 22
 
     unload_config_file();
 
@@ -103,6 +114,20 @@ int load_config_file(char *config)
     directives[14].desc = "UPDATEPERIOD - Number of seconds between every player data save";
     directives[15].desc = "WELCOMEMSG - Message to send to new users on the network";
     directives[16].desc = "PIDFILE - Filename to store the gameserv process ID in";
+    directives[17].desc = "MAXAFIGHTDISTANCE - The maximum number of levels above you "\
+                               "that you can fight player->player";
+    directives[18].desc = "MAXBFIGHTDISTANCE - The maximum number of levels below you "\
+                               "that you can fight player->player";
+    directives[19].desc = "MAXIDLETIME - The maximum amount of time (in seconds) "\
+                               "that a player can be idle before something happens";
+    directives[20].desc = "IDLECHECKPERIOD - The period (in seconds) in which the entire "\
+                               "players list will be checked for idlers. See also: "\
+                               "MAXIDLETIME";
+    directives[21].desc = "LISTENONC_FOREST - True/False as to "\
+                               "whether or not to listen for forest "\
+                               "commands on the forest channel";
+
+    configflags = 0;
 
     for (int count = 0; count < numdirectives; count++)
     {
@@ -256,6 +281,55 @@ int load_config_file(char *config)
            strcpy(pidfile, value);
            directives[16].done = true;
        }
+       else if (stricmp(directive, "MAXAFIGHTDISTANCE") == 0)
+       {
+           value = strtok(NULL, " ");
+           maxafightdistance = stringtoint(value);
+           directives[17].done = true;;
+       }
+       else if (stricmp(directive, "MAXBFIGHTDISTANCE") == 0)
+       {
+           value = strtok(NULL, " ");
+           maxbfightdistance = stringtoint(value);
+           directives[18].done = true;
+       }
+       else if (stricmp(directive, "MAXIDLETIME") == 0)
+       {
+           value = strtok(NULL, " ");
+           maxidletime = stringtoint(value);
+           directives[19].done = true;
+       }
+       else if (stricmp(directive, "IDLECHECKPERIOD") == 0)
+       {
+           value = strtok(NULL, " ");
+           idlecheckperiod = stringtoint(value);
+           directives[20].done = true;
+       }
+       else if (stricmp(directive, "LISTENONC_FOREST") == 0)
+       {
+           value = strtok(NULL, " ");
+           if (stricmp(value, "TRUE") == 0)
+               setListenOnCF();
+
+           directives[21].done = true;
+       }
+       else if (stricmp(directive, "USEPRIVMSG") == 0)
+       {
+           // This directive is optional
+           setUsePrivmsg();
+       }
+       else if (stricmp(directive, "BOPER") == 0)
+       {
+           // This directive is optional
+           setBOper();
+       }
+       else if (stricmp(directive, "IGNORESERVERS") == 0)
+       {
+           // This directive is optional
+           value = strtok(NULL, "");
+           ignoreserverslist = new char[strlen(value) + 1];
+           strcpy(ignoreserverslist, value);
+       }
        else
        {
            #ifdef DEBUGMODE