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