]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a property to tell when gamemodes are supposed to be forced supported (TDM on...
authorMario <mario@smbclan.net>
Sat, 29 Sep 2018 06:33:29 +0000 (16:33 +1000)
committerMario <mario@smbclan.net>
Sat, 29 Sep 2018 06:33:29 +0000 (16:33 +1000)
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh

index 859ec51d54809709a8fd9a52f922902fed7ee112..17093f88ef58b746815f9bf0e108ebfe3f5ce313 100644 (file)
@@ -1067,13 +1067,7 @@ int MapInfo_Get_ByName(string pFilename, float pAllowGenerate, Gametype pGametyp
 {
        int r = MapInfo_Get_ByName_NoFallbacks(pFilename, pAllowGenerate, pGametypeToSet);
 
-       if(cvar("g_tdm_on_dm_maps"))
-       {
-               // if this is set, all DM maps support TDM too
-               if (!(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH.m_flags))
-                       if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH.m_flags)
-                               _MapInfo_Map_ApplyGametypeEx ("", pGametypeToSet, MAPINFO_TYPE_TEAM_DEATHMATCH);
-       }
+       FOREACH(Gametypes, it.m_isForcedSupported(it), _MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, it));
 
        if(pGametypeToSet)
        {
index 4addd24001f6d32a594424a2761855c222f3b300..63723afd7ab2deb70023f05a2762d108d082f9c8 100644 (file)
@@ -57,6 +57,10 @@ CLASS(Gametype, Object)
     {
         return false;
     }
+    METHOD(Gametype, m_isForcedSupported, bool(Gametype this))
+    {
+        return false;
+    }
 
     METHOD(Gametype, describe, string(Gametype this))
     {
@@ -202,6 +206,16 @@ CLASS(TeamDeathmatch, Gametype)
             return true;
         return false;
     }
+    METHOD(TeamDeathmatch, m_isForcedSupported, bool(Gametype this))
+    {
+        if(cvar("g_tdm_on_dm_maps"))
+        {
+            // if this is set, all DM maps support TDM too
+            if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH.m_flags))
+                return true; // TODO: references another gametype (alternatively, we could check which gamemodes are always enabled and append this if any are supported)
+        }
+        return false;
+    }
     METHOD(TeamDeathmatch, m_setTeams, void(string sa))
     {
         cvar_set("g_tdm_teams", sa);