From 15217d84585fd6aaacfc75ac36961398bf74e693 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Mon, 20 Oct 2008 23:20:28 +0000 Subject: [PATCH] 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 --- src/game/client/components/menus_ingame.cpp | 4 ++++ src/game/server/hooks.cpp | 26 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 29067e413..8b28b47ee 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -148,6 +148,9 @@ void MENUS::render_serverinfo(RECT main_view) SERVER_INFO current_server_info; client_serverinfo(¤t_server_info); + if(!gameclient.snap.local_info) + return; + // count players for server info-box int num_players = 0; for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++) @@ -202,6 +205,7 @@ void MENUS::render_serverinfo(RECT main_view) current_server_info.version, current_server_info.flags&1 ? "Yes" : "No" ); + gfx_text(0, serverinfo.x+x, serverinfo.y+y, 20, buf, 250); { diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index b4e5f1f49..2d3485d0e 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);