]> jfr.im git - irc/gameservirc.git/commitdiff
Added a new config file directive USE_PRIVMSG and implemented a flag system for confi...
authorkainazzzo <redacted>
Wed, 28 Apr 2004 13:19:28 +0000 (13:19 +0000)
committerkainazzzo <redacted>
Wed, 28 Apr 2004 13:19:28 +0000 (13:19 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@182 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/Changes
gameserv/config.cpp
gameserv/extern.h
gameserv/flags.h
gameserv/gameserv.cpp
gameserv/tcpclient.cpp

index d1e561e44700f2a0cf6100edd3bdc3d336397d1e..c34ee346d5735877c1fbd32b040e520611d19349 100644 (file)
@@ -1,4 +1,7 @@
 Version 1.2.2
+* Added an optional config file directive USEPRIVMSG which makes
+    gameserv use /msg instead of /notice - kain
+* Made the ignoreservers config file option work for bahamut - kain
 * Fixed an error in do_register that was not adding the client to the
     players list correctly, causing newly registered players to be
     locked out of identifying until the next gameserv restart - kain
index a91c364e92a610b3809c660cd926c0f2ea0f41d2..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;
@@ -29,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.
@@ -77,6 +78,8 @@ void unload_config_file()
        delete [] pidfile;
     if (ignoreserverslist)
        delete [] ignoreserverslist;
+
+    configflags = 0;
 }
 
 int load_config_file(char *config)
@@ -124,6 +127,8 @@ int load_config_file(char *config)
                                "whether or not to listen for forest "\
                                "commands on the forest channel";
 
+    configflags = 0;
+
     for (int count = 0; count < numdirectives; count++)
     {
        directives[count].done = false;
@@ -304,12 +309,15 @@ 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
index 04845feb867682e2a3dd22c375b2c70b386c73c4..2c6b780a6fd2a82f65652c3ecb04027c4f8eec5f 100644 (file)
@@ -66,7 +66,7 @@ E char *PACKAGE;
 E char *welcomemsg;
 E char *ignoreserverslist;
 
-E bool listenonc_forest;
+E long configflags;
 E bool shuttingdown;
 E int welcomedelay;
 E int updateperiod;
index 4c9557581f3829d7d9ffd90f295174d6fa5b76b8..7c895c712b38bcfd80c0f5ec8e6f2ed4674d81ab 100644 (file)
 #define FLAG_YOURTURN          0x0004
 #define FLAG_WONGAME           0x0008
 
+// Config File flags
+#define CFLAG_LISTENONCF               0x0001
+#define CFLAG_USEPRIVMSG               0x0002
+
+#define setListenOnCF(x)               (x |= CFLAG_LISTENONCF)
+#define clearListenOnCF(x)             (x &= ~CFLAG_LISTENONCF)
+#define isListenonCF(x)                        (x & CFLAG_LISTENONCF)
+
+#define setUsePrivmsg(x)               (x |= CFLAG_USEPRIVMSG)
+#define clearUsePrivmsg(x)             (x &= ~CFLAG_USEPRIVMSG)
+#define isUsePrivmsg(x)                        (x & CFLAG_USEPRIVMSG)
 
 // aClient flags
 // #define ADMIN_FLAGS(FLAG_ONE | FLAG_TWO | FLAG_ETC)
index 6a68086e09cc4ec23cf2c13ebcdd3ed8b31c6fd3..923cd5a182266ff90ea93af3c119571060f335ae 100644 (file)
@@ -463,6 +463,22 @@ void notice(const char *source, const char *dest, const char *fmt, ...)
     if (fmt[0] == '\0')
        return;
 
+    char *commanduse;
+    commanduse = new char[16];
+
+    #ifdef P10
+       if (isUsePrivmsg(configflags))
+           strncpy(commanduse, "P", 1);
+       else
+           strncpy(commanduse, "N", 1);
+    #else
+
+       if (isUsePrivmsg(configflags))
+           strncpy(commanduse, "PRIVMSG", 7);
+       else
+           strncpy(commanduse, "NOTICE", 6);
+    #endif
+
     va_list args;
     char *input;
     const char *t = fmt;
@@ -473,9 +489,9 @@ void notice(const char *source, const char *dest, const char *fmt, ...)
        dest++;
 
       #if !defined(P10)
-       sprintf(input, ":%s NOTICE %s :", source, dest);
+       sprintf(input, ":%s %s %s :", source, commanduse, dest);
       #else
-       sprintf(input, "%s O %s :", gsnum, dest);
+       sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
       #endif
 
        dest--;
@@ -483,9 +499,9 @@ void notice(const char *source, const char *dest, const char *fmt, ...)
     else
     {
       #if !defined(P10)
-       sprintf(input, ":%s NOTICE %s :", source, dest);
+       sprintf(input, ":%s %s %s :", source, commanduse, dest);
       #else
-       sprintf(input, "%s O %s :", gsnum, dest);
+       sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
       #endif
     }
 
@@ -513,6 +529,7 @@ void notice(const char *source, const char *dest, const char *fmt, ...)
     #endif
     sprintf(input, "%s%s", input, "\r\n");
     sock_puts(sock, input);
+    delete [] commanduse;
     delete [] input;
 va_end(args);
 }
index a77226cd0653c5ff08392e44fe346af194af3a3a..38274584674987e00f1e077d6aded391d476abc3 100644 (file)
@@ -430,7 +430,7 @@ int main(int argc, char *argv[])
                delete [] longname;
                gameserv(source, rest);
            }
-           else if (stricmp(dest, c_Forest) == 0 && listenonc_forest)
+           else if (stricmp(dest, c_Forest) == 0 && isListenOnCF(configflags))
            {
                delete [] longname;
                forest(source, rest);