]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapinfo.qh
remove lots of game type listings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapinfo.qh
1 var float MAPINFO_TYPE_ALL = 0;
2 entity MapInfo_Type_first;
3 entity MapInfo_Type_last;
4
5 #define REGISTER_GAMETYPE_LONG(name,sname,NAME,g_name,MAPINFO_TYPE_NAME,MapInfo_Type_name) \
6         var float MAPINFO_TYPE_NAME; \
7         var entity MapInfo_Type_name; \
8         void RegisterGametypes_##name() \
9         { \
10                 MAPINFO_TYPE_NAME = MAPINFO_TYPE_ALL + 1; \
11                 MAPINFO_TYPE_ALL |= MAPINFO_TYPE_NAME; \
12                 MapInfo_Type_name = spawn(); \
13                 MapInfo_Type_name.weapons = MAPINFO_TYPE_NAME; \
14                 MapInfo_Type_name.netname = #name; \
15                 MapInfo_Type_name.message = #NAME; \
16                 MapInfo_Type_name.mdl = #g_name; \
17                 MapInfo_Type_name.model2 = #sname; \
18                 if(!MapInfo_Type_first) \
19                         MapInfo_Type_first = MapInfo_Type_name; \
20                 if(MapInfo_Type_last) \
21                         MapInfo_Type_last.enemy = MapInfo_Type_name; \
22                 MapInfo_Type_last = MapInfo_Type_name; \
23         } \
24         ACCUMULATE_FUNCTION(RegisterGametypes, RegisterGametypes_##name)
25
26 #define REGISTER_GAMETYPE(name,sname,NAME) \
27         REGISTER_GAMETYPE_LONG(name,sname,NAME,g_##name,MAPINFO_TYPE_##NAME,MapInfo_Type_##name)
28
29 #define IS_GAMETYPE(NAME) \
30         (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
31
32 REGISTER_GAMETYPE(dm,dm,DEATHMATCH)
33 #define g_dm IS_GAMETYPE(DEATHMATCH)
34
35 REGISTER_GAMETYPE(lms,lms,LMS)
36 #define g_lms IS_GAMETYPE(LMS)
37
38 REGISTER_GAMETYPE(arena,arena,ARENA)
39 #define g_arena IS_GAMETYPE(ARENA)
40
41 REGISTER_GAMETYPE(runematch,rune,RUNEMATCH)
42 #define g_runematch IS_GAMETYPE(RUNEMATCH)
43
44 REGISTER_GAMETYPE(race,rc,RACE)
45 #define g_race IS_GAMETYPE(RACE)
46
47 REGISTER_GAMETYPE(cts,cts,CTS)
48 #define g_cts IS_GAMETYPE(CTS)
49
50 REGISTER_GAMETYPE(tdm,tdm,TEAM_DEATHMATCH)
51 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)
52
53 REGISTER_GAMETYPE(ctf,ctf,CTF)
54 #define g_ctf IS_GAMETYPE(CTF)
55
56 REGISTER_GAMETYPE(ca,ca,CA)
57 #define g_ca IS_GAMETYPE(CA)
58
59 REGISTER_GAMETYPE(domination,dom,DOMINATION)
60 #define g_domination IS_GAMETYPE(DOMINATION)
61
62 REGISTER_GAMETYPE(keyhunt,kh,KEYHUNT)
63 #define g_keyhunt IS_GAMETYPE(KEYHUNT)
64
65 REGISTER_GAMETYPE(assault,as,ASSAULT)
66 #define g_assault IS_GAMETYPE(ASSAULT)
67
68 REGISTER_GAMETYPE(onslaught,ons,ONSLAUGHT)
69 #define g_onslaught IS_GAMETYPE(ONSLAUGHT)
70
71 REGISTER_GAMETYPE(nexball,nexball,NEXBALL)
72 #define g_nexball IS_GAMETYPE(NEXBALL)
73
74 REGISTER_GAMETYPE(freezetag,freezetag,FREEZETAG)
75 #define g_freezetag IS_GAMETYPE(FREEZETAG)
76
77 REGISTER_GAMETYPE(keepaway,keepaway,KEEPAWAY)
78 #define g_keepaway IS_GAMETYPE(KEEPAWAY)
79
80 float MAPINFO_FEATURE_WEAPONS       = 1; // not defined for minstagib-only maps
81 float MAPINFO_FEATURE_VEHICLES      = 2;
82 float MAPINFO_FEATURE_TURRETS       = 4;
83
84 float MAPINFO_FLAG_HIDDEN           = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually
85 float MAPINFO_FLAG_FORBIDDEN        = 2; // don't even allow the map by a cvar setting that allows hidden maps
86 float MAPINFO_FLAG_FRUSTRATING      = 4; // this map is near impossible to play, enable at your own risk
87
88 float MapInfo_count;
89
90 // info about a map that MapInfo loads
91 string MapInfo_Map_bspname;
92 string MapInfo_Map_title;
93 string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant
94 string MapInfo_Map_description;
95 string MapInfo_Map_author;
96 string MapInfo_Map_clientstuff; // not in cache, only for map load
97 string MapInfo_Map_fog; // not in cache, only for map load
98 float MapInfo_Map_supportedGametypes;
99 float MapInfo_Map_supportedFeatures;
100 float MapInfo_Map_flags;
101 vector MapInfo_Map_mins; // these are '0 0 0' if not supported!
102 vector MapInfo_Map_maxs; // these are '0 0 0' if not specified!
103
104 // load MapInfo_count; generate mapinfo for maps that miss them, and clear the
105 // cache; you need to call MapInfo_FilterGametype afterwards!
106 void MapInfo_Enumerate();
107
108 // filter the info by game type mask (updates MapInfo_count)
109 float MapInfo_progress;
110 float MapInfo_FilterGametype(float gametype, 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)
111 float MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
112 float MapInfo_CurrentGametype(); // retrieves current gametype from cvars
113 float MapInfo_ForbiddenFlags(); // retrieves current flags from cvars
114 float MapInfo_RequiredFlags(); // retrieves current flags from cvars
115
116 // load info about the i-th map into the MapInfo_Map_* globals
117 float MapInfo_Get_ByID(float i); // 1 on success, 0 on failure
118 string MapInfo_BSPName_ByID(float i);
119
120 // load info about a map by name into the MapInfo_Map_* globals
121 float MapInfo_Get_ByName(string s, float allowGenerate, float gametypeToSet); // 1 on success, 0 on failure, 2 if it autogenerated a mapinfo file
122
123 // look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
124 string MapInfo_FindName_match; // the name of the map that was found
125 float MapInfo_FindName_firstResult; // -1 if none were found, index of first one if not unique but found (FindName then returns -1)
126 float MapInfo_FindName(string s);
127 string MapInfo_FixName(string s);
128
129 // play a map
130 float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
131 void MapInfo_LoadMap(string s, float reinit);
132
133 // list all maps for the current game type
134 string MapInfo_ListAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
135 // list all allowed maps (for any game type)
136 string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
137
138 // gets a gametype from a string
139 float MapInfo_Type_FromString(string t);
140 string MapInfo_Type_ToString(float t);
141 string MapInfo_GetGameTypeCvar(float t);
142 void MapInfo_SwitchGameType(float t);
143
144 // to be called from worldspawn to set up cvars
145 void MapInfo_LoadMapSettings(string s);
146 float MapInfo_LoadedGametype; // game type that was active during map load
147
148 void MapInfo_Cache_Destroy(); // disable caching
149 void MapInfo_Cache_Create(); // enable caching
150 void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled
151
152 void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame
153
154 void MapInfo_Shutdown(); // call this in the shutdown handler
155
156 #define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
157 #define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* +*"