From 0edde87771462b5782fc058cce40167d3506ca9c Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 29 Sep 2018 16:33:29 +1000 Subject: [PATCH] Add a property to tell when gamemodes are supposed to be forced supported (TDM on DM maps) --- qcsrc/common/mapinfo.qc | 8 +------- qcsrc/common/mapinfo.qh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 859ec51d5..17093f88e 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -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) { diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 4addd2400..63723afd7 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -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); -- 2.39.2