mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
da473cf614
commit
15217d8458
|
@ -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);
|
||||
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue