Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
mapinfo.qh
Go to the documentation of this file.
1#pragma once
2
3#include "util.qh"
4
5// info about a map that MapInfo loads
8string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant
11string MapInfo_Map_clientstuff; // not in cache, only for map load
12string MapInfo_Map_fog; // not in cache, only for map load
16vector MapInfo_Map_mins; // these are '0 0 0' if not supported!
17vector MapInfo_Map_maxs; // these are '0 0 0' if not specified!
18
19const int GAMETYPE_FLAG_TEAMPLAY = BIT(0); // teamplay based
20const int GAMETYPE_FLAG_USEPOINTS = BIT(1); // gametype has point-based scoring
21const int GAMETYPE_FLAG_PREFERRED = BIT(2); // preferred (when available) in random selections
22const int GAMETYPE_FLAG_PRIORITY = BIT(3); // priority selection when preferred gametype isn't available in random selections
23const int GAMETYPE_FLAG_HIDELIMITS = BIT(4); // don't display a score limit needed for winning the match in the scoreboard
24const int GAMETYPE_FLAG_WEAPONARENA = BIT(5); // gametype has a forced weapon arena, weapon arena mutators should disable themselves when this is set
25const int GAMETYPE_FLAG_1V1 = BIT(6); // 1v1 gameplay
26
29
30// must be defined before the registry
32
34 ATTRIB(Gametype, m_id, int, 0);
40 ATTRIB(Gametype, mdl, string);
61#ifdef CSQC
62 ATTRIB(Gametype, m_modicons, void(vector pos, vector mySize));
63 ATTRIB(Gametype, m_modicons_reset, void());
64 ATTRIB(Gametype, m_modicons_export, void(int fh));
65#endif
66
69
70 ATTRIB(Gametype, m_mutators, string);
71 METHOD(Gametype, m_parse_mapinfo, bool(string k, string v))
72 {
73 return false;
74 }
76 {
77 TC(Gametype, this);
78 }
80 {
81 return false;
82 }
83 METHOD(Gametype, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
84 {
85 return false;
86 }
88 {
89 return false;
90 }
91 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))
92 {
93 TC(Gametype, this);
94 returns(menu, _("Frag limit:"), 5, 100, 5, "fraglimit_override", string_null, _("The amount of frags needed before the match will end"));
95 }
96
97#ifdef MENUQC
98 /* gametype guide description
99 * this description is used in the guide, the description stored in .m_description is shorter and used for things like the mapvoting dialog
100 */
102 {
103 TC(Gametype, this);
104 return SUPER(Gametype).describe(this);
105 }
106
107 METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns))
108 {
109 TC(Gametype, this);
110 if (this.mdl == "")
111 returns(this.message, "");
112 else
113 returns(this.message, icon_path_from_menuskin(strcat("gametype_", this.mdl)));
114 }
115#endif
116
117 METHOD(Gametype, gametype_init, void(Gametype this, string hname, string sname, string g_name, int gflags, string mutators, string defaults, string gdescription))
118 {
119 this.netname = g_name;
120 this.mdl = sname;
121 this.message = hname;
122 this.team = (gflags & GAMETYPE_FLAG_TEAMPLAY);
123 this.m_mutators = cons(sname, mutators);
124 this.model2 = defaults;
125 this.m_description = gdescription;
126 this.frags = (gflags & GAMETYPE_FLAG_USEPOINTS);
127 this.m_priority = ((gflags & GAMETYPE_FLAG_PREFERRED) ? 2 : ((gflags & GAMETYPE_FLAG_PRIORITY) ? 1 : 0));
128 this.m_hidelimits = (gflags & GAMETYPE_FLAG_HIDELIMITS);
129 this.m_weaponarena = (gflags & GAMETYPE_FLAG_WEAPONARENA);
130 this.m_1v1 = (gflags & GAMETYPE_FLAG_1V1);
131 }
133
134REGISTRY(Gametypes, 32)
135REGISTER_REGISTRY(Gametypes)
136REGISTRY_SORT(Gametypes)
137REGISTRY_CHECK(Gametypes)
138
139REGISTRY_DEFINE_GET(Gametypes, NULL)
140STATIC_INIT(Gametypes_renumber)
141{
142 FOREACH(Gametypes, true,
143 {
144 it.m_id = i;
145 vector set = it.gametype_flags = _GametypeFlags_FromGametype(it.m_id);
146 MAPINFO_TYPE_ALL |= set;
147 });
148}
149#define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
150
151#ifndef CSQC
152// NOTE: ISGAMETYPE in csqc (temporary hack)
153#define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
154#endif
155
156const int MAPINFO_FEATURE_WEAPONS = 1; // not defined for instagib-only maps
160
161const int MAPINFO_FLAG_HIDDEN = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually
162const int MAPINFO_FLAG_FORBIDDEN = 2; // don't even allow the map by a cvar setting that allows hidden maps
163const int MAPINFO_FLAG_FRUSTRATING = 4; // this map is near impossible to play, enable at your own risk
164const int MAPINFO_FLAG_DONOTWANT = 8; // do not include in GUI voting screen or select in GotoNextMap()/GetNextMap(), unless added with `suggestmap` or required as a fallback
165
167
168// load MapInfo_count; generate mapinfo for maps that miss them, and clear the
169// cache; you need to call MapInfo_FilterGametype afterwards!
170void MapInfo_Enumerate();
171
172// filter the info by gametype mask (updates MapInfo_count)
174float 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)
175float _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)
176void MapInfo_FilterString(string sf); // filter _MapInfo_filtered (created by MapInfo_FilterGametype) with keyword
177int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
178Gametype MapInfo_CurrentGametype(); // retrieves current gametype from cvars
179int MapInfo_ForbiddenFlags(); // retrieves current flags from cvars
180int MapInfo_RequiredFlags(); // retrieves current flags from cvars
181
182// load info about the i-th map into the MapInfo_Map_* globals
183bool MapInfo_Get_ByID(int i); // 1 on success, 0 on failure
184string MapInfo_BSPName_ByID(float i);
185
186// load info about a map by name into the MapInfo_Map_* globals
187int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet); // 1 on success, 0 on failure, 2 if it autogenerated a mapinfo file
188
189// load map-specific player limits
192bool MapReadSizes(string map);
193
194// look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
195string MapInfo_FindName_match; // the name of the map that was found
196float MapInfo_FindName_firstResult; // -1 if none were found, index of first one if not unique but found (FindName then returns -1)
197float MapInfo_FindName(string s);
198string MapInfo_FixName(string s);
199
200// play a map
201float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
202void MapInfo_LoadMap(string s, float reinit);
203
204// list all maps for the current gametype
205string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden);
206// list all allowed maps (for any gametype)
207string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
208
209// gets a gametype from a string
212Gametype MapInfo_Type_FromString(string t, bool dowarn, bool is_q3compat);
217
218// to be called from worldspawn to set up cvars
219void MapInfo_LoadMapSettings(string s);
220Gametype MapInfo_LoadedGametype; // gametype that was active during map load
221
222void MapInfo_Cache_Destroy(); // disable caching
223void MapInfo_Cache_Create(); // enable caching
224void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled
225
226bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gametype pGametypeToSet, bool isdefi, bool isgenerator);
227
228string _MapInfo_FindArenaFile(string pFilename, string extension);
229
230void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse);
231
232void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame
233
234void MapInfo_Shutdown(); // call this in the shutdown handler
235
236#define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
237#define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* +*"
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
ATTRIB(Gametype, netname, string)
gametype name as in cvar (with g_ prefix)
int m_id
Definition mapinfo.qh:34
string m_legacydefaults
DO NOT USE, this is compatibility for legacy maps!
Definition mapinfo.qh:68
virtual void m_isTwoBaseMode()
Definition mapinfo.qh:79
virtual void display()
Definition mapinfo.qh:107
ATTRIB(Gametype, m_modicons_export, void(int fh))
bool m_hidelimits
should this gametype display a score limit in the scoreboard?
Definition mapinfo.qh:50
virtual void m_generate_mapinfo()
Definition mapinfo.qh:75
vector m_color
color
Definition mapinfo.qh:44
virtual void m_isAlwaysSupported()
Definition mapinfo.qh:83
virtual void m_parse_mapinfo()
Definition mapinfo.qh:71
virtual void m_configuremenu()
Definition mapinfo.qh:91
bool m_1v1
1v1 gameplay?
Definition mapinfo.qh:54
ATTRIB(Gametype, m_modicons_reset, void())
int items
gametype ID
Definition mapinfo.qh:36
bool m_weaponarena
does this gametype enforce its own weapon arena?
Definition mapinfo.qh:52
bool team
does this gametype support teamplay?
Definition mapinfo.qh:46
int m_priority
gametype priority in random selections
Definition mapinfo.qh:60
ATTRIB(Gametype, m_modicons, void(vector pos, vector mySize))
ATTRIB(Gametype, m_mutators, string)
virtual void describe()
Definition mapinfo.qh:101
bool frags
does this gametype use a point limit?
Definition mapinfo.qh:48
virtual void gametype_init()
Definition mapinfo.qh:117
virtual void m_isForcedSupported()
Definition mapinfo.qh:87
string netname
Definition powerups.qc:20
string message
Definition powerups.qc:19
string mdl
Definition item.qh:89
#define true
Definition csprogsdefs.qh:5
#define false
Definition csprogsdefs.qh:6
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define TC(T, sym)
Definition _all.inc:82
const int MAPINFO_FEATURE_MONSTERS
Definition mapinfo.qh:159
vector MapInfo_Map_supportedGametypes
Definition mapinfo.qh:13
vector MapInfo_Map_maxs
Definition mapinfo.qh:17
const int GAMETYPE_FLAG_PRIORITY
Definition mapinfo.qh:22
void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
Definition mapinfo.qc:667
bool MapReadSizes(string map)
Definition mapinfo.qc:1409
vector MAPINFO_TYPE_ALL
Definition mapinfo.qh:27
vector MapInfo_Map_mins
Definition mapinfo.qh:16
float MapInfo_CheckMap(string s)
Definition mapinfo.qc:1510
int map_minplayers
Definition mapinfo.qh:190
const int GAMETYPE_FLAG_USEPOINTS
Definition mapinfo.qh:20
string MapInfo_FindName_match
Definition mapinfo.qh:195
float MapInfo_FindName(string s)
Definition mapinfo.qc:1426
bool MapInfo_Get_ByID(int i)
Definition mapinfo.qc:275
string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden)
Definition mapinfo.qc:1542
void MapInfo_Shutdown()
Definition mapinfo.qc:1651
int MapInfo_RequiredFlags()
Definition mapinfo.qc:1679
float MapInfo_FindName_firstResult
Definition mapinfo.qh:196
string MapInfo_Type_ToString(Gametype t)
Definition mapinfo.qc:656
string MapInfo_BSPName_ByID(float i)
Definition mapinfo.qc:250
Gametype MapInfo_LoadedGametype
Definition mapinfo.qh:220
int map_maxplayers
Definition mapinfo.qh:191
void MapInfo_FilterString(string sf)
Definition mapinfo.qc:213
float MapInfo_count
Definition mapinfo.qh:166
void MapInfo_LoadMap(string s, float reinit)
Definition mapinfo.qc:1523
const int MAPINFO_FLAG_FORBIDDEN
Definition mapinfo.qh:162
vector _GametypeFlags_FromGametype(int a)
Definition mapinfo.qc:20
string MapInfo_Map_bspname
Definition mapinfo.qh:6
string MapInfo_Type_Description(Gametype t)
Definition mapinfo.qc:651
string MapInfo_Map_fog
Definition mapinfo.qh:12
float MapInfo_FilterGametype(Gametype gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
int MapInfo_Map_supportedFeatures
Definition mapinfo.qh:14
float MapInfo_progress
Definition mapinfo.qh:173
void MapInfo_Cache_Destroy()
Definition mapinfo.qc:43
void MapInfo_Cache_Create()
Definition mapinfo.qc:53
const int GAMETYPE_FLAG_TEAMPLAY
Definition mapinfo.qh:19
string _MapInfo_GetDefaultEx(Gametype t)
Definition mapinfo.qc:534
string _MapInfo_FindArenaFile(string pFilename, string extension)
Definition mapinfo.qc:1008
const int GAMETYPE_FLAG_1V1
Definition mapinfo.qh:25
Gametype MapInfo_Type_FromString(string t, bool dowarn, bool is_q3compat)
Definition mapinfo.qc:621
int MapInfo_ForbiddenFlags()
Definition mapinfo.qc:1664
int MapInfo_CurrentFeatures()
Definition mapinfo.qc:1480
string MapInfo_Type_ToText(Gametype t)
Definition mapinfo.qc:661
float _MapInfo_FilterGametype(vector gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
string MapInfo_Map_title
Definition mapinfo.qh:7
string MapInfo_Map_author
Definition mapinfo.qh:10
const int MAPINFO_FEATURE_WEAPONS
Definition mapinfo.qh:156
const int GAMETYPE_FLAG_WEAPONARENA
Definition mapinfo.qh:24
const int MAPINFO_FLAG_HIDDEN
Definition mapinfo.qh:161
int MapInfo_Map_flags
Definition mapinfo.qh:15
void MapInfo_SwitchGameType(Gametype t)
Definition mapinfo.qc:1518
void MapInfo_LoadMapSettings(string s)
Definition mapinfo.qc:1580
void MapInfo_ClearTemps()
Definition mapinfo.qc:1639
const int MAPINFO_FEATURE_VEHICLES
Definition mapinfo.qh:157
float _MapInfo_GetTeamPlayBool(Gametype t)
Definition mapinfo.qc:539
string MapInfo_Map_titlestring
Definition mapinfo.qh:8
const int MAPINFO_FEATURE_TURRETS
Definition mapinfo.qh:158
void MapInfo_Cache_Invalidate()
Definition mapinfo.qc:61
void MapInfo_Enumerate()
Definition mapinfo.qc:134
string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden)
Definition mapinfo.qc:1556
const int GAMETYPE_FLAG_HIDELIMITS
Definition mapinfo.qh:23
string MapInfo_Map_clientstuff
Definition mapinfo.qh:11
string MapInfo_Map_description
Definition mapinfo.qh:9
const int GAMETYPE_FLAG_PREFERRED
Definition mapinfo.qh:21
int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet)
Definition mapinfo.qc:1390
const int MAPINFO_FLAG_FRUSTRATING
Definition mapinfo.qh:163
vector gametype_flags
Definition mapinfo.qh:28
bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gametype pGametypeToSet, bool isdefi, bool isgenerator)
Definition mapinfo.qc:826
string MapInfo_FixName(string s)
Definition mapinfo.qc:1474
const int MAPINFO_FLAG_DONOTWANT
Definition mapinfo.qh:164
string name
Definition menu.qh:30
string string_null
Definition nil.qh:9
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define SUPER(cname)
Definition oo.qh:231
#define CLASS(...)
Definition oo.qh:145
#define ENDCLASS(cname)
Definition oo.qh:281
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define ATTRIB(...)
Definition oo.qh:148
this m_description
Definition pages.qc:28
#define NULL
Definition post.qh:14
#define REGISTRY_SORT(...)
Definition registry.qh:128
#define REGISTER_REGISTRY(id)
Definition registry.qh:229
#define REGISTRY(id, max)
Declare a new registry.
Definition registry.qh:26
#define REGISTRY_CHECK(id)
Definition registry.qh:175
#define REGISTRY_DEFINE_GET(id, null)
Definition registry.qh:40
vector
Definition self.qh:92
#define STATIC_INIT(func)
during worldspawn
Definition static.qh:32
ERASEABLE string cons(string a, string b)
Definition string.qh:276
string model2