]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapinfo.qh
Merge branch 'master' into Mario/stats_eloranking
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapinfo.qh
1 #pragma once
2
3 #include "util.qh"
4
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!
18
19 int MAPINFO_TYPE_ALL;
20 .int m_flags;
21
22 CLASS(Gametype, Object)
23     ATTRIB(Gametype, m_id, int, 0);
24     /** game type ID */
25     ATTRIB(Gametype, items, int, 0);
26     /** game type name as in cvar (with g_ prefix) */
27     ATTRIB(Gametype, netname, string);
28     /** game type short name */
29     ATTRIB(Gametype, mdl, string);
30     /** human readable name */
31     ATTRIB(Gametype, message, string);
32     /** does this gametype support teamplay? */
33     ATTRIB(Gametype, team, bool, false);
34     /** does this gametype use a point limit? */
35     ATTRIB(Gametype, frags, bool, true);
36     /** game type defaults */
37     ATTRIB(Gametype, model2, string);
38     /** game type description */
39     ATTRIB(Gametype, gametype_description, string);
40 #ifdef CSQC
41     ATTRIB(Gametype, m_modicons, void(vector pos, vector mySize));
42     ATTRIB(Gametype, m_modicons_reset, void());
43 #endif
44
45     /** DO NOT USE, this is compatibility for legacy maps! */
46     ATTRIB(Gametype, m_legacydefaults, string, "");
47
48     ATTRIB(Gametype, m_mutators, string);
49     METHOD(Gametype, m_parse_mapinfo, bool(string k, string v))
50     {
51         return false;
52     }
53     METHOD(Gametype, m_generate_mapinfo, void(Gametype this, string v))
54     {
55         TC(Gametype, this);
56     }
57     METHOD(Gametype, m_isTwoBaseMode, bool())
58     {
59         return false;
60     }
61     METHOD(Gametype, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
62     {
63         return false;
64     }
65     METHOD(Gametype, m_isForcedSupported, bool(Gametype this))
66     {
67         return false;
68     }
69     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))
70     {
71         TC(Gametype, this);
72         returns(menu, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        string_null,                    _("The amount of frags needed before the match will end"));
73     }
74
75     METHOD(Gametype, describe, string(Gametype this))
76     {
77         TC(Gametype, this);
78         return this.gametype_description;
79     }
80
81     METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns))
82     {
83         TC(Gametype, this);
84         returns(this.message, strcat("gametype_", this.mdl));
85     }
86
87     METHOD(Gametype, gametype_init, void(Gametype this, string hname, string sname, string g_name, bool gteamplay, bool gusepoints, string mutators, string defaults, string gdescription))
88     {
89         this.netname = g_name;
90         this.mdl = sname;
91         this.message = hname;
92         this.team = gteamplay;
93         this.m_mutators = cons(sname, mutators);
94         this.model2 = defaults;
95         this.gametype_description = gdescription;
96         this.frags = gusepoints;
97
98         // same as `1 << m_id`
99         MAPINFO_TYPE_ALL |= this.items = this.m_flags = (MAPINFO_TYPE_ALL + 1);
100     }
101 ENDCLASS(Gametype)
102
103 REGISTRY(Gametypes, 24)
104 #define Gametypes_from(i) _Gametypes_from(i, NULL)
105 REGISTER_REGISTRY(Gametypes)
106 REGISTRY_CHECK(Gametypes)
107 #define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
108
109 #define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
110
111 CLASS(Deathmatch, Gametype)
112     INIT(Deathmatch)
113     {
114         this.gametype_init(this, _("Deathmatch"),"dm","g_dm",false,true,"","timelimit=15 pointlimit=30 leadlimit=0",_("Score as many frags as you can"));
115     }
116     METHOD(Deathmatch, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
117     {
118         return true;
119     }
120     ATTRIB(Deathmatch, m_legacydefaults, string, "30 20 0");
121 ENDCLASS(Deathmatch)
122 REGISTER_GAMETYPE(DEATHMATCH, NEW(Deathmatch));
123
124 CLASS(LastManStanding, Gametype)
125     INIT(LastManStanding)
126     {
127         this.gametype_init(this, _("Last Man Standing"),"lms","g_lms",false,true,"","timelimit=20 lives=9 leadlimit=0",_("Survive and kill until the enemies have no lives left"));
128     }
129     METHOD(LastManStanding, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
130     {
131         return true;
132     }
133     METHOD(LastManStanding, 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))
134     {
135         TC(Gametype, this);
136         returns(menu, _("Lives:"),           3,   50,  1, "g_lms_lives_override",      string_null,                    string_null);
137     }
138     ATTRIB(LastManStanding, m_legacydefaults, string, "9 20 0");
139 ENDCLASS(LastManStanding)
140 REGISTER_GAMETYPE(LMS, NEW(LastManStanding));
141
142 #ifdef CSQC
143 void HUD_Mod_Race(vector pos, vector mySize);
144 #endif
145 CLASS(Race, Gametype)
146     INIT(Race)
147     {
148         this.gametype_init(this, _("Race"),"rc","g_race",false,true,"","timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0",_("Race against other players to the finish line"));
149     }
150     METHOD(Race, m_parse_mapinfo, bool(string k, string v))
151     {
152         if (!k) {
153             cvar_set("g_race_qualifying_timelimit", cvar_defstring("g_race_qualifying_timelimit"));
154             return true;
155         }
156         switch (k) {
157             case "qualifying_timelimit":
158                 cvar_set("g_race_qualifying_timelimit", v);
159                 return true;
160         }
161         return false;
162     }
163     METHOD(Race, m_generate_mapinfo, void(Gametype this, string v))
164     {
165         if(v == "trigger_race_checkpoint")
166             MapInfo_Map_supportedGametypes |= this.m_flags;
167     }
168     METHOD(Race, m_isTwoBaseMode, bool())
169     {
170         return true;
171     }
172     METHOD(Race, 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))
173     {
174         TC(Gametype, this);
175         returns(menu, _("Laps:"),            1,   25,  1, "g_race_laps_limit",         string_null,                    string_null);
176     }
177 #ifdef CSQC
178     ATTRIB(Race, m_modicons, void(vector pos, vector mySize), HUD_Mod_Race);
179 #endif
180     ATTRIB(Race, m_legacydefaults, string, "20 5 7 15 0");
181 ENDCLASS(Race)
182 REGISTER_GAMETYPE(RACE, NEW(Race));
183 #define g_race IS_GAMETYPE(RACE)
184
185 CLASS(RaceCTS, Gametype)
186     INIT(RaceCTS)
187     {
188         this.gametype_init(this, _("Race CTS"),"cts","g_cts",false,false,"cloaked","timelimit=20",_("Race for fastest time."));
189     }
190     METHOD(RaceCTS, m_generate_mapinfo, void(Gametype this, string v))
191     {
192         if(v == "target_startTimer")
193             MapInfo_Map_supportedGametypes |= this.m_flags;
194     }
195     METHOD(RaceCTS, m_setTeams, void(string sa))
196     {
197         // this is the skill of the map
198         // not parsed by anything yet
199         // for map databases
200         //  cvar_set("fraglimit", sa);
201     }
202     METHOD(RaceCTS, 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))
203     {
204         TC(Gametype, this);
205         returns(menu, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null);
206     }
207 #ifdef CSQC
208     ATTRIB(RaceCTS, m_modicons, void(vector pos, vector mySize), HUD_Mod_Race);
209 #endif
210     ATTRIB(RaceCTS, m_legacydefaults, string, "20 0 0");
211 ENDCLASS(RaceCTS)
212 REGISTER_GAMETYPE(CTS, NEW(RaceCTS));
213 #define g_cts IS_GAMETYPE(CTS)
214
215 CLASS(TeamDeathmatch, Gametype)
216     INIT(TeamDeathmatch)
217     {
218         this.gametype_init(this, _("Team Deathmatch"),"tdm","g_tdm",true,true,"","timelimit=15 pointlimit=50 teams=2 leadlimit=0",_("Help your team score the most frags against the enemy team"));
219     }
220     METHOD(TeamDeathmatch, m_parse_mapinfo, bool(string k, string v))
221     {
222         if (!k) {
223             cvar_set("g_tdm_teams", cvar_defstring("g_tdm_teams"));
224             return true;
225         }
226         switch (k) {
227             case "teams":
228                 cvar_set("g_tdm_teams", v);
229                 return true;
230         }
231         return false;
232     }
233     METHOD(TeamDeathmatch, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
234     {
235         if(spawnpoints >= 8 && diameter > 4096)
236             return true;
237         return false;
238     }
239     METHOD(TeamDeathmatch, m_isForcedSupported, bool(Gametype this))
240     {
241         if(cvar("g_tdm_on_dm_maps"))
242         {
243             // if this is set, all DM maps support TDM too
244             if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH.m_flags))
245                 return true; // TODO: references another gametype (alternatively, we could check which gamemodes are always enabled and append this if any are supported)
246         }
247         return false;
248     }
249     METHOD(TeamDeathmatch, m_setTeams, void(string sa))
250     {
251         cvar_set("g_tdm_teams", sa);
252     }
253     METHOD(TeamDeathmatch, 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))
254     {
255         TC(Gametype, this);
256         returns(menu, _("Point limit:"),     5,  100,  5, "g_tdm_point_limit",         "g_tdm_teams_override",         _("The amount of points needed before the match will end"));
257     }
258     ATTRIB(TeamDeathmatch, m_legacydefaults, string, "50 20 2 0");
259 ENDCLASS(TeamDeathmatch)
260 REGISTER_GAMETYPE(TEAM_DEATHMATCH, NEW(TeamDeathmatch));
261 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)
262
263 #ifdef CSQC
264 void HUD_Mod_CTF(vector pos, vector mySize);
265 void HUD_Mod_CTF_Reset();
266 #endif
267 CLASS(CaptureTheFlag, Gametype)
268     INIT(CaptureTheFlag)
269     {
270         this.gametype_init(this, _("Capture the Flag"),"ctf","g_ctf",true,true,"","timelimit=20 caplimit=10 leadlimit=6",_("Find and bring the enemy flag to your base to capture it, defend your base from the other team"));
271     }
272     METHOD(CaptureTheFlag, m_generate_mapinfo, void(Gametype this, string v))
273     {
274         if(v == "item_flag_team2" || v == "team_CTF_blueflag")
275             MapInfo_Map_supportedGametypes |= this.m_flags;
276     }
277     METHOD(CaptureTheFlag, m_isTwoBaseMode, bool())
278     {
279         return true;
280     }
281     METHOD(CaptureTheFlag, m_setTeams, void(string sa))
282     {
283         cvar_set("fraglimit", sa);
284     }
285     METHOD(CaptureTheFlag, 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))
286     {
287         TC(Gametype, this);
288         returns(menu, _("Capture limit:"),   1,   20,  1, "capturelimit_override",     string_null,                    _("The amount of captures needed before the match will end"));
289     }
290 #ifdef CSQC
291     ATTRIB(CaptureTheFlag, m_modicons, void(vector pos, vector mySize), HUD_Mod_CTF);
292     ATTRIB(CaptureTheFlag, m_modicons_reset, void(), HUD_Mod_CTF_Reset);
293 #endif
294     ATTRIB(CaptureTheFlag, m_legacydefaults, string, "300 20 10 0");
295 ENDCLASS(CaptureTheFlag)
296 REGISTER_GAMETYPE(CTF, NEW(CaptureTheFlag));
297 #define g_ctf IS_GAMETYPE(CTF)
298
299 #ifdef CSQC
300 void HUD_Mod_CA(vector pos, vector mySize);
301 #endif
302 CLASS(ClanArena, Gametype)
303     INIT(ClanArena)
304     {
305         this.gametype_init(this, _("Clan Arena"),"ca","g_ca",true,true,"","timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill all enemy teammates to win the round"));
306     }
307     METHOD(ClanArena, m_parse_mapinfo, bool(string k, string v))
308     {
309         if (!k) {
310             cvar_set("g_ca_teams", cvar_defstring("g_ca_teams"));
311             return true;
312         }
313         switch (k) {
314             case "teams":
315                 cvar_set("g_ca_teams", v);
316                 return true;
317         }
318         return false;
319     }
320     METHOD(ClanArena, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
321     {
322         if(spawnpoints >= 8 && diameter > 4096)
323             return true;
324         return false;
325     }
326     METHOD(ClanArena, m_setTeams, void(string sa))
327     {
328         cvar_set("g_ca_teams", sa);
329     }
330     METHOD(ClanArena, 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))
331     {
332         TC(Gametype, this);
333         returns(menu, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        "g_ca_teams_override",          _("The amount of frags needed before the match will end"));
334     }
335 #ifdef CSQC
336     ATTRIB(ClanArena, m_modicons, void(vector pos, vector mySize), HUD_Mod_CA);
337 #endif
338     ATTRIB(ClanArena, m_legacydefaults, string, "10 20 0");
339 ENDCLASS(ClanArena)
340 REGISTER_GAMETYPE(CA, NEW(ClanArena));
341 #define g_ca IS_GAMETYPE(CA)
342
343 #ifdef CSQC
344 void HUD_Mod_Dom(vector pos, vector mySize);
345 #endif
346 CLASS(Domination, Gametype)
347     INIT(Domination)
348     {
349         this.gametype_init(this, _("Domination"),"dom","g_domination",true,true,"","timelimit=20 pointlimit=200 teams=2 leadlimit=0",_("Capture and defend all the control points to win"));
350     }
351     METHOD(Domination, m_parse_mapinfo, bool(string k, string v))
352     {
353         if (!k) {
354             cvar_set("g_domination_default_teams", cvar_defstring("g_domination_default_teams"));
355             return true;
356         }
357         switch (k) {
358             case "teams":
359                 cvar_set("g_domination_default_teams", v);
360                 return true;
361         }
362         return false;
363     }
364     METHOD(Domination, m_generate_mapinfo, void(Gametype this, string v))
365     {
366         if(v == "dom_controlpoint")
367             MapInfo_Map_supportedGametypes |= this.m_flags;
368     }
369     METHOD(Domination, 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))
370     {
371         TC(Gametype, this);
372         returns(menu, _("Point limit:"),    50,  500, 10, "g_domination_point_limit",  "g_domination_teams_override",  _("The amount of points needed before the match will end"));
373     }
374 #ifdef CSQC
375     ATTRIB(Domination, m_modicons, void(vector pos, vector mySize), HUD_Mod_Dom);
376 #endif
377     ATTRIB(Domination, m_legacydefaults, string, "200 20 0");
378 ENDCLASS(Domination)
379 REGISTER_GAMETYPE(DOMINATION, NEW(Domination));
380
381 #ifdef CSQC
382 void HUD_Mod_KH(vector pos, vector mySize);
383 #endif
384 CLASS(KeyHunt, Gametype)
385     INIT(KeyHunt)
386     {
387         this.gametype_init(this, _("Key Hunt"),"kh","g_keyhunt",true,true,"","timelimit=20 pointlimit=1000 teams=3 leadlimit=0",_("Gather all the keys to win the round"));
388     }
389     METHOD(KeyHunt, m_parse_mapinfo, bool(string k, string v))
390     {
391         if (!k) {
392             cvar_set("g_keyhunt_teams", cvar_defstring("g_keyhunt_teams"));
393             return true;
394         }
395         switch (k) {
396             case "teams":
397                 cvar_set("g_keyhunt_teams", v);
398                 return true;
399         }
400         return false;
401     }
402     METHOD(KeyHunt, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
403     {
404         if(spawnpoints >= 12 && diameter > 5120)
405             return true;
406         return false;
407     }
408     METHOD(KeyHunt, m_setTeams, void(string sa))
409     {
410         cvar_set("g_keyhunt_teams", sa);
411     }
412     METHOD(KeyHunt, 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))
413     {
414         TC(Gametype, this);
415         returns(menu, _("Point limit:"),   200, 1500, 50, "g_keyhunt_point_limit",     "g_keyhunt_teams_override",     _("The amount of points needed before the match will end"));
416     }
417 #ifdef CSQC
418     ATTRIB(KeyHunt, m_modicons, void(vector pos, vector mySize), HUD_Mod_KH);
419 #endif
420     ATTRIB(KeyHunt, m_legacydefaults, string, "1000 20 3 0");
421 ENDCLASS(KeyHunt)
422 REGISTER_GAMETYPE(KEYHUNT, NEW(KeyHunt));
423
424 CLASS(Assault, Gametype)
425     INIT(Assault)
426     {
427         this.gametype_init(this, _("Assault"),"as","g_assault",true,false,"","timelimit=20",_("Destroy obstacles to find and destroy the enemy power core before time runs out"));
428     }
429     METHOD(Assault, m_generate_mapinfo, void(Gametype this, string v))
430     {
431         if(v == "target_assault_roundend")
432             MapInfo_Map_supportedGametypes |= this.m_flags;
433     }
434     METHOD(Assault, m_isTwoBaseMode, bool())
435     {
436         return true;
437     }
438     METHOD(Assault, 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))
439     {
440         TC(Gametype, this);
441         returns(menu, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null);
442     }
443     ATTRIB(Assault, m_legacydefaults, string, "20 0");
444 ENDCLASS(Assault)
445 REGISTER_GAMETYPE(ASSAULT, NEW(Assault));
446 #define g_assault IS_GAMETYPE(ASSAULT)
447
448 CLASS(Onslaught, Gametype)
449     INIT(Onslaught)
450     {
451         this.gametype_init(this, _("Onslaught"),"ons","g_onslaught",true,false,"","pointlimit=1 timelimit=20",_("Capture control points to reach and destroy the enemy generator"));
452     }
453     METHOD(Onslaught, m_generate_mapinfo, void(Gametype this, string v))
454     {
455         if(v == "onslaught_generator")
456             MapInfo_Map_supportedGametypes |= this.m_flags;
457     }
458     METHOD(Onslaught, 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))
459     {
460         TC(Gametype, this);
461         returns(menu, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null);
462     }
463     ATTRIB(Onslaught, m_legacydefaults, string, "20 0");
464 ENDCLASS(Onslaught)
465 REGISTER_GAMETYPE(ONSLAUGHT, NEW(Onslaught));
466
467 #ifdef CSQC
468 void HUD_Mod_NexBall(vector pos, vector mySize);
469 #endif
470 CLASS(NexBall, Gametype)
471     INIT(NexBall)
472     {
473         this.gametype_init(this, _("Nexball"),"nb","g_nexball",true,true,"","timelimit=20 pointlimit=5 leadlimit=0",_("Shoot and kick the ball into the enemies goal, keep your goal clean"));
474     }
475     METHOD(NexBall, m_generate_mapinfo, void(Gametype this, string v))
476     {
477         if(substring(v, 0, 8) == "nexball_" || substring(v, 0, 4) == "ball")
478             MapInfo_Map_supportedGametypes |= this.m_flags;
479     }
480     METHOD(NexBall, m_isTwoBaseMode, bool())
481     {
482         return true;
483     }
484     METHOD(NexBall, 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))
485     {
486         TC(Gametype, this);
487         returns(menu, _("Goals:"),           1,   50,  1, "g_nexball_goallimit",       string_null,                    _("The amount of goals needed before the match will end"));
488     }
489 #ifdef CSQC
490     ATTRIB(NexBall, m_modicons, void(vector pos, vector mySize), HUD_Mod_NexBall);
491 #endif
492     ATTRIB(NexBall, m_legacydefaults, string, "5 20 0");
493 ENDCLASS(NexBall)
494 REGISTER_GAMETYPE(NEXBALL, NEW(NexBall));
495 #define g_nexball IS_GAMETYPE(NEXBALL)
496
497 CLASS(FreezeTag, Gametype)
498     INIT(FreezeTag)
499     {
500         this.gametype_init(this, _("Freeze Tag"),"ft","g_freezetag",true,true,"","timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill enemies to freeze them, stand next to frozen teammates to revive them; freeze all enemies to win"));
501     }
502     METHOD(FreezeTag, m_parse_mapinfo, bool(string k, string v))
503     {
504         if (!k) {
505             cvar_set("g_freezetag_teams", cvar_defstring("g_freezetag_teams"));
506             return true;
507         }
508         switch (k) {
509             case "teams":
510                 cvar_set("g_freezetag_teams", v);
511                 return true;
512         }
513         return false;
514     }
515     METHOD(FreezeTag, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
516     {
517         if(spawnpoints >= 8 && diameter > 4096)
518             return true;
519         return false;
520     }
521     METHOD(FreezeTag, m_setTeams, void(string sa))
522     {
523         cvar_set("g_freezetag_teams", sa);
524     }
525     METHOD(FreezeTag, 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))
526     {
527         TC(Gametype, this);
528         returns(menu, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        "g_freezetag_teams_override",   _("The amount of frags needed before the match will end"));
529     }
530 #ifdef CSQC
531     ATTRIB(FreezeTag, m_modicons, void(vector pos, vector mySize), HUD_Mod_CA);
532 #endif
533     ATTRIB(FreezeTag, m_legacydefaults, string, "10 20 0");
534 ENDCLASS(FreezeTag)
535 REGISTER_GAMETYPE(FREEZETAG, NEW(FreezeTag));
536 #define g_freezetag IS_GAMETYPE(FREEZETAG)
537
538 #ifdef CSQC
539 void HUD_Mod_Keepaway(vector pos, vector mySize);
540 #endif
541 CLASS(Keepaway, Gametype)
542     INIT(Keepaway)
543     {
544         this.gametype_init(this, _("Keepaway"),"ka","g_keepaway",false,true,"","timelimit=20 pointlimit=30",_("Hold the ball to get points for kills"));
545     }
546     METHOD(Keepaway, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
547     {
548         return true;
549     }
550 #ifdef CSQC
551     ATTRIB(Keepaway, m_modicons, void(vector pos, vector mySize), HUD_Mod_Keepaway);
552 #endif
553 ENDCLASS(Keepaway)
554 REGISTER_GAMETYPE(KEEPAWAY, NEW(Keepaway));
555
556 CLASS(Invasion, Gametype)
557     INIT(Invasion)
558     {
559         this.gametype_init(this, _("Invasion"),"inv","g_invasion",false,true,"","pointlimit=50 teams=0 type=0",_("Survive against waves of monsters"));
560     }
561     METHOD(Invasion, m_parse_mapinfo, bool(string k, string v))
562     {
563         switch (k) {
564             case "teams":
565                 cvar_set("g_invasion_teams", v);
566                 return true;
567             case "type":
568                 cvar_set("g_invasion_type", v);
569                 return true;
570         }
571         return false;
572     }
573     METHOD(Invasion, m_generate_mapinfo, void(Gametype this, string v))
574     {
575         if(v == "invasion_spawnpoint")
576             MapInfo_Map_supportedGametypes |= this.m_flags;
577     }
578     METHOD(Invasion, 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))
579     {
580         TC(Gametype, this);
581         returns(menu, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null);
582     }
583 ENDCLASS(Invasion)
584 REGISTER_GAMETYPE(INVASION, NEW(Invasion));
585
586 CLASS(Duel, Gametype)
587     INIT(Duel)
588     {
589         this.gametype_init(this, _("Duel"),"duel","g_duel",false,true,"","timelimit=10 pointlimit=0 leadlimit=0",_("Fight in a one versus one arena battle to decide the winner"));
590     }
591     METHOD(Duel, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
592     {
593         return (diameter < 16384);
594     }
595     METHOD(Duel, m_isForcedSupported, bool(Gametype this))
596     {
597         // force all DM maps to work in duel?!
598         // TODO: we should really check the size of maps, some DM maps do not work for duel!
599         if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH.m_flags))
600             return true;
601         return false;
602     }
603 ENDCLASS(Duel)
604 REGISTER_GAMETYPE(DUEL, NEW(Duel));
605 #define g_duel IS_GAMETYPE(DUEL)
606
607 const int MAPINFO_FEATURE_WEAPONS       = 1; // not defined for instagib-only maps
608 const int MAPINFO_FEATURE_VEHICLES      = 2;
609 const int MAPINFO_FEATURE_TURRETS       = 4;
610 const int MAPINFO_FEATURE_MONSTERS      = 8;
611
612 const int MAPINFO_FLAG_HIDDEN           = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually
613 const int MAPINFO_FLAG_FORBIDDEN        = 2; // don't even allow the map by a cvar setting that allows hidden maps
614 const int MAPINFO_FLAG_FRUSTRATING      = 4; // this map is near impossible to play, enable at your own risk
615 const int MAPINFO_FLAG_NOAUTOMAPLIST    = 8; // do not include when automatically building maplist (counts as hidden for maplist building purposes)
616
617 float MapInfo_count;
618
619 // load MapInfo_count; generate mapinfo for maps that miss them, and clear the
620 // cache; you need to call MapInfo_FilterGametype afterwards!
621 void MapInfo_Enumerate();
622
623 // filter the info by game type mask (updates MapInfo_count)
624 float MapInfo_progress;
625 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)
626 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)
627 void MapInfo_FilterString(string sf); // filter _MapInfo_filtered (created by MapInfo_FilterGametype) with keyword
628 int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
629 Gametype MapInfo_CurrentGametype(); // retrieves current gametype from cvars
630 int MapInfo_ForbiddenFlags(); // retrieves current flags from cvars
631 int MapInfo_RequiredFlags(); // retrieves current flags from cvars
632
633 // load info about the i-th map into the MapInfo_Map_* globals
634 float MapInfo_Get_ByID(float i); // 1 on success, 0 on failure
635 string MapInfo_BSPName_ByID(float i);
636
637 // load info about a map by name into the MapInfo_Map_* globals
638 int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet); // 1 on success, 0 on failure, 2 if it autogenerated a mapinfo file
639
640 // look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
641 string MapInfo_FindName_match; // the name of the map that was found
642 float MapInfo_FindName_firstResult; // -1 if none were found, index of first one if not unique but found (FindName then returns -1)
643 float MapInfo_FindName(string s);
644 string MapInfo_FixName(string s);
645
646 // play a map
647 float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
648 void MapInfo_LoadMap(string s, float reinit);
649
650 // list all maps for the current game type
651 string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden);
652 // list all allowed maps (for any game type)
653 string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
654
655 // gets a gametype from a string
656 string _MapInfo_GetDefaultEx(Gametype t);
657 float _MapInfo_GetTeamPlayBool(Gametype t);
658 Gametype MapInfo_Type_FromString(string t);
659 string MapInfo_Type_Description(Gametype t);
660 string MapInfo_Type_ToString(Gametype t);
661 string MapInfo_Type_ToText(Gametype t);
662 void MapInfo_SwitchGameType(Gametype t);
663
664 // to be called from worldspawn to set up cvars
665 void MapInfo_LoadMapSettings(string s);
666 Gametype MapInfo_LoadedGametype; // game type that was active during map load
667
668 void MapInfo_Cache_Destroy(); // disable caching
669 void MapInfo_Cache_Create(); // enable caching
670 void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled
671
672 void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame
673
674 void MapInfo_Shutdown(); // call this in the shutdown handler
675
676 #define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
677 #define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* -r_water +*"