]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix current custom gametype not being kept if gametype vote ends without votes
authorterencehill <piuntn@gmail.com>
Thu, 21 Mar 2024 17:43:43 +0000 (18:43 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 21 Mar 2024 17:43:43 +0000 (18:43 +0100)
qcsrc/server/mapvoting.qc
qcsrc/server/scores.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index f10dcae583f2fd0b2413f481acc80db65de481c0..1a6e24960d535912b456804d2d3fb03ada3c0efe 100644 (file)
@@ -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;
index 2bdb8cdf056dc21f9a6e78a36188853bc85d6a69..05ea6e1a0b3d54e5e5fcc9ca58df946191f2b8c0 100644 (file)
@@ -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));
index ad40a389543bcb5698d2abc2a0ddd1068e1f0557..48ef7727373450a62d7703ac4845afbd30ecef69 100644 (file)
@@ -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)
        {
index a7301dc799b1fa96bc5a3102d95bc71faa3bd167..a5e848d45dbd8d4c951f5ab5ca02e2fed1aa3960 100644 (file)
@@ -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;