]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/config.cpp
Shrunk the dependencies immensely with forward declarations in all H files instead...
[irc/gameservirc.git] / gameserv / config.cpp
index b8b6774ac0ea9eb0b049692b05e4043ac12087ed..c9f72304184b1d8f25cd3a39e41043044da28135 100644 (file)
@@ -23,6 +23,9 @@ char *c_ForestTopic;          // Forest Channel Topic
 char *adminpass;               // Administrator password
 char *welcomemsg;              // Welcome Message
 char *ignoreserverslist;       // Servernames to ignore
+char *nsname;                  // NickServ's name
+char *nspass;                  // GameServ's NickServ Password
+
 int welcomedelay;              // Welcome Message Delay
 int updateperiod;              // Seconds until another player database update
 int forestfights;              // Forest fights per day
@@ -30,6 +33,9 @@ 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
+int level1expire;              // Days for level 1 players to expire
+int defaultexpire;             // Days for other levels to expire
+long refreshperiod;            // Period for refreshing players
 long configflags;              // Holds the bit representation of some boolean values
 
 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
@@ -39,7 +45,9 @@ char *remoteport;             // Port to connect to on remoteserver
 char *remotepass;              // Password for the server link
 
 char *playerdata;              // File to store player data in
-char *monsterdata;             // File to load monster data from
+char *dragondata;              // File to store current dragon data in
+char *masterdata;              // File to store the master data in
+char *newsdata;                        // File to store news data in
 char *pidfile;                 // Process ID file
 
 #if defined(P10)
@@ -68,8 +76,10 @@ void unload_config_file()
        delete [] remotepass;
     if (playerdata)
        delete [] playerdata;
-    if (monsterdata)
-       delete [] monsterdata;
+    if (dragondata)
+       delete [] dragondata;
+    if (masterdata)
+       delete [] masterdata;
     if (adminpass)
        delete [] adminpass;
     if (welcomemsg)
@@ -78,6 +88,12 @@ void unload_config_file()
        delete [] pidfile;
     if (ignoreserverslist)
        delete [] ignoreserverslist;
+    if (newsdata)
+       delete [] newsdata;
+    if (nsname)
+       delete [] nsname;
+    if (nspass)
+       delete [] nspass;
 
     configflags = 0;
 }
@@ -86,7 +102,7 @@ int load_config_file(char *config)
 {
     char *buf, *directive, *value;
 
-    #define numdirectives 22
+    #define numdirectives 30
 
     unload_config_file();
 
@@ -107,25 +123,41 @@ int load_config_file(char *config)
      directives[7].desc = "REMOTEPORT - Port on the remote server to connect to";
      directives[8].desc = "REMOTEPASS - Password on the remote server";
      directives[9].desc = "PLAYERDATA - File to store the player saves in";
-    directives[10].desc = "MONSTERDATA - File to load the monsters from";
+    directives[10].desc = "SAVEDNOTICE - True/False as to wether or not to tell the forest "\
+                               "channel that the player database has been saved";
     directives[11].desc = "ADMINPASS - Password to identify as an admin with";
     directives[12].desc = "WELCOMEDELAY - Delay (in seconds) to wait before welcoming new users to the network";
     directives[13].desc = "FORESTFIGHTS - Number of forest fights players get every day";
     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 "\
+    directives[15].desc = "PIDFILE - Filename to store the gameserv process ID in";
+    directives[16].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 "\
+    directives[17].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) "\
+    directives[18].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 "\
+    directives[19].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 "\
+    directives[20].desc = "LISTENONC_FOREST - True/False as to "\
                                "whether or not to listen for forest "\
                                "commands on the forest channel";
+    directives[21].desc = "NEWSDATA - File to store daily news in";
+    directives[22].desc = "REFRESHPERIOD - Period (in seconds) to "\
+                               "refresh players";
+    directives[23].desc = "LEVEL1EXPIRE - Amount of days until a "\
+                       "level 1 player's account is deleted due to "\
+                       "inactivity.";
+    directives[24].desc = "DEFAULTEXPIRE - Amount of days until a "\
+                       "level 2 and above player's account is "\
+                       "deleted due to inactivity";
+    directives[25].desc = "USENICKSERV - True/False as to wether or not "\
+                       "GameServ should identify with NickServ";
+    directives[26].desc = "NSNAME - Your network's NickServ nickname";
+    directives[27].desc = "NSPASS - GameServ's NickServ Password";
+    directives[28].desc = "DRAGONDATA - File to store the current "\
+                       "dragon's stats in";
+    directives[29].desc = "MASTERDATA - File to store the level master stats in";
 
     configflags = 0;
 
@@ -235,11 +267,11 @@ int load_config_file(char *config)
            strcpy(playerdata, value);
            directives[9].done = true;
        }
-       else if (stricmp(directive, "MONSTERDATA") == 0)
+       else if (stricmp(directive, "SAVEDNOTICE") == 0)
        {
            value = strtok(NULL, "");
-           monsterdata = new char[strlen(value) + 1];
-           strcpy(monsterdata, value);
+           if (stricmp(value, "TRUE") == 0)
+               setSavedNotice();
            directives[10].done = true;
        }
        else if (stricmp(directive, "ADMINPASS") == 0)
@@ -267,56 +299,125 @@ int load_config_file(char *config)
            updateperiod = stringtoint(value);
            directives[14].done = true;
        }
-       else if (stricmp(directive, "WELCOMEMSG") == 0)
-       {
-           value = strtok(NULL, "");
-           welcomemsg = new char[strlen(value) + 1];
-           strcpy(welcomemsg, value);
-           directives[15].done = true;
-       }
        else if (stricmp(directive, "PIDFILE") == 0)
        {
            value = strtok(NULL, " ");
            pidfile = new char[strlen(value) + 1];
            strcpy(pidfile, value);
-           directives[16].done = true;
+           directives[15].done = true;
        }
        else if (stricmp(directive, "MAXAFIGHTDISTANCE") == 0)
        {
            value = strtok(NULL, " ");
            maxafightdistance = stringtoint(value);
-           directives[17].done = true;;
+           directives[16].done = true;;
        }
        else if (stricmp(directive, "MAXBFIGHTDISTANCE") == 0)
        {
            value = strtok(NULL, " ");
            maxbfightdistance = stringtoint(value);
-           directives[18].done = true;
+           directives[17].done = true;
        }
        else if (stricmp(directive, "MAXIDLETIME") == 0)
        {
            value = strtok(NULL, " ");
            maxidletime = stringtoint(value);
-           directives[19].done = true;
+           directives[18].done = true;
        }
        else if (stricmp(directive, "IDLECHECKPERIOD") == 0)
        {
            value = strtok(NULL, " ");
            idlecheckperiod = stringtoint(value);
-           directives[20].done = true;
+           directives[19].done = true;
        }
        else if (stricmp(directive, "LISTENONC_FOREST") == 0)
        {
            value = strtok(NULL, " ");
            if (stricmp(value, "TRUE") == 0)
-               setListenOnCF(configflags);
+               setListenOnCF();
 
+           directives[20].done = true;
+       }
+       else if (stricmp(directive, "NEWSDATA") == 0)
+       {
+           value = strtok(NULL, " ");
+           newsdata = new char [strlen(value) + 1];
+           strcpy(newsdata, value);
            directives[21].done = true;
        }
+       else if (stricmp(directive, "REFRESHPERIOD") == 0)
+       {
+           value = strtok(NULL, " ");
+           refreshperiod = stringtoint(value);
+           directives[22].done = true;
+       }
+       else if (stricmp(directive, "LEVEL1EXPIRE") == 0)
+       {
+           value = strtok(NULL, " ");
+           level1expire = stringtoint(value);
+           directives[23].done = true;
+       }
+       else if (stricmp(directive, "DEFAULTEXPIRE") == 0)
+       {
+           value = strtok(NULL, " ");
+           defaultexpire = stringtoint(value);
+           directives[24].done = true;
+       }
+       else if (stricmp(directive, "USENICKSERV") == 0)
+       {
+           value = strtok(NULL, " ");
+           if (stricmp(value, "TRUE") == 0)
+           {
+               setUseNickServ();
+           }
+
+           directives[25].done = true;
+       }
+       else if (stricmp(directive, "NSNAME") == 0)
+       {
+           value = strtok(NULL, "");
+           nsname = new char[strlen(value) + 1];
+           strcpy(nsname, value);
+           directives[26].done = true;
+       }
+       else if (stricmp(directive, "NSPASS") == 0)
+       {
+           value = strtok(NULL, "");
+           nspass = new char[strlen(value) + 1];
+           strcpy(nspass, value);
+           directives[27].done = true;
+       }
+       else if (stricmp(directive, "DRAGONDATA") == 0)
+       {
+           value = strtok(NULL, "");
+           dragondata = new char[strlen(value) + 1];
+           strcpy(dragondata, value);
+           directives[28].done = true;
+       }
+       else if (stricmp(directive, "MASTERDATA") == 0)
+       {
+           value = strtok(NULL, "");
+           masterdata = new char[strlen(value) + 1];
+           strcpy(masterdata, value);
+           directives[29].done = true;
+       }
+       else if (stricmp(directive, "WELCOMEMSG") == 0)
+       {
+           // This directive is optional
+           value = strtok(NULL, "");
+           welcomemsg = new char[strlen(value) + 1];
+           strcpy(welcomemsg, value);
+           setWelcome();
+       }
        else if (stricmp(directive, "USEPRIVMSG") == 0)
        {
            // This directive is optional
-           setUsePrivmsg(configflags);
+           setUsePrivmsg();
+       }
+       else if (stricmp(directive, "BOPER") == 0)
+       {
+           // This directive is optional
+           setBOper();
        }
        else if (stricmp(directive, "IGNORESERVERS") == 0)
        {