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

This commit is contained in:
Magnus Auvinen 2008-10-20 23:20:28 +00:00
parent da473cf614
commit 15217d8458
2 changed files with 30 additions and 0 deletions

View file

@ -148,6 +148,9 @@ void MENUS::render_serverinfo(RECT main_view)
SERVER_INFO current_server_info;
client_serverinfo(&current_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);
{

View file

@ -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);