X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/4dde2ed9f323c87a1f54b002c66da835f7dc0baa..33ac4371df8917180a54eb3f79dfc5c1e2744156:/gameserv/config.cpp?ds=sidebyside diff --git a/gameserv/config.cpp b/gameserv/config.cpp index abdb4d2..c43f014 100644 --- a/gameserv/config.cpp +++ b/gameserv/config.cpp @@ -1,8 +1,13 @@ -#include +#include #include +#include #include #include "extern.h" +using std::ifstream; +using std::cerr; +using std::endl; + void load_config_file(char *config); void unload_config_file(); @@ -16,7 +21,9 @@ char *c_Forest; // Forest channel char *c_ForestTopic; // Forest Channel Topic char *adminpass; // Administrator password char *welcomemsg; // Welcome Message -int confloadtime; // Welcome Message Delay +int welcomedelay; // Welcome Message Delay +int updateperiod; // Seconds until another player database update +int forestfights; // Forest fights per day // Remote server stuff. This is used for the outgoing connection gameserv needs to make // to a real ircd. @@ -27,6 +34,10 @@ char *remotepass; // Password for the server link char *playerdata; // File to store player data in char *monsterdata; // File to load monster data from +#if defined(P10) + char *gsnum = "[]AAA"; // GameServ Numeric +#endif + void unload_config_file() { if (s_GameServ) @@ -68,19 +79,30 @@ void load_config_file(char *config) infile.open(config); if (infile.fail()) { - cout << "Error opening " << config << endl; + log("Error opening %s", config); + cerr << "Error opening " << config << endl; return; } while (infile.getline(buf, 1024, '\n')) { - cout << "Buf: " << buf << endl; + #ifdef DEBUGMODE + log("Config file entry buf: %s", buf); + #endif if (buf[0] == '#' || buf[0] == ' ' || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') continue; directive = strtok(buf, " "); + if (stricmp(directive, "DIE") == 0) + { + value = strtok(NULL, ""); + log("You should read the entire %s file!", config); + cerr << "You should read the entire " << config << " file!" + << endl; + exit(0); + } if (stricmp(directive, "S_GAMESERV") == 0) { value = strtok(NULL, " "); @@ -153,10 +175,20 @@ void load_config_file(char *config) adminpass = new char[strlen(value) + 1]; strcpy(adminpass, value); } - else if (stricmp(directive, "CONFLOADTIME") == 0) + else if (stricmp(directive, "WELCOMEDELAY") == 0) + { + value = strtok(NULL, " "); + welcomedelay = stringtoint(value); + } + else if (stricmp(directive, "FORESTFIGHTS") == 0) + { + value = strtok(NULL, " "); + forestfights = stringtoint(value); + } + else if (stricmp(directive, "UPDATEPERIOD") == 0) { value = strtok(NULL, " "); - confloadtime = stringtoint(value); + updateperiod = stringtoint(value); } else if (stricmp(directive, "WELCOMEMSG") == 0) { @@ -166,7 +198,11 @@ void load_config_file(char *config) } else { - cout << "Unknown Directive. Buffer: " << buf << endl; + #ifdef DEBUGMODE + log("Unknown Directive. Buffer: %s", buf); + cerr << "Unknown " << config << " directive. Buffer: " + << buf << endl; + #endif continue; } }