#define WARN_COND false
#endif
+vector _GametypeFlags_FromGametype(int a)
+{
+ if (REGISTRY_MAX(Gametypes) > 24)
+ if (a >= 24)
+ {
+ a -= 24;
+ if (REGISTRY_MAX(Gametypes) > 48)
+ if (a >= 24)
+ {
+ a -= 24;
+ return '0 0 1' * BIT(a);
+ }
+ return '0 1 0' * BIT(a);
+ }
+ return '1 0 0' * BIT(a);
+}
+
// generic string stuff
int _MapInfo_Cache_Active;
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_titlestring);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_description);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_author);
- bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_supportedGametypes));
+ bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, vtos(MapInfo_Map_supportedGametypes));
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_supportedFeatures));
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_flags));
}
MapInfo_Map_titlestring = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
MapInfo_Map_description = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
MapInfo_Map_author = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
- MapInfo_Map_supportedGametypes = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
+ MapInfo_Map_supportedGametypes = stov(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
MapInfo_Map_supportedFeatures = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
MapInfo_Map_flags = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
{
- return _MapInfo_FilterGametype(pGametype.m_flags, pFeatures, pFlagsRequired, pFlagsForbidden, pAbortOnGenerate);
+ return _MapInfo_FilterGametype(pGametype.gametype_flags, pFeatures, pFlagsRequired, pFlagsForbidden, pAbortOnGenerate);
}
-float _MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
+float _MapInfo_FilterGametype(vector pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
{
float i, j;
if (!_MapInfo_filtered_allocated)
MapInfo_progress = i / _MapInfo_globcount;
return 0;
}
- if((MapInfo_Map_supportedGametypes & pGametype) != 0)
+ if(MapInfo_Map_supportedGametypes & pGametype)
if((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures)
if((MapInfo_Map_flags & pFlagsForbidden) == 0)
if((MapInfo_Map_flags & pFlagsRequired) == pFlagsRequired)
}
diameter = vlen(mapMaxs - mapMins);
- int twoBaseModes = 0;
- FOREACH(Gametypes, it.m_isTwoBaseMode(), twoBaseModes |= it.m_flags);
+ vector twoBaseModes = '0 0 0';
+ FOREACH(Gametypes, it.m_isTwoBaseMode(), twoBaseModes |= it.gametype_flags);
if(twoBaseModes && (twoBaseModes &= MapInfo_Map_supportedGametypes))
{
// we have a symmetrical map, don't add the modes without bases
}
else if(!is_q3df_map)
{
- FOREACH(Gametypes, it.m_isAlwaysSupported(it, spawnpoints, diameter), MapInfo_Map_supportedGametypes |= it.m_flags);
+ FOREACH(Gametypes, it.m_isAlwaysSupported(it, spawnpoints, diameter), MapInfo_Map_supportedGametypes |= it.gametype_flags);
}
- if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE.m_flags)
+ if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE.gametype_flags)
if(!spawnplaces)
{
- MapInfo_Map_supportedGametypes &= ~MAPINFO_TYPE_RACE.m_flags;
- MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS.m_flags;
+ MapInfo_Map_supportedGametypes &= ~MAPINFO_TYPE_RACE.gametype_flags;
+ MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS.gametype_flags;
}
LOG_TRACE("-> diameter ", ftos(diameter));
LOG_TRACE("; spawnpoints ", ftos(spawnpoints));
- LOG_TRACE("; modes ", ftos(MapInfo_Map_supportedGametypes));
+ LOG_TRACE("; modes ", vtos(MapInfo_Map_supportedGametypes));
fclose(fh);
MapInfo_Map_titlestring = "<TITLE>";
MapInfo_Map_description = "<DESCRIPTION>";
MapInfo_Map_author = "<AUTHOR>";
- MapInfo_Map_supportedGametypes = 0;
+ MapInfo_Map_supportedGametypes = '0 0 0';
MapInfo_Map_supportedFeatures = 0;
MapInfo_Map_flags = 0;
MapInfo_Map_clientstuff = "";
void _MapInfo_Map_ApplyGametype(string s, Gametype pWantedType, Gametype pThisType, int load_default)
{
string sa;
- MapInfo_Map_supportedGametypes |= pThisType.m_flags;
- if(!(pThisType.m_flags & pWantedType.m_flags))
+ MapInfo_Map_supportedGametypes |= pThisType.gametype_flags;
+ if(!(pThisType.gametype_flags & pWantedType.gametype_flags))
return;
if(load_default)
void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThisType)
{
- MapInfo_Map_supportedGametypes |= pThisType.m_flags;
- if (!(pThisType.m_flags & pWantedType.m_flags))
+ MapInfo_Map_supportedGametypes |= pThisType.gametype_flags;
+ if (!(pThisType.gametype_flags & pWantedType.gametype_flags))
return;
// reset all the cvars to their defaults
string stored_Map_description = "";
string stored_Map_title = "";
string stored_Map_author = "";
- int stored_supportedGametypes = 0;
+ vector stored_supportedGametypes = '0 0 0';
int stored_supportedFeatures = 0;
int stored_flags = 0;
string t, s;
MapInfo_Map_supportedGametypes |= stored_supportedGametypes;
else
{
- FOREACH(Gametypes, it.m_flags & stored_supportedGametypes,
+ FOREACH(Gametypes, it.gametype_flags & stored_supportedGametypes,
{
_MapInfo_Map_ApplyGametype ("", pGametypeToSet, it, true);
});
stored_Map_description = "";
stored_Map_title = "";
stored_Map_author = "";
- stored_supportedGametypes = 0;
+ stored_supportedGametypes = '0 0 0';
stored_supportedFeatures = 0;
stored_flags = 0;
continue;
{
Gametype f = MapInfo_Type_FromString(it, false, true);
if(f)
- stored_supportedGametypes |= f.m_flags;
+ stored_supportedGametypes |= f.gametype_flags;
});
}
else if(t == "style" && isdefi)
{
// we have a defrag map on our hands, add CTS!
// TODO: styles
- stored_supportedGametypes |= MAPINFO_TYPE_CTS.m_flags;
+ stored_supportedGametypes |= MAPINFO_TYPE_CTS.gametype_flags;
}
else if(t == "map")
{
if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING)
fputs(fh, "frustrating\n");
- FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.m_flags, {
+ FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.gametype_flags, {
fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(it), _MapInfo_GetDefaultEx(it)));
});
Gametype f = NULL;
if(all || (f = MapInfo_Type_FromString(t, true, false)))
{
- if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags)
+ if((all ? MAPINFO_TYPE_ALL : f.gametype_flags) & pGametypeToSet.gametype_flags)
{
_MapInfo_Parse_Settemp(pFilename, acl, 0, s, 1);
}
Gametype f = NULL;
if(all || (f = MapInfo_Type_FromString(t, true, false)))
{
- if((all ? MAPINFO_TYPE_ALL : f.m_flags) & pGametypeToSet.m_flags)
+ if((all ? MAPINFO_TYPE_ALL : f.gametype_flags) & pGametypeToSet.gametype_flags)
{
_MapInfo_Parse_Settemp(pFilename, acl, 1, s, 1);
}
MapInfo_Map_author = ""; // don't display "<AUTHOR>" in the UI (we do write it to .mapinfo files)
MapInfo_Cache_Store();
- if(MapInfo_Map_supportedGametypes != 0)
+ if(MapInfo_Map_supportedGametypes != '0 0 0')
return r;
if (WARN_COND)
LOG_WARN("Map ", pFilename, " supports no game types, ignored");
if(pGametypeToSet)
{
- if(!(MapInfo_Map_supportedGametypes & pGametypeToSet.m_flags))
+ if(!(MapInfo_Map_supportedGametypes & pGametypeToSet.gametype_flags))
{
error("Can't select the requested game type. This should never happen as the caller should prevent it!\n");
//_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
{
if(!MapInfo_Get_ByName(s, 1, NULL))
return 0;
- if((MapInfo_Map_supportedGametypes & MapInfo_CurrentGametype().m_flags) == 0)
+ if(!(MapInfo_Map_supportedGametypes & MapInfo_CurrentGametype().gametype_flags))
return 0;
if (gametype_only)
return 1;
void MapInfo_LoadMap(string s, float reinit)
{
- MapInfo_Map_supportedGametypes = 0;
+ MapInfo_Map_supportedGametypes = '0 0 0';
// we shouldn't need this, as LoadMapSettings already fixes the gametype
//if(!MapInfo_CheckMap(s))
//{
// print("EMERGENCY: can't play the selected map in the given game mode. Falling back to DM.\n");
- // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH.m_flags);
+ // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH.gametype_flags);
//}
LOG_INFO("Switching to map ", s);
return; // do not call Get_ByName!
}
- if(MapInfo_Map_supportedGametypes == 0)
+ if(MapInfo_Map_supportedGametypes == '0 0 0')
{
RandomSelection_Init();
FOREACH(Gametypes, it.m_priority == 2,
{
- MapInfo_Map_supportedGametypes |= it.m_flags;
+ MapInfo_Map_supportedGametypes |= it.gametype_flags;
RandomSelection_AddEnt(it, 1, 1);
});
if(RandomSelection_chosen_ent)
#endif
RandomSelection_Init();
Gametype t_prev = t;
- FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.m_flags,
+ FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.gametype_flags,
{
RandomSelection_AddEnt(it, 1, it.m_priority);
});
MapInfo_Map_description = string_null;
MapInfo_Map_author = string_null;
MapInfo_Map_clientstuff = string_null;
- MapInfo_Map_supportedGametypes = 0;
+ MapInfo_Map_supportedGametypes = '0 0 0';
MapInfo_Map_supportedFeatures = 0;
}
string MapInfo_Map_author;
string MapInfo_Map_clientstuff; // not in cache, only for map load
string MapInfo_Map_fog; // not in cache, only for map load
-int MapInfo_Map_supportedGametypes;
+vector MapInfo_Map_supportedGametypes;
int MapInfo_Map_supportedFeatures;
int MapInfo_Map_flags;
vector MapInfo_Map_mins; // these are '0 0 0' if not supported!
const int GAMETYPE_FLAG_WEAPONARENA = BIT(5); // gametype has a forced weapon arena, weapon arena mutators should disable themselves when this is set
const int GAMETYPE_FLAG_1V1 = BIT(6); // 1v1 gameplay
-int MAPINFO_TYPE_ALL;
-.int m_flags;
+vector MAPINFO_TYPE_ALL;
+.vector gametype_flags;
+
+// must be defined before the registry
+vector _GametypeFlags_FromGametype(int a);
CLASS(Gametype, Object)
ATTRIB(Gametype, m_id, int, 0);
this.m_hidelimits = (gflags & GAMETYPE_FLAG_HIDELIMITS);
this.m_weaponarena = (gflags & GAMETYPE_FLAG_WEAPONARENA);
this.m_1v1 = (gflags & GAMETYPE_FLAG_1V1);
-
- // same as `1 << m_id`
- MAPINFO_TYPE_ALL |= this.items = this.m_flags = (MAPINFO_TYPE_ALL + 1);
}
ENDCLASS(Gametype)
REGISTRY_CHECK(Gametypes)
REGISTRY_DEFINE_GET(Gametypes, NULL)
-STATIC_INIT(Gametypes_renumber) { FOREACH(Gametypes, true, it.m_id = i); }
+STATIC_INIT(Gametypes_renumber)
+{
+ FOREACH(Gametypes, true,
+ {
+ it.m_id = i;
+ vector set = it.gametype_flags = _GametypeFlags_FromGametype(it.m_id);
+ MAPINFO_TYPE_ALL |= set;
+ });
+}
#define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
#ifndef CSQC
// filter the info by game type mask (updates MapInfo_count)
float MapInfo_progress;
float MapInfo_FilterGametype(Gametype gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
-float _MapInfo_FilterGametype(int gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
+float _MapInfo_FilterGametype(vector gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
void MapInfo_FilterString(string sf); // filter _MapInfo_filtered (created by MapInfo_FilterGametype) with keyword
int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
Gametype MapInfo_CurrentGametype(); // retrieves current gametype from cvars