From: terencehill Date: Thu, 21 Mar 2024 17:43:43 +0000 (+0100) Subject: Fix current custom gametype not being kept if gametype vote ends without votes X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0f31b82e541b8523a73eb7bbbdcc3656649c8680;p=xonotic%2Fxonotic-data.pk3dir.git Fix current custom gametype not being kept if gametype vote ends without votes --- diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index f10dcae58..1a6e24960 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -278,7 +278,7 @@ void MapVote_Init() // properly restarts the map applying the current game type. // Applying voted_gametype before map vote start is needed to properly initialize map vote. if (match_gametype) - GameTypeVote_ApplyGameType(match_gametype, gametype_custom_string); + GameTypeVote_ApplyGameType(match_gametype, loaded_gametype_custom_string); } void MapVote_SendPicture(entity to, int id) @@ -564,11 +564,16 @@ bool MapVote_CheckRules_2() RandomSelection_Init(); currentPlace = 0; currentVotes = -1; + string current_gametype_string; + if (loaded_gametype_custom_string != "") + current_gametype_string = loaded_gametype_custom_string; + else + current_gametype_string = MapInfo_Type_ToString(MapInfo_CurrentGametype()); for(i = 0; i < mapvote_count_real; ++i) if ( mapvote_maps_flags[i] & GTV_AVAILABLE ) { RandomSelection_AddFloat(i, 1, mapvote_selections[i]); - if ( gametypevote && mapvote_maps[i] == MapInfo_Type_ToString(MapInfo_CurrentGametype()) ) + if ( gametypevote && mapvote_maps[i] == current_gametype_string ) { currentVotes = mapvote_selections[i]; currentPlace = i; @@ -877,7 +882,12 @@ bool GameTypeVote_Start() { if ( mapvote_count > 0 ) strunzone(mapvote_maps[0]); - mapvote_maps[0] = strzone(MapInfo_Type_ToString(MapInfo_CurrentGametype())); + string current_gametype_string; + if (loaded_gametype_custom_string != "") + current_gametype_string = loaded_gametype_custom_string; + else + current_gametype_string = MapInfo_Type_ToString(MapInfo_CurrentGametype()); + mapvote_maps[0] = strzone(current_gametype_string); //GameTypeVote_Finished(0); MapVote_Finished(0); return false; diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 2bdb8cdf0..05ea6e1a0 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -209,8 +209,8 @@ bool ScoreInfo_SendEntity(entity this, entity to, int sf) WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO); WriteRegistered(Gametypes, MSG_ENTITY, MapInfo_LoadedGametype); string gt_name = ""; - if (gametype_custom_string != "") - gt_name = cvar_string(strcat("sv_vote_gametype_", gametype_custom_string, "_name")); + if (loaded_gametype_custom_string != "") + gt_name = cvar_string(strcat("sv_vote_gametype_", loaded_gametype_custom_string, "_name")); WriteString(MSG_ENTITY, gt_name); FOREACH(Scores, true, { WriteString(MSG_ENTITY, scores_label(it)); diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index ad40a3895..48ef77273 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -736,7 +736,7 @@ void InitGameplayMode() MapInfo_ClearTemps(); - strcpy(gametype_custom_string, autocvar__sv_vote_gametype_custom); + strcpy(loaded_gametype_custom_string, autocvar__sv_vote_gametype_custom); cvar_set("_sv_vote_gametype_custom", ""); // clear it immediately so it can't get stuck cache_mutatormsg = strzone(""); @@ -2645,7 +2645,7 @@ void Shutdown() MapInfo_Shutdown(); strfree(sv_termsofservice_url_escaped); - strfree(gametype_custom_string); + strfree(loaded_gametype_custom_string); } else if(world_initialized == 0) { diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index a7301dc79..a5e848d45 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -49,7 +49,7 @@ float cvar_purechanges_count; string modname; string autocvar__sv_vote_gametype_custom; -string gametype_custom_string; +string loaded_gametype_custom_string; string record_type;