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