Xonotic
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
8 string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant
11 string MapInfo_Map_clientstuff; // not in cache, only for map load
12 string MapInfo_Map_fog; // not in cache, only for map load
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 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
24 const int GAMETYPE_FLAG_WEAPONARENA = BIT(5); // gametype has a forced weapon arena, weapon arena mutators should disable themselves when this is set
25 
27 .int m_flags;
28 
30  ATTRIB(Gametype, m_id, int, 0);
32  ATTRIB(Gametype, items, int, 0);
34  ATTRIB(Gametype, netname, string);
36  ATTRIB(Gametype, mdl, string);
38  ATTRIB(Gametype, message, string);
40  ATTRIB(Gametype, team, bool, false);
42  ATTRIB(Gametype, frags, bool, true);
44  ATTRIB(Gametype, m_hidelimits, bool, false);
46  ATTRIB(Gametype, m_weaponarena, bool, false);
48  ATTRIB(Gametype, model2, string);
50  ATTRIB(Gametype, gametype_description, string);
52  ATTRIB(Gametype, m_priority, int, 0);
53 #ifdef CSQC
54  ATTRIB(Gametype, m_modicons, void(vector pos, vector mySize));
55  ATTRIB(Gametype, m_modicons_reset, void());
56  ATTRIB(Gametype, m_modicons_export, void(int fh));
57 #endif
58 
60  ATTRIB(Gametype, m_legacydefaults, string, "");
61 
62  ATTRIB(Gametype, m_mutators, string);
63  METHOD(Gametype, m_parse_mapinfo, bool(string k, string v))
64  {
65  return false;
66  }
67  METHOD(Gametype, m_generate_mapinfo, void(Gametype this, string v))
68  {
69  TC(Gametype, this);
70  }
71  METHOD(Gametype, m_isTwoBaseMode, bool())
72  {
73  return false;
74  }
75  METHOD(Gametype, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
76  {
77  return false;
78  }
79  METHOD(Gametype, m_isForcedSupported, bool(Gametype this))
80  {
81  return false;
82  }
83  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))
84  {
85  TC(Gametype, this);
86  returns(menu, _("Frag limit:"), 5, 100, 5, "fraglimit_override", string_null, _("The amount of frags needed before the match will end"));
87  }
88 
89  METHOD(Gametype, describe, string(Gametype this))
90  {
91  TC(Gametype, this);
92  return this.gametype_description;
93  }
94 
95  METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns))
96  {
97  TC(Gametype, this);
98  returns(this.message, strcat("gametype_", this.mdl));
99  }
100 
101  METHOD(Gametype, gametype_init, void(Gametype this, string hname, string sname, string g_name, int gflags, string mutators, string defaults, string gdescription))
102  {
103  this.netname = g_name;
104  this.mdl = sname;
105  this.message = hname;
106  this.team = (gflags & GAMETYPE_FLAG_TEAMPLAY);
107  this.m_mutators = cons(sname, mutators);
108  this.model2 = defaults;
109  this.gametype_description = gdescription;
110  this.frags = (gflags & GAMETYPE_FLAG_USEPOINTS);
111  this.m_priority = ((gflags & GAMETYPE_FLAG_PREFERRED) ? 2 : ((gflags & GAMETYPE_FLAG_PRIORITY) ? 1 : 0));
112  this.m_hidelimits = (gflags & GAMETYPE_FLAG_HIDELIMITS);
113  this.m_weaponarena = (gflags & GAMETYPE_FLAG_WEAPONARENA);
114 
115  // same as `1 << m_id`
116  MAPINFO_TYPE_ALL |= this.items = this.m_flags = (MAPINFO_TYPE_ALL + 1);
117  }
118 ENDCLASS(Gametype)
119 
120 REGISTRY(Gametypes, 32)
121 REGISTER_REGISTRY(Gametypes)
122 REGISTRY_SORT(Gametypes);
123 REGISTRY_CHECK(Gametypes)
124 
125 REGISTRY_DEFINE_GET(Gametypes, NULL)
126 STATIC_INIT(Gametypes_renumber) { FOREACH(Gametypes, true, it.m_id = i); }
127 #define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
128 
129 #ifndef CSQC
130 // NOTE: ISGAMETYPE in csqc (temporary hack)
131 #define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
132 #endif
133 
134 const int MAPINFO_FEATURE_WEAPONS = 1; // not defined for instagib-only maps
138 
139 const int MAPINFO_FLAG_HIDDEN = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually
140 const int MAPINFO_FLAG_FORBIDDEN = 2; // don't even allow the map by a cvar setting that allows hidden maps
141 const int MAPINFO_FLAG_FRUSTRATING = 4; // this map is near impossible to play, enable at your own risk
142 const int MAPINFO_FLAG_NOAUTOMAPLIST = 8; // do not include when automatically building maplist (counts as hidden for maplist building purposes)
143 
145 
146 // load MapInfo_count; generate mapinfo for maps that miss them, and clear the
147 // cache; you need to call MapInfo_FilterGametype afterwards!
148 void MapInfo_Enumerate();
149 
150 // filter the info by game type mask (updates MapInfo_count)
152 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)
153 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)
154 void MapInfo_FilterString(string sf); // filter _MapInfo_filtered (created by MapInfo_FilterGametype) with keyword
155 int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
156 Gametype MapInfo_CurrentGametype(); // retrieves current gametype from cvars
157 int MapInfo_ForbiddenFlags(); // retrieves current flags from cvars
158 int MapInfo_RequiredFlags(); // retrieves current flags from cvars
159 
160 // load info about the i-th map into the MapInfo_Map_* globals
161 bool MapInfo_Get_ByID(int i); // 1 on success, 0 on failure
162 string MapInfo_BSPName_ByID(float i);
163 
164 // load info about a map by name into the MapInfo_Map_* globals
165 int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet); // 1 on success, 0 on failure, 2 if it autogenerated a mapinfo file
166 
167 // look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
168 string MapInfo_FindName_match; // the name of the map that was found
169 float MapInfo_FindName_firstResult; // -1 if none were found, index of first one if not unique but found (FindName then returns -1)
170 float MapInfo_FindName(string s);
171 string MapInfo_FixName(string s);
172 
173 // play a map
174 float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
175 void MapInfo_LoadMap(string s, float reinit);
176 
177 // list all maps for the current game type
178 string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden);
179 // list all allowed maps (for any game type)
180 string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
181 
182 // gets a gametype from a string
183 string _MapInfo_GetDefaultEx(Gametype t);
184 float _MapInfo_GetTeamPlayBool(Gametype t);
185 Gametype MapInfo_Type_FromString(string t, bool dowarn);
186 string MapInfo_Type_Description(Gametype t);
187 string MapInfo_Type_ToString(Gametype t);
188 string MapInfo_Type_ToText(Gametype t);
189 void MapInfo_SwitchGameType(Gametype t);
190 
191 // to be called from worldspawn to set up cvars
192 void MapInfo_LoadMapSettings(string s);
193 Gametype MapInfo_LoadedGametype; // game type that was active during map load
194 
195 void MapInfo_Cache_Destroy(); // disable caching
196 void MapInfo_Cache_Create(); // enable caching
197 void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled
198 
199 void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse);
200 
201 void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame
202 
203 void MapInfo_Shutdown(); // call this in the shutdown handler
204 
205 #define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
206 #define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* +*"
string MapInfo_ListAllowedMaps(Gametype type, float pFlagsRequired, float pFlagsForbidden)
Definition: mapinfo.qc:1202
string MapInfo_BSPName_ByID(float i)
Definition: mapinfo.qc:231
string string_null
Definition: nil.qh:9
int MapInfo_RequiredFlags()
Definition: mapinfo.qc:1339
CLASS(Object) Object
Definition: oo.qh:318
string MapInfo_Map_clientstuff
Definition: mapinfo.qh:11
vector MapInfo_Map_maxs
Definition: mapinfo.qh:17
int MapInfo_Map_supportedFeatures
Definition: mapinfo.qh:14
string MapInfo_Type_ToString(Gametype t)
Definition: mapinfo.qc:616
int team
Definition: main.qh:157
int MAPINFO_TYPE_ALL
Definition: mapinfo.qh:26
const int GAMETYPE_FLAG_HIDELIMITS
Definition: mapinfo.qh:23
float MapInfo_progress
Definition: mapinfo.qh:151
entity() spawn
const int MAPINFO_FEATURE_WEAPONS
Definition: mapinfo.qh:134
Gametype MapInfo_LoadedGametype
Definition: mapinfo.qh:193
float MapInfo_CheckMap(string s)
Definition: mapinfo.qc:1170
#define false
Definition: csprogsdefs.qh:6
#define REGISTRY_CHECK(id)
Definition: registry.qh:175
string netname
Definition: powerups.qc:20
int MapInfo_CurrentFeatures()
Definition: mapinfo.qc:1140
const int GAMETYPE_FLAG_WEAPONARENA
Definition: mapinfo.qh:24
void MapInfo_Shutdown()
Definition: mapinfo.qc:1311
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
int m_flags
Definition: mapinfo.qh:27
string MapInfo_Map_description
Definition: mapinfo.qh:9
void MapInfo_FilterString(string sf)
Definition: mapinfo.qc:194
int MapInfo_Map_flags
Definition: mapinfo.qh:15
const int GAMETYPE_FLAG_TEAMPLAY
Definition: mapinfo.qh:19
#define ATTRIB(...)
Definition: oo.qh:136
string MapInfo_FindName_match
Definition: mapinfo.qh:168
string MapInfo_Map_author
Definition: mapinfo.qh:10
#define REGISTER_REGISTRY(id)
Definition: registry.qh:212
bool MapInfo_Get_ByID(int i)
Definition: mapinfo.qc:256
STATIC_INIT(Gametypes_renumber)
Definition: mapinfo.qh:126
void MapInfo_ClearTemps()
Definition: mapinfo.qc:1299
#define REGISTRY_DEFINE_GET(id, null)
Definition: registry.qh:40
float _MapInfo_FilterGametype(int gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
int m_id
Definition: effect.qh:19
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
int MapInfo_Map_supportedGametypes
Definition: mapinfo.qh:13
float MapInfo_count
Definition: mapinfo.qh:144
float MapInfo_FilterGametype(Gametype gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
void MapInfo_Enumerate()
Definition: mapinfo.qc:115
REGISTRY_SORT(Gametypes)
void MapInfo_Cache_Destroy()
Definition: mapinfo.qc:24
const int MAPINFO_FEATURE_VEHICLES
Definition: mapinfo.qh:135
void MapInfo_SwitchGameType(Gametype t)
Definition: mapinfo.qc:1178
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define REGISTRY(id, max)
Declare a new registry.
Definition: registry.qh:26
vector MapInfo_Map_mins
Definition: mapinfo.qh:16
string message
Definition: powerups.qc:19
#define NULL
Definition: post.qh:17
string MapInfo_FixName(string s)
Definition: mapinfo.qc:1134
string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden)
Definition: mapinfo.qc:1216
#define TC(T, sym)
Definition: _all.inc:82
frags
Definition: ent_cs.qc:151
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
const int GAMETYPE_FLAG_PREFERRED
Definition: mapinfo.qh:21
const int MAPINFO_FLAG_FORBIDDEN
Definition: mapinfo.qh:140
float MapInfo_FindName(string s)
Definition: mapinfo.qc:1086
string MapInfo_Type_ToText(Gametype t)
Definition: mapinfo.qc:621
string MapInfo_Type_Description(Gametype t)
Definition: mapinfo.qc:611
string MapInfo_Map_title
Definition: mapinfo.qh:7
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float MapInfo_FindName_firstResult
Definition: mapinfo.qh:169
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
vector v
Definition: ent_cs.qc:116
const int GAMETYPE_FLAG_USEPOINTS
Definition: mapinfo.qh:20
string MapInfo_Map_bspname
Definition: mapinfo.qh:6
string MapInfo_Map_fog
Definition: mapinfo.qh:12
const int MAPINFO_FLAG_HIDDEN
Definition: mapinfo.qh:139
void MapInfo_LoadMap(string s, float reinit)
Definition: mapinfo.qc:1183
#define ENDCLASS(cname)
Definition: oo.qh:269
float items
Definition: progsdefs.qc:145
const int MAPINFO_FLAG_FRUSTRATING
Definition: mapinfo.qh:141
void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
Definition: mapinfo.qc:627
ERASEABLE string cons(string a, string b)
Definition: string.qh:257
int MapInfo_Get_ByName(string s, float allowGenerate, Gametype gametypeToSet)
Definition: mapinfo.qc:1067
const int MAPINFO_FEATURE_TURRETS
Definition: mapinfo.qh:136
void MapInfo_Cache_Create()
Definition: mapinfo.qc:34
const int GAMETYPE_FLAG_PRIORITY
Definition: mapinfo.qh:22
const int MAPINFO_FEATURE_MONSTERS
Definition: mapinfo.qh:137
float _MapInfo_GetTeamPlayBool(Gametype t)
Definition: mapinfo.qc:507
void MapInfo_Cache_Invalidate()
Definition: mapinfo.qc:42
#define FOREACH(list, cond, body)
Definition: iter.qh:19
const int MAPINFO_FLAG_NOAUTOMAPLIST
Definition: mapinfo.qh:142
string _MapInfo_GetDefaultEx(Gametype t)
Definition: mapinfo.qc:502
#define true
Definition: csprogsdefs.qh:5
Gametype MapInfo_Type_FromString(string t, bool dowarn)
Definition: mapinfo.qc:589
string MapInfo_Map_titlestring
Definition: mapinfo.qh:8
void MapInfo_LoadMapSettings(string s)
Definition: mapinfo.qc:1240