]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
g_maplist: update with `gametype` command, as well as GUI gametype voting
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 23 Oct 2023 16:37:48 +0000 (02:37 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sat, 10 Feb 2024 08:16:57 +0000 (18:16 +1000)
This fixes the need to manually set g_maplist to \"\" after running the
gametype command on a votable server.

This is consistent with GUI gametype voting (sv_vote_gametype 1)
behaviour and shares its code to reduce duplication.

qcsrc/server/command/sv_cmd.qc
qcsrc/server/mapvoting.qc

index f05edfcb5a670225986eb18ae6f679645d540c9b..8cd6125ab12cf38afa5ad4b4edb96081bb7c7521 100644 (file)
@@ -774,30 +774,12 @@ void GameCommand_gametype(int request, int argc)
                        if (argv(1) != "")
                        {
                                string s = argv(1);
-                               Gametype t = MapInfo_Type_FromString(s, false, false), tsave = MapInfo_CurrentGametype();
+                               Gametype t = MapInfo_Type_FromString(s, false, false);
 
                                if (t)
-                               {
-                                       MapInfo_SwitchGameType(t);
-                                       MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
-                                       if (MapInfo_count > 0)
-                                       {
-                                               // update lsmaps in case the gametype changed, this way people can easily list maps for it
-                                               if (lsmaps_reply != "")   strunzone(lsmaps_reply);
-                                               lsmaps_reply = strzone(getlsmaps());
-                                               bprint("Game type successfully switched to ", s, "\n");
-                                       }
-                                       else
-                                       {
-                                               bprint("Cannot use this game type: no map for it found\n");
-                                               MapInfo_SwitchGameType(tsave);
-                                               MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
-                                       }
-                               }
+                                       GameTypeVote_SetGametype(t);
                                else
-                               {
                                        bprint("Failed to switch to ", s, ": this game type does not exist!\n");
-                               }
 
                                return;
                        }
index 051968eb00c488cbef6ebc9d53f2dcca818a9fca..c3ddeeea3ece91a6a0abbf6ed1ad39c1715b84b7 100644 (file)
@@ -772,8 +772,6 @@ bool GameTypeVote_SetGametype(Gametype type)
                return false;
        }
 
-       //localcmd("gametype ", MapInfo_Type_ToString(type), "\n");
-
        cvar_set("g_maplist", MapInfo_ListAllowedMaps(type, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags()) );
        if(autocvar_g_maplist_shuffle)
                ShuffleMaplist();