From: kainazzzo Date: Thu, 29 Apr 2004 13:08:56 +0000 (+0000) Subject: Added a new version of the logout command, and made welcomemsg config file directive... X-Git-Url: https://jfr.im/git/irc/gameservirc.git/commitdiff_plain/18b84d1132e34a601da7f44542b40c27fdd8c7dd?hp=903cd8615208a3e02ac9efbd881d73c409f996e2 Added a new version of the logout command, and made welcomemsg config file directive optional git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@187 bc333340-6410-0410-a689-9d09f3c113fa --- diff --git a/gameserv/Changes b/gameserv/Changes index 8173ac7..4768b3f 100644 --- a/gameserv/Changes +++ b/gameserv/Changes @@ -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 diff --git a/gameserv/config.cpp b/gameserv/config.cpp index 48e4d9a..7adfa56 100644 --- a/gameserv/config.cpp +++ b/gameserv/config.cpp @@ -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) { diff --git a/gameserv/flags.h b/gameserv/flags.h index c2a2ba1..c2b1f41 100644 --- a/gameserv/flags.h +++ b/gameserv/flags.h @@ -29,20 +29,25 @@ */ // 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) diff --git a/gameserv/gameserv.cpp b/gameserv/gameserv.cpp index 1929a2f..2c00c6b 100644 --- a/gameserv/gameserv.cpp +++ b/gameserv/gameserv.cpp @@ -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); + } } } diff --git a/gameserv/gameserv.example.conf b/gameserv/gameserv.example.conf index f554f05..bf3a326 100644 --- a/gameserv/gameserv.example.conf +++ b/gameserv/gameserv.example.conf @@ -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 diff --git a/gameserv/helpfiles/logout b/gameserv/helpfiles/logout index f6271df..b31cfad 100644 --- a/gameserv/helpfiles/logout +++ b/gameserv/helpfiles/logout @@ -1,3 +1,4 @@ This command allows players to stop playing without needing to quit the IRC Server. -SYNTAX: LOGOUT +Only %S admins may logout other players. +SYNTAX: LOGOUT [name] Example: /msg %S LOGOUT diff --git a/gameserv/tcpclient.cpp b/gameserv/tcpclient.cpp index fc9e2c3..7763f53 100644 --- a/gameserv/tcpclient.cpp +++ b/gameserv/tcpclient.cpp @@ -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