From 2394e0a72e7396aa7aadced56f55f9bc3cc18969 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 26 Jul 2024 02:59:22 +0000 Subject: [PATCH] Add map list curation support to gametype votes --- gamemodes-server.cfg | 1 + qcsrc/server/mapvoting.qc | 17 ++++++++++++++--- qcsrc/server/mapvoting.qh | 1 + xonotic-server.cfg | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index f3b6a95bb..68b2606e0 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -72,6 +72,7 @@ alias sv_vote_gametype_hook_surv // sv_vote_gametype_*_type Must be set to the name of the gametype the option is based on // sv_vote_gametype_*_name Contains a human-readable name of the gametype // sv_vote_gametype_*_description Contains a longer description +// sv_vote_gametype_*_maplist Optional list of maps for the gametype //set sv_vote_gametype_1v1ctf_type ctf //set sv_vote_gametype_1v1ctf_name "Capture the Flag Duel" //set sv_vote_gametype_1v1ctf_description "One vs One match in CTF" diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index 72969a0ab..8fa3c54f0 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -764,6 +764,8 @@ void MapVote_Think() // otherwise gametype_string is the string (short name) of a custom gametype bool GameTypeVote_SetGametype(Gametype type, string gametype_string, bool call_hooks) { + if (gametype_string == "") + gametype_string = MapInfo_Type_ToString(type); if (!call_hooks) { // custom gametype is disabled because gametype hooks can't be executed @@ -771,8 +773,6 @@ bool GameTypeVote_SetGametype(Gametype type, string gametype_string, bool call_h } else { - if (gametype_string == "") - gametype_string = MapInfo_Type_ToString(type); gametype_custom_enabled = (gametype_string != MapInfo_Type_ToString(type)); localcmd("sv_vote_gametype_hook_all\n"); @@ -805,7 +805,18 @@ bool GameTypeVote_SetGametype(Gametype type, string gametype_string, bool call_h return false; } - cvar_set("g_maplist", MapInfo_ListAllowedMaps(type, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags()) ); + bool doreset = autocvar_sv_vote_gametype_maplist_reset; + string gvmaplist = strcat("sv_vote_gametype_", gametype_string, "_maplist"); + if(cvar_type(gvmaplist) & CVAR_TYPEFLAG_EXISTS) + { + // force a reset if the provided list is empty + if(cvar_string(gvmaplist) == "") + doreset = true; + else + cvar_set("g_maplist", cvar_string(gvmaplist)); + } + if(doreset) + cvar_set("g_maplist", MapInfo_ListAllowedMaps(type, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags()) ); return true; } diff --git a/qcsrc/server/mapvoting.qh b/qcsrc/server/mapvoting.qh index f2515bdad..e8d8f5de8 100644 --- a/qcsrc/server/mapvoting.qh +++ b/qcsrc/server/mapvoting.qh @@ -24,6 +24,7 @@ float autocvar_sv_vote_gametype_timeout; string autocvar_sv_vote_gametype_options; float autocvar_sv_vote_gametype_keeptwotime; bool autocvar_sv_vote_gametype_default_current; +bool autocvar_sv_vote_gametype_maplist_reset = true; // definitions for functions used outside mapvoting.qc void MapVote_Start(); diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 461c2e524..53553806a 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -374,6 +374,7 @@ set sv_vote_gametype_keeptwotime 10 "show only 2 options after this amount of ti set sv_vote_gametype_options "dm tdm ca ctf" "identifiers of gamemodes on the voting screen, can be custom (max 9 chars) - see example in server/server.cfg" set sv_vote_gametype_timeout 20 "how long the gametype vote screen lasts" set sv_vote_gametype_default_current 1 "Keep the current gametype if no one votes" +set sv_vote_gametype_maplist_reset 1 "Reset g_maplist when switching to a new gametype" set g_chat_flood_spl 3 "normal chat: seconds between lines to not count as flooding" set g_chat_flood_lmax 2 "normal chat: maximum number of lines per chat message at once" -- 2.39.2