]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Store the current gametype as a shortname rather than registry ID, fixes some issues...
authorMario <mario.mario@y7mail.com>
Sat, 18 Jul 2020 09:48:09 +0000 (19:48 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 18 Jul 2020 09:48:09 +0000 (19:48 +1000)
qcsrc/client/mapvoting.qc
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh
qcsrc/common/mapobjects/target/changelevel.qc
qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc
qcsrc/server/campaign.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/mapvoting.qc

index c025bdd4651229ed39d182281ca9f4542b31fb59..2129b7802735149564d8891117e29ed61db9ce4e 100644 (file)
@@ -636,7 +636,7 @@ void GameTypeVote_ReadOption(int i)
        }
        else
        {
-               Gametype type = MapInfo_Type_FromString(gt);
+               Gametype type = MapInfo_Type_FromString(gt, false);
                mv_pk3[i] = strzone(MapInfo_Type_ToText(type));
                mv_desc[i] = MapInfo_Type_Description(type);
        }
index 36c32a057176ce2f069349464842732bf34894ed..dce55aa86e07c9b9c1cb4135d36c8acdbd508005 100644 (file)
@@ -589,7 +589,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThis
        }
 }
 
-Gametype MapInfo_Type_FromString(string gtype)
+Gametype MapInfo_Type_FromString(string gtype, bool dowarn)
 {
        string replacement = "";
        switch (gtype)
@@ -603,7 +603,7 @@ Gametype MapInfo_Type_FromString(string gtype)
        }
        if (replacement != "")
        {
-               if (WARN_COND)
+               if (dowarn && WARN_COND)
                        LOG_WARNF("MapInfo_Type_FromString (probably %s): using deprecated name '%s'. Should use '%s'.", MapInfo_Map_bspname, gtype, replacement);
                gtype = replacement;
        }
@@ -921,7 +921,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
                else if(t == "type")
                {
                        t = car(s); s = cdr(s);
-                       Gametype f = MapInfo_Type_FromString(t);
+                       Gametype f = MapInfo_Type_FromString(t, true);
                        //if(WARN_COND)
                                //LOG_WARN("Map ", pFilename, " contains the legacy 'type' keyword which is deprecated and will be removed in the future. Please migrate the mapinfo file to 'gametype'.");
                        if(f)
@@ -932,7 +932,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
                else if(t == "gametype")
                {
                        t = car(s); s = cdr(s);
-                       Gametype f = MapInfo_Type_FromString(t);
+                       Gametype f = MapInfo_Type_FromString(t, true);
                        if(f)
                                _MapInfo_Map_ApplyGametypeEx (s, pGametypeToSet, f);
                        else if(WARN_COND)
@@ -983,7 +983,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
                        t = car(s); s = cdr(s);
                        bool all = t == "all";
                        Gametype f = NULL;
-                       if(all || (f = MapInfo_Type_FromString(t)))
+                       if(all || (f = MapInfo_Type_FromString(t, true)))
                        {
                                if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags)
                                {
@@ -1000,7 +1000,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
                        t = car(s); s = cdr(s);
                        bool all = t == "all";
                        Gametype f = NULL;
-                       if(all || (f = MapInfo_Type_FromString(t)))
+                       if(all || (f = MapInfo_Type_FromString(t, true)))
                        {
                                if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags)
                                {
@@ -1148,7 +1148,7 @@ int MapInfo_CurrentFeatures()
 
 Gametype MapInfo_CurrentGametype()
 {
-       Gametype prev = REGISTRY_GET(Gametypes, cvar("gamecfg"));
+       Gametype prev = MapInfo_Type_FromString(cvar_string("gamecfg"), false);
        FOREACH(Gametypes, cvar(it.netname) && it != prev, return it);
        return prev ? prev : MAPINFO_TYPE_DEATHMATCH;
 }
@@ -1232,7 +1232,7 @@ string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
 void MapInfo_LoadMapSettings_SaveGameType(Gametype t)
 {
        MapInfo_SwitchGameType(t);
-       cvar_set("gamecfg", ftos(t.m_id));
+       cvar_set("gamecfg", t.mdl);
        MapInfo_LoadedGametype = t;
 }
 
index 7059a122d7129d0bcf93105aa3cc5361baa0206b..68b5d0b3b888addd754d9e074b21b04dbef4d9c9 100644 (file)
@@ -174,7 +174,7 @@ string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
 // gets a gametype from a string
 string _MapInfo_GetDefaultEx(Gametype t);
 float _MapInfo_GetTeamPlayBool(Gametype t);
-Gametype MapInfo_Type_FromString(string t);
+Gametype MapInfo_Type_FromString(string t, bool dowarn);
 string MapInfo_Type_Description(Gametype t);
 string MapInfo_Type_ToString(Gametype t);
 string MapInfo_Type_ToText(Gametype t);
index 7166e46ca66ef0906aa0b653b831e6e6caa759dd..876fed7a7306cab48686a8adef6c1e18caf94e0c 100644 (file)
@@ -28,7 +28,7 @@ void target_changelevel_use(entity this, entity actor, entity trigger)
        }
 
        if(this.gametype != "")
-               MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype));
+               MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype, false));
 
        if (this.chmap == "")
        {
index 5745ce072e044940ddadd3d2e19dd41875e65dbb..cf542f39c8f47d0d6120c6ef1e56336a07676e90 100644 (file)
@@ -84,7 +84,7 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
        if(s != "data")
                modname = sprintf("%s (%s)", modname, s);
 
-       Gametype j = MapInfo_Type_FromString(typestr); // try and get the real name of the game type
+       Gametype j = MapInfo_Type_FromString(typestr, false); // try and get the real name of the game type
        if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
 
        me.currentServerType = strzone(typestr);
index 1a01868fb3b1cc660d0e2720dac392dfdafef648..784288a6ee555b50dbf6637f238f0b4a4168bc92 100644 (file)
@@ -33,7 +33,7 @@ float Campaign_Invalid()
        string thismapname, wantedmapname;
        thismapname = GetMapname();
        wantedmapname = campaign_gametype[0];
-       if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname))
+       if(MapInfo_CurrentGametype() != MapInfo_Type_FromString(wantedmapname, false))
                return CampaignBailout("wrong game type!");
        wantedmapname = campaign_mapname[0];
        if(wantedmapname != thismapname)
@@ -67,7 +67,7 @@ void CampaignPreInit()
 
        if(autocvar_sv_cheats)
        {
-               MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0]));
+               MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false));
                CampaignFile_Unload();
                CampaignBailout("JOLLY CHEATS AHAHAHAHAHAHAH))");
                return;
@@ -96,7 +96,7 @@ void CampaignPreInit()
        cvar_settemp("skill", ftos(baseskill));
        cvar_settemp("bot_number", ftos(campaign_bots[0]));
 
-       MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0]));
+       MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false));
 
        if(Campaign_Invalid())
                return;
index 62edb992f9749b723ab8c559d979c5280f098aa9..034bd6cb92cc37004d364ff67334f355855c287d 100644 (file)
@@ -723,7 +723,7 @@ void GameCommand_gametype(int request, int argc)
                        if (argv(1) != "")
                        {
                                string s = argv(1);
-                               Gametype t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
+                               Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype();
 
                                if (t)
                                {
index fe8748f3852b494f2bf19ed73803f955bfebd00a..e427483069522786f163c6ff9cf6908151c8e84f 100644 (file)
@@ -47,10 +47,10 @@ entity mapvote_ent;
  */
 Gametype GameTypeVote_Type_FromString(string type_name)
 {
-       Gametype type = MapInfo_Type_FromString(type_name);
+       Gametype type = MapInfo_Type_FromString(type_name, false);
        if (type == NULL)
                type = MapInfo_Type_FromString(cvar_string(
-                       strcat("sv_vote_gametype_",type_name,"_type")));
+                       strcat("sv_vote_gametype_",type_name,"_type")), false);
        return type;
 }
 
@@ -58,11 +58,11 @@ int GameTypeVote_AvailabilityStatus(string type_name)
 {
        int flag = GTV_FORBIDDEN;
 
-       Gametype type = MapInfo_Type_FromString(type_name);
+       Gametype type = MapInfo_Type_FromString(type_name, false);
        if ( type == NULL )
        {
                type = MapInfo_Type_FromString(cvar_string(
-                       strcat("sv_vote_gametype_",type_name,"_type")));
+                       strcat("sv_vote_gametype_",type_name,"_type")), false);
                flag |= GTV_CUSTOM;
        }