]> jfr.im git - irc/gameservirc.git/commitdiff
Added a new version of the logout command, and made welcomemsg config file directive...
authorkainazzzo <redacted>
Thu, 29 Apr 2004 13:08:56 +0000 (13:08 +0000)
committerkainazzzo <redacted>
Thu, 29 Apr 2004 13:08:56 +0000 (13:08 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@187 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/Changes
gameserv/config.cpp
gameserv/flags.h
gameserv/gameserv.cpp
gameserv/gameserv.example.conf
gameserv/helpfiles/logout
gameserv/tcpclient.cpp

index 8173ac744fc3124972eacc491e925a8b76825b0e..4768b3fd78fdfb2b58d1a3171ebf799e64cc9b0c 100644 (file)
@@ -1,4 +1,6 @@
 Version 1.2.2
+* Made welcomemsg an optional config file option. If commented out
+    or deleted, gameserv will not send the welcome message - kain
 * Made the ignoreservers config file option work for Unreal - kain
 * Fixed a minor logical problem that was causing players to be mugged
     for 0 gold when they were either dead or had no gold on hand and
index 48e4d9ab22e5098b30af6109e894ae6c4019c6c4..7adfa561a264a4abb7d9f61a58233508ee93eab0 100644 (file)
@@ -86,7 +86,7 @@ int load_config_file(char *config)
 {
     char *buf, *directive, *value;
 
-    #define numdirectives 22
+    #define numdirectives 21
 
     unload_config_file();
 
@@ -112,18 +112,17 @@ int load_config_file(char *config)
     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";
 
@@ -267,43 +266,36 @@ 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)
        {
@@ -311,7 +303,15 @@ int load_config_file(char *config)
            if (stricmp(value, "TRUE") == 0)
                setListenOnCF();
 
-           directives[21].done = true;
+           directives[20].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)
        {
index c2a2ba123f25999e92174736fe0c27e7d935c594..c2b1f419c5b342080ea3720cb22acfed1b4fb536 100644 (file)
  */
 
 // aClient FLAGS ONLY
-#define FLAG_ADMIN 0x0001
-#define FLAG_IGNORE 0x0002
-#define FLAG_PLAYING 0x0004
+#define FLAG_ADMIN     0x00000001
+#define FLAG_IGNORE    0x00000002
+#define FLAG_PLAYING   0x00000004
 
 // PLAYER FLAGS ONLY
-#define FLAG_MASTER            0x0001
-#define FLAG_ALIVE             0x0002
-#define FLAG_YOURTURN          0x0004
-#define FLAG_WONGAME           0x0008
+#define FLAG_MASTER            0x00000001
+#define FLAG_ALIVE             0x00000002
+#define FLAG_YOURTURN          0x00000004
+#define FLAG_WONGAME           0x00000008
 
 // Config File flags
-#define CFLAG_LISTENONCF               0x0001
-#define CFLAG_USEPRIVMSG               0x0002
-#define CFLAG_BOPER                    0x0004
+#define CFLAG_LISTENONCF               0x00000001
+#define CFLAG_USEPRIVMSG               0x00000002
+#define CFLAG_BOPER                    0x00000004
+#define CFLAG_WELCOME                  0x00000008
+
+#define setWelcome()                   (configflags |= CFLAG_WELCOME)
+#define clearWelcome()                 (configflags &= ~CFLAG_WELCOME)
+#define isWelcome()                    (configflags & CFLAG_WELCOME)
 
 #define setListenOnCF()                        (configflags |= CFLAG_LISTENONCF)
 #define clearListenOnCF()              (configflags &= ~CFLAG_LISTENONCF)
index 1929a2f170fbf303077a435d1d5a3cab11f8959c..2c00c6b171cf620fef81467936b589481629b696 100644 (file)
@@ -625,12 +625,15 @@ void do_list(char *u)
 void do_logout(char *u)
 {
     aClient *user;
+    char *name = strtok(NULL, " ");
+
     if (!(user = find(u)))
     {
        notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
                "Buf: %s LOGOUT", u);
        log("Could not find aClient Buf: %s LOGOUT", 
                u);
+       return;
     }
     else if (isIgnore(user))
     {
@@ -639,18 +642,38 @@ void do_logout(char *u)
        #endif
        return;
     }
-    else if (!is_playing(user))
-    {
-       notice(s_GameServ, u, "You're not logged in!");
-    }
-    else if (is_fighting(user))
+
+    if (name)
     {
-       notice(s_GameServ, u, "You can't logout while fighting!");
+       if (!isAdmin(user))
+       {
+           notice(s_GameServ, u, "You must be a %S admin to use this command!");
+       }
+       else if (!(user = findplayer(name)))
+       {
+           notice(s_GameServ, u, "Couldn't find a player named %s", name);
+       }
+       else
+       {
+           notice(s_GameServ, u, "Logging out %s", user->stats->name);
+           logout(user);
+       }
     }
-    else
+    else if (!name)
     {
-       notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
-       logout(user);
+       if (!is_playing(user))
+       {
+           notice(s_GameServ, u, "You're not logged in!");
+       }
+       else if (is_fighting(user))
+       {
+           notice(s_GameServ, u, "You can't logout while fighting!");
+       }
+       else
+       {
+           notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
+           logout(user);
+       }
     }
 }
 
index f554f05ba10e0e73c31d58c51570fa5c1f97ef8f..bf3a326e0e994768dcd1410e6bce129d57d60707 100644 (file)
@@ -44,10 +44,11 @@ remotepass linkpass
 welcomedelay 10
 
 # Message that is displayed to new clients that join the IRC Network
-# Welcomemsg is a formatted string. To use it in a function that uses formatting like notice(), you must include a string
-# as an argument. i.e. notice(s_GameServ, u, welcomemsg, nick);
-# This is only true if you include anything like %s etc... if you include more than one %s or %d or anything, you must
-# include the proper type as an argument also.
+# Welcomemsg is a formatted string. You MUST include one %s and only
+# one %s. Do not put any %d %ld or other %s into this string! You will
+# break something, because there will be a leftover argument when it is
+# called in tcpclient.cpp, because that expects one %s and nothing else.
+# Comment this out to disable sending a welcome message
 welcomemsg Hello, %s! This network utilizes a services package called GameServ. For info on how to play the game, type /msg %S help.
 
 # This is an optional config file entry that allows you to specify
index f6271dfeca170c9947f778872de4b3ad583e1c03..b31cfad21b65a8ffe5ef6ed54b3d55545cca41cc 100644 (file)
@@ -1,3 +1,4 @@
 This command allows players to stop playing without needing to quit the IRC Server.
-SYNTAX: \ 2LOGOUT\ 2
+Only %S admins may logout other players.
+SYNTAX: \ 2LOGOUT\ 2 [\1fname\1f]
 Example: /msg %S \ 2LOGOUT\ 2
index fc9e2c317bf105873f3849c74a233e69383fd709..7763f53b7b681fedc4af60c336ee749b7d538bf6 100644 (file)
@@ -336,11 +336,15 @@ int main(int argc, char *argv[])
 
 
                if (loaded)
-               #ifdef P10
-                   notice(s_GameServ, nick, welcomemsg, realnick);
-               #else
-                   notice(s_GameServ, nick, welcomemsg, nick);
-               #endif
+
+               if (isWelcome())
+               {
+                   #ifdef P10
+                       notice(s_GameServ, nick, welcomemsg, realnick);
+                   #else
+                       notice(s_GameServ, nick, welcomemsg, nick);
+                   #endif
+               }
                #ifdef P10
                    unsigned long hv = sHASH((unsigned char *) nick)
                #else