diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-20 23:20:28 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-20 23:20:28 +0000 |
| commit | 15217d84585fd6aaacfc75ac36961398bf74e693 (patch) | |
| tree | 44718c2a87feadc212744bf85f0aab5b49c20890 /src/game/server/hooks.cpp | |
| parent | da473cf614cb49ddf15f7dde9cbaeb46aa86babf (diff) | |
| download | zcatch-15217d84585fd6aaacfc75ac36961398bf74e693.tar.gz zcatch-15217d84585fd6aaacfc75ac36961398bf74e693.zip | |
fixed so that you can't vote on maps that arn't in the map list. fixed crash bug in the server info menu page
Diffstat (limited to 'src/game/server/hooks.cpp')
| -rw-r--r-- | src/game/server/hooks.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index b4e5f1f4..2d3485d0 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -121,6 +121,26 @@ void mods_client_drop(int client_id) (void) game.controller->check_team_balance(); } +static bool is_separator(char c) { return c == ';' || c == ' ' || c == ',' || c == '\t'; } + +static const char *liststr_find(const char *str, const char *needle) +{ + int needle_len = strlen(needle); + while(*str) + { + int wordlen = 0; + while(str[wordlen] && !is_separator(str[wordlen])) + wordlen++; + + if(wordlen == needle_len && strncmp(str, needle, needle_len) == 0) + return str; + + str += wordlen+1; + } + + return 0; +} + void mods_message(int msgtype, int client_id) { void *rawmsg = netmsg_secure_unpack(msgtype); @@ -178,6 +198,12 @@ void mods_message(int msgtype, int client_id) return; } + if(!liststr_find(config.sv_maplist, msg->value)) + { + game.send_chat(-1, client_id, "Map is not in the map list"); + return; + } + str_format(chatmsg, sizeof(chatmsg), "Vote called to change map to '%s'", msg->value); str_format(desc, sizeof(desc), "Change map to '%s'", msg->value); str_format(cmd, sizeof(cmd), "sv_map %s", msg->value); |