5 // info about a map that MapInfo loads
6 string MapInfo_Map_bspname;
7 string MapInfo_Map_title;
8 string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant
9 string MapInfo_Map_description;
10 string MapInfo_Map_author;
11 string MapInfo_Map_clientstuff; // not in cache, only for map load
12 string MapInfo_Map_fog; // not in cache, only for map load
13 int MapInfo_Map_supportedGametypes;
14 int MapInfo_Map_supportedFeatures;
15 int MapInfo_Map_flags;
16 vector MapInfo_Map_mins; // these are '0 0 0' if not supported!
17 vector MapInfo_Map_maxs; // these are '0 0 0' if not specified!
19 const int GAMETYPE_FLAG_TEAMPLAY = BIT(0); // teamplay based
20 const int GAMETYPE_FLAG_USEPOINTS = BIT(1); // gametype has point-based scoring
21 const int GAMETYPE_FLAG_PREFERRED = BIT(2); // preferred (when available) in random selections
22 const int GAMETYPE_FLAG_PRIORITY = BIT(3); // priority selection when preferred gametype isn't available in random selections
23 const int GAMETYPE_FLAG_HIDELIMITS = BIT(4); // don't display a score limit needed for winning the match in the scoreboard
28 CLASS(Gametype, Object)
29 ATTRIB(Gametype, m_id, int, 0);
31 ATTRIB(Gametype, items, int, 0);
32 /** game type name as in cvar (with g_ prefix) */
33 ATTRIB(Gametype, netname, string);
34 /** game type short name */
35 ATTRIB(Gametype, mdl, string);
36 /** human readable name */
37 ATTRIB(Gametype, message, string);
38 /** does this gametype support teamplay? */
39 ATTRIB(Gametype, team, bool, false);
40 /** does this gametype use a point limit? */
41 ATTRIB(Gametype, frags, bool, true);
42 /** should this gametype display a score limit in the scoreboard? */
43 ATTRIB(Gametype, m_hidelimits, bool, false);
44 /** game type defaults */
45 ATTRIB(Gametype, model2, string);
46 /** game type description */
47 ATTRIB(Gametype, gametype_description, string);
48 /** game type priority in random selections */
49 ATTRIB(Gametype, m_priority, int, 0);
51 ATTRIB(Gametype, m_modicons, void(vector pos, vector mySize));
52 ATTRIB(Gametype, m_modicons_reset, void());
53 ATTRIB(Gametype, m_modicons_export, void(int fh));
56 /** DO NOT USE, this is compatibility for legacy maps! */
57 ATTRIB(Gametype, m_legacydefaults, string, "");
59 ATTRIB(Gametype, m_mutators, string);
60 METHOD(Gametype, m_parse_mapinfo, bool(string k, string v))
64 METHOD(Gametype, m_generate_mapinfo, void(Gametype this, string v))
68 METHOD(Gametype, m_isTwoBaseMode, bool())
72 METHOD(Gametype, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
76 METHOD(Gametype, m_isForcedSupported, bool(Gametype this))
80 METHOD(Gametype, m_configuremenu, void(Gametype this, entity menu, void(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip) returns))
83 returns(menu, _("Frag limit:"), 5, 100, 5, "fraglimit_override", string_null, _("The amount of frags needed before the match will end"));
86 METHOD(Gametype, describe, string(Gametype this))
89 return this.gametype_description;
92 METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns))
95 returns(this.message, strcat("gametype_", this.mdl));
98 METHOD(Gametype, gametype_init, void(Gametype this, string hname, string sname, string g_name, int gflags, string mutators, string defaults, string gdescription))
100 this.netname = g_name;
102 this.message = hname;
103 this.team = (gflags & GAMETYPE_FLAG_TEAMPLAY);
104 this.m_mutators = cons(sname, mutators);
105 this.model2 = defaults;
106 this.gametype_description = gdescription;
107 this.frags = (gflags & GAMETYPE_FLAG_USEPOINTS);
108 this.m_priority = ((gflags & GAMETYPE_FLAG_PREFERRED) ? 2 : ((gflags & GAMETYPE_FLAG_PRIORITY) ? 1 : 0));
109 this.m_hidelimits = (gflags & GAMETYPE_FLAG_HIDELIMITS);
111 // same as `1 << m_id`
112 MAPINFO_TYPE_ALL |= this.items = this.m_flags = (MAPINFO_TYPE_ALL + 1);
116 REGISTRY(Gametypes, 32)
117 REGISTER_REGISTRY(Gametypes)
118 REGISTRY_SORT(Gametypes);
119 REGISTRY_CHECK(Gametypes)
121 REGISTRY_DEFINE_GET(Gametypes, NULL)
122 STATIC_INIT(Gametypes_renumber) { FOREACH(Gametypes, true, it.m_id = i); }
123 #define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
125 #define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
127 const int MAPINFO_FEATURE_WEAPONS = 1; // not defined for instagib-only maps
128 const int MAPINFO_FEATURE_VEHICLES = 2;
129 const int MAPINFO_FEATURE_TURRETS = 4;
130 const int MAPINFO_FEATURE_MONSTERS = 8;
132 const int MAPINFO_FLAG_HIDDEN = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually
133 const int MAPINFO_FLAG_FORBIDDEN = 2; // don't even allow the map by a cvar setting that allows hidden maps
134 const int MAPINFO_FLAG_FRUSTRATING = 4; // this map is near impossible to play, enable at your own risk
135 const int MAPINFO_FLAG_NOAUTOMAPLIST = 8; // do not include when automatically building maplist (counts as hidden for maplist building purposes)
139 // load MapInfo_count; generate mapinfo for maps that miss them, and clear the
140 // cache; you need to call MapInfo_FilterGametype afterwards!
141 void MapInfo_Enumerate();
143 // filter the info by game type mask (updates MapInfo_count)
144 float MapInfo_progress;
145 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)
146 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)
147 void MapInfo_FilterString(string sf); // filter _MapInfo_filtered (created by MapInfo_FilterGametype) with keyword
148 int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
149 Gametype MapInfo_CurrentGametype(); // retrieves current gametype from cvars
150 int MapInfo_ForbiddenFlags(); // retrieves current flags from cvars
151 int MapInfo_RequiredFlags(); // retrieves current flags from cvars
153 // load info about the i-th map into the MapInfo_Map_* globals
154 float MapInfo_Get_ByID(float i); // 1 on success, 0 on failure
155 string MapInfo_BSPName_ByID(float i);
157 // load info about a map by name into the MapInfo_Map_* globals
158 int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet); // 1 on success, 0 on failure, 2 if it autogenerated a mapinfo file
160 // look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
161 string MapInfo_FindName_match; // the name of the map that was found
162 float MapInfo_FindName_firstResult; // -1 if none were found, index of first one if not unique but found (FindName then returns -1)
163 float MapInfo_FindName(string s);
164 string MapInfo_FixName(string s);
167 float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
168 void MapInfo_LoadMap(string s, float reinit);
170 // list all maps for the current game type
171 string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden);
172 // list all allowed maps (for any game type)
173 string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
175 // gets a gametype from a string
176 string _MapInfo_GetDefaultEx(Gametype t);
177 float _MapInfo_GetTeamPlayBool(Gametype t);
178 Gametype MapInfo_Type_FromString(string t, bool dowarn);
179 string MapInfo_Type_Description(Gametype t);
180 string MapInfo_Type_ToString(Gametype t);
181 string MapInfo_Type_ToText(Gametype t);
182 void MapInfo_SwitchGameType(Gametype t);
184 // to be called from worldspawn to set up cvars
185 void MapInfo_LoadMapSettings(string s);
186 Gametype MapInfo_LoadedGametype; // game type that was active during map load
188 void MapInfo_Cache_Destroy(); // disable caching
189 void MapInfo_Cache_Create(); // enable caching
190 void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled
192 void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse);
194 void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame
196 void MapInfo_Shutdown(); // call this in the shutdown handler
198 #define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
199 #define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* +*"