]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/config.cpp
Added a new config file directive USE_PRIVMSG and implemented a flag system for confi...
[irc/gameservirc.git] / gameserv / config.cpp
index e9c064cce366edd6573a4b59a8d783a1f907d87b..b8b6774ac0ea9eb0b049692b05e4043ac12087ed 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,6 +22,7 @@ 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
@@ -28,7 +30,7 @@ int maxafightdistance;                // Max levels above a player they can fight player->play
 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
-bool listenonc_forest;         // If true, listen for commands on the forest channel
+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.
@@ -74,6 +76,10 @@ void unload_config_file()
        delete [] welcomemsg;
     if (pidfile)
        delete [] pidfile;
+    if (ignoreserverslist)
+       delete [] ignoreserverslist;
+
+    configflags = 0;
 }
 
 int load_config_file(char *config)
@@ -118,8 +124,10 @@ int load_config_file(char *config)
                                "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"
+                               "whether or not to listen for forest "\
+                               "commands on the forest channel";
+
+    configflags = 0;
 
     for (int count = 0; count < numdirectives; count++)
     {
@@ -301,12 +309,22 @@ int load_config_file(char *config)
        {
            value = strtok(NULL, " ");
            if (stricmp(value, "TRUE") == 0)
-               listenonc_forest = true;
-           else
-               listenonc_forest = false;
+               setListenOnCF(configflags);
 
            directives[21].done = true;
        }
+       else if (stricmp(directive, "USEPRIVMSG") == 0)
+       {
+           // This directive is optional
+           setUsePrivmsg(configflags);
+       }
+       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