1 // generic string stuff
3 float _MapInfo_Cache_Active;
4 float _MapInfo_Cache_DB_NameToIndex;
5 float _MapInfo_Cache_Buf_IndexToMapData;
7 void MapInfo_Cache_Destroy()
9 if(!_MapInfo_Cache_Active)
12 db_close(_MapInfo_Cache_DB_NameToIndex);
13 buf_del(_MapInfo_Cache_Buf_IndexToMapData);
14 _MapInfo_Cache_Active = 0;
17 void MapInfo_Cache_Create()
19 MapInfo_Cache_Destroy();
20 _MapInfo_Cache_DB_NameToIndex = db_create();
21 _MapInfo_Cache_Buf_IndexToMapData = buf_create();
22 _MapInfo_Cache_Active = 1;
25 void MapInfo_Cache_Invalidate()
27 if(!_MapInfo_Cache_Active)
30 MapInfo_Cache_Create();
33 void MapInfo_Cache_Store()
37 if(!_MapInfo_Cache_Active)
40 s = db_get(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname);
41 if(!s) // empty string is NOT valid here!
43 i = buf_getsize(_MapInfo_Cache_Buf_IndexToMapData);
44 db_put(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname, ftos(i));
49 // now store all the stuff
50 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, i, MapInfo_Map_bspname);
51 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_title);
52 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_titlestring);
53 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_description);
54 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_author);
55 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_supportedGametypes));
56 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_supportedFeatures));
57 bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_flags));
60 float MapInfo_Cache_Retrieve(string map)
64 if(!_MapInfo_Cache_Active)
67 s = db_get(_MapInfo_Cache_DB_NameToIndex, map);
72 // now retrieve all the stuff
73 MapInfo_Map_bspname = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, i);
74 MapInfo_Map_title = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
75 MapInfo_Map_titlestring = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
76 MapInfo_Map_description = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
77 MapInfo_Map_author = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
78 MapInfo_Map_supportedGametypes = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
79 MapInfo_Map_supportedFeatures = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
80 MapInfo_Map_flags = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
84 // GLOB HANDLING (for all BSP files)
85 float _MapInfo_globopen;
86 float _MapInfo_globcount;
87 float _MapInfo_globhandle;
88 string _MapInfo_GlobItem(float i)
91 s = search_getfilename(_MapInfo_globhandle, i);
92 return substring(s, 5, strlen(s) - 9); // without maps/ and .bsp
95 void MapInfo_Enumerate()
98 search_end(_MapInfo_globhandle);
99 MapInfo_Cache_Invalidate();
100 _MapInfo_globhandle = search_begin("maps/*.bsp", TRUE, TRUE);
101 _MapInfo_globcount = search_getsize(_MapInfo_globhandle);
102 _MapInfo_globopen = 1;
105 // filter the info by game type mask (updates MapInfo_count)
107 float _MapInfo_filtered;
108 float _MapInfo_filtered_allocated;
109 float MapInfo_FilterList_Lookup(float i)
111 return stof(bufstr_get(_MapInfo_filtered, i));
114 void _MapInfo_FilterList_swap(float i, float j, entity pass)
117 h = bufstr_get(_MapInfo_filtered, i);
118 bufstr_set(_MapInfo_filtered, i, bufstr_get(_MapInfo_filtered, j));
119 bufstr_set(_MapInfo_filtered, j, h);
122 float _MapInfo_FilterList_cmp(float i, float j, entity pass)
125 a = _MapInfo_GlobItem(stof(bufstr_get(_MapInfo_filtered, i)));
126 b = _MapInfo_GlobItem(stof(bufstr_get(_MapInfo_filtered, j)));
127 return strcasecmp(a, b);
130 float MapInfo_FilterGametype(float pGametype, float pFeatures, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
133 if not(_MapInfo_filtered_allocated)
135 _MapInfo_filtered_allocated = 1;
136 _MapInfo_filtered = buf_create();
139 for(i = 0, j = -1; i < _MapInfo_globcount; ++i)
141 if(MapInfo_Get_ByName(_MapInfo_GlobItem(i), 1, 0) == 2) // if we generated one... BAIL OUT and let the caller continue in the next frame.
144 dprint("Autogenerated a .mapinfo, doing the rest later.\n");
145 MapInfo_progress = i / _MapInfo_globcount;
148 if((MapInfo_Map_supportedGametypes & pGametype) != 0)
149 if((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures)
150 if((MapInfo_Map_flags & pFlagsForbidden) == 0)
151 if((MapInfo_Map_flags & pFlagsRequired) == pFlagsRequired)
152 bufstr_set(_MapInfo_filtered, ++j, ftos(i));
154 MapInfo_count = j + 1;
155 MapInfo_ClearTemps();
157 // sometimes the glob isn't sorted nicely, so fix it here...
158 heapsort(MapInfo_count, _MapInfo_FilterList_swap, _MapInfo_FilterList_cmp, world);
163 void MapInfo_Filter_Free()
165 if(_MapInfo_filtered_allocated)
167 buf_del(_MapInfo_filtered);
168 _MapInfo_filtered_allocated = 0;
172 // load info about the i-th map into the MapInfo_Map_* globals
173 string MapInfo_BSPName_ByID(float i)
175 return _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i));
178 string unquote(string s)
183 for(i = 0; i < l; ++i)
186 ch = substring(s, i, 1);
187 if(ch != " ") if(ch != "\"")
189 for(j = strlen(s) - i - 1; j > 0; --j)
191 ch = substring(s, i+j, 1);
192 if(ch != " ") if(ch != "\"")
193 return substring(s, i, j+1);
195 return substring(s, i, 1);
201 float MapInfo_Get_ByID(float i)
203 if(MapInfo_Get_ByName(MapInfo_BSPName_ByID(i), 0, 0))
208 string _MapInfo_Map_worldspawn_music;
210 float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
220 float diameter, spawnpoints;
223 vector mapMins, mapMaxs;
226 fn = strcat("maps/", pFilename, ".ent");
227 fh = fopen(fn, FILE_READ);
231 fn = strcat("maps/", pFilename, ".bsp");
232 fh = fopen(fn, FILE_READ);
236 print("Analyzing ", fn, " to generate initial mapinfo\n");
239 MapInfo_Map_flags = 0;
240 MapInfo_Map_supportedGametypes = 0;
243 _MapInfo_Map_worldspawn_music = "";
247 if not((s = fgets(fh)))
249 if(inWorldspawn == 1)
250 if(startsWith(s, "}"))
256 if(k == "classname" && v == "worldspawn")
258 else if(k == "author")
259 MapInfo_Map_author = v;
260 else if(k == "_description")
261 MapInfo_Map_description = v;
262 else if(k == "music")
263 _MapInfo_Map_worldspawn_music = v;
264 else if(k == "noise")
265 _MapInfo_Map_worldspawn_music = v;
266 else if(k == "message")
268 i = strstrofs(v, " by ", 0);
269 if(MapInfo_Map_author == "<AUTHOR>" && i >= 0)
271 MapInfo_Map_title = substring(v, 0, i);
272 MapInfo_Map_author = substring(v, i + 4, strlen(v) - (i + 4));
275 MapInfo_Map_title = v;
282 o = stov(strcat("'", v, "'"));
283 mapMins_x = min(mapMins_x, o_x);
284 mapMins_y = min(mapMins_y, o_y);
285 mapMins_z = min(mapMins_z, o_z);
286 mapMaxs_x = max(mapMaxs_x, o_x);
287 mapMaxs_y = max(mapMaxs_y, o_y);
288 mapMaxs_z = max(mapMaxs_z, o_z);
290 else if(k == "race_place")
295 else if(k == "classname")
297 if(v == "dom_controlpoint")
298 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_DOMINATION;
299 else if(v == "item_flag_team2")
300 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF;
301 else if(v == "team_CTF_blueflag")
302 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF;
303 else if(v == "runematch_spawn_point")
304 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH;
305 else if(v == "target_assault_roundend")
306 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ASSAULT;
307 else if(v == "onslaught_generator")
308 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ONSLAUGHT;
309 else if(substring(v, 0, 8) == "nexball_" || substring(v, 0, 4) == "ball")
310 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_NEXBALL;
311 else if(v == "info_player_team1")
313 else if(v == "info_player_team2")
315 else if(v == "info_player_start")
317 else if(v == "info_player_deathmatch")
319 else if(v == "trigger_race_checkpoint")
320 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RACE;
321 else if(v == "target_startTimer")
322 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS;
323 else if(v == "weapon_nex")
325 else if(v == "weapon_railgun")
327 else if(startsWith(v, "weapon_"))
328 MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
329 else if(startsWith(v, "turret_"))
330 MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_TURRETS;
331 else if(startsWith(v, "vehicle_"))
332 MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_VEHICLES;
333 else if(v == "target_music" || v == "trigger_music")
334 _MapInfo_Map_worldspawn_music = string_null; // don't use regular BGM
340 print(fn, " ended still in worldspawn, BUG\n");
343 diameter = vlen(mapMaxs - mapMins);
345 twoBaseModes = MapInfo_Map_supportedGametypes & (MAPINFO_TYPE_CTF | MAPINFO_TYPE_ASSAULT | MAPINFO_TYPE_RACE | MAPINFO_TYPE_NEXBALL);
346 if(twoBaseModes && (MapInfo_Map_supportedGametypes == twoBaseModes))
348 // we have a CTF-only or Assault-only map. Don't add other modes then,
349 // as the map is too symmetric for them.
353 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_DEATHMATCH; // DM always works
354 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH; // Rune always works
355 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_LMS; // LMS always works
356 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_KEEPAWAY; // Keepaway always works
358 if(spawnpoints >= 8 && diameter > 4096) {
359 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_TEAM_DEATHMATCH;
360 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_FREEZETAG;
361 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CA;
364 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ARENA;
365 if(spawnpoints >= 12 && diameter > 5120)
366 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_KEYHUNT;
369 if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE)
372 MapInfo_Map_supportedGametypes &~= MAPINFO_TYPE_RACE;
373 MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS;
376 dprint("-> diameter ", ftos(diameter));
377 dprint("; spawnpoints ", ftos(spawnpoints));
378 dprint("; modes ", ftos(MapInfo_Map_supportedGametypes), "\n");
385 void _MapInfo_Map_Reset()
387 MapInfo_Map_title = "<TITLE>";
388 MapInfo_Map_titlestring = "<TITLE>";
389 MapInfo_Map_description = "<DESCRIPTION>";
390 MapInfo_Map_author = "<AUTHOR>";
391 MapInfo_Map_supportedGametypes = 0;
392 MapInfo_Map_supportedFeatures = 0;
393 MapInfo_Map_flags = 0;
394 MapInfo_Map_clientstuff = "";
395 MapInfo_Map_fog = "";
396 MapInfo_Map_mins = '0 0 0';
397 MapInfo_Map_maxs = '0 0 0';
400 string _MapInfo_GetDefault(float t)
404 case MAPINFO_TYPE_DEATHMATCH: return "30 20 0";
405 case MAPINFO_TYPE_TEAM_DEATHMATCH: return "50 20 2 0";
406 case MAPINFO_TYPE_DOMINATION: return "200 20 0";
407 case MAPINFO_TYPE_CTF: return "300 20 10 0";
408 case MAPINFO_TYPE_RUNEMATCH: return "200 20 0";
409 case MAPINFO_TYPE_LMS: return "9 20 0";
410 case MAPINFO_TYPE_ARENA: return "10 20 0";
411 case MAPINFO_TYPE_CA: return "10 20 0";
412 case MAPINFO_TYPE_KEYHUNT: return "1000 20 3 0";
413 case MAPINFO_TYPE_ASSAULT: return "20 0";
414 case MAPINFO_TYPE_RACE: return "20 5 7 15 0";
415 case MAPINFO_TYPE_ONSLAUGHT: return "20 0";
416 case MAPINFO_TYPE_NEXBALL: return "5 20 0";
417 case MAPINFO_TYPE_CTS: return "20 0 0";
418 case MAPINFO_TYPE_FREEZETAG: return "10 20 0";
419 // NOTE: DO NOT ADD ANY MORE GAME TYPES HERE
420 // THIS IS JUST LEGACY SUPPORT FOR NEXUIZ MAPS
421 // ONLY ADD NEW STUFF TO _MapInfo_GetDefaultEx
422 // THIS FUNCTION WILL EVENTUALLY BE REMOVED
427 void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, float load_default)
430 MapInfo_Map_supportedGametypes |= pThisType;
431 if(!(pThisType & pWantedType))
435 _MapInfo_Map_ApplyGametype(_MapInfo_GetDefault(pThisType), pWantedType, pThisType, FALSE);
437 if(pWantedType == MAPINFO_TYPE_ASSAULT || pWantedType == MAPINFO_TYPE_ONSLAUGHT || pWantedType == MAPINFO_TYPE_RACE || pWantedType == MAPINFO_TYPE_CTS) // these modes don't use fraglimit
439 cvar_set("fraglimit", "0");
445 cvar_set("fraglimit", sa);
451 cvar_set("timelimit", sa);
454 if(pWantedType == MAPINFO_TYPE_TEAM_DEATHMATCH)
458 cvar_set("g_tdm_teams", sa);
462 if(pWantedType == MAPINFO_TYPE_KEYHUNT)
466 cvar_set("g_keyhunt_teams", sa);
470 if(pWantedType == MAPINFO_TYPE_CTF)
474 if(cvar("g_ctf_win_mode") < 2)
475 cvar_set("fraglimit", sa);
480 if(pWantedType == MAPINFO_TYPE_KEEPAWAY)
484 cvar_set("fraglimit", sa);
489 // rc = timelimit timelimit_qualification laps laps_teamplay
490 if(pWantedType == MAPINFO_TYPE_RACE)
492 sa = car(s); if(sa == "") sa = cvar_string("timelimit");
493 cvar_set("g_race_qualifying_timelimit", sa);
498 if(cvar("g_race_teams") < 2)
499 cvar_set("fraglimit", sa);
504 if(cvar("g_race_teams") >= 2)
505 cvar_set("fraglimit", sa);
509 if(pWantedType == MAPINFO_TYPE_CTS)
513 // this is the skill of the map
514 // not parsed by anything yet
517 // cvar_set("fraglimit", sa);
522 if(pWantedType == MAPINFO_TYPE_ASSAULT || pWantedType == MAPINFO_TYPE_ONSLAUGHT || pWantedType == MAPINFO_TYPE_CTS) // these modes don't use fraglimit
524 cvar_set("leadlimit", "0");
530 cvar_set("leadlimit", sa);
535 string _MapInfo_GetDefaultEx(float t)
539 case MAPINFO_TYPE_DEATHMATCH: return "timelimit=20 pointlimit=30 leadlimit=0";
540 case MAPINFO_TYPE_TEAM_DEATHMATCH: return "timelimit=20 pointlimit=50 teams=2 leadlimit=0";
541 case MAPINFO_TYPE_DOMINATION: return "timelimit=20 pointlimit=200 teams=2 leadlimit=0";
542 case MAPINFO_TYPE_CTF: return "timelimit=20 pointlimit=300 caplimit=10 leadlimit=0";
543 case MAPINFO_TYPE_RUNEMATCH: return "timelimit=20 pointlimit=200 leadlimit=0";
544 case MAPINFO_TYPE_LMS: return "timelimit=20 lives=9 leadlimit=0";
545 case MAPINFO_TYPE_ARENA: return "timelimit=20 pointlimit=10 leadlimit=0";
546 case MAPINFO_TYPE_CA: return "timelimit=20 pointlimit=10 leadlimit=0";
547 case MAPINFO_TYPE_KEYHUNT: return "timelimit=20 pointlimit=1000 teams=3 leadlimit=0";
548 case MAPINFO_TYPE_ASSAULT: return "timelimit=20";
549 case MAPINFO_TYPE_RACE: return "timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0";
550 case MAPINFO_TYPE_ONSLAUGHT: return "timelimit=20";
551 case MAPINFO_TYPE_NEXBALL: return "timelimit=20 pointlimit=5 leadlimit=0";
552 case MAPINFO_TYPE_CTS: return "timelimit=20 skill=-1";
553 case MAPINFO_TYPE_FREEZETAG: return "timelimit=20 pointlimit=10 teams=2 leadlimit=0";
554 case MAPINFO_TYPE_KEEPAWAY: return "timelimit=20 pointlimit=30";
559 void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType)
563 string fraglimit_normal;
564 string fraglimit_caps;
565 string fraglimit_teams;
567 MapInfo_Map_supportedGametypes |= pThisType;
568 if(!(pThisType & pWantedType))
571 // reset all the cvars to their defaults
573 cvar_set("timelimit", cvar_defstring("timelimit"));
574 cvar_set("leadlimit", cvar_defstring("leadlimit"));
575 cvar_set("fraglimit", cvar_defstring("fraglimit"));
576 cvar_set("g_tdm_teams", cvar_defstring("g_tdm_teams"));
577 cvar_set("g_keyhunt_teams", cvar_defstring("g_keyhunt_teams"));
578 cvar_set("g_domination_default_teams", cvar_defstring("g_domination_default_teams"));
579 cvar_set("g_race_qualifying_timelimit", cvar_defstring("g_race_qualifying_timelimit"));
581 fraglimit_normal = string_null;
582 fraglimit_caps = string_null;
583 fraglimit_teams = string_null;
585 s = strcat(_MapInfo_GetDefaultEx(pWantedType), " ", s);
594 p = strstrofs(sa, "=", 0);
602 k = substring(sa, 0, p);
603 v = substring(sa, p+1, -1);
608 cvar_set("timelimit", v);
610 else if(k == "leadlimit")
612 cvar_set("leadlimit", v);
614 else if(k == "pointlimit" || k == "fraglimit" || k == "lives" || k == "laplimit")
616 fraglimit_normal = v;
618 else if(k == "caplimit")
622 else if(k == "teampointlimit" || k == "teamlaplimit")
626 else if(k == "teams")
628 cvar_set("g_tdm_teams", v);
629 cvar_set("g_keyhunt_teams", v);
630 cvar_set("g_domination_default_teams", v);
632 else if(k == "qualifying_timelimit")
634 cvar_set("g_race_qualifying_timelimit", v);
636 else if(k == "skill")
642 print("Invalid gametype key in mapinfo: ", k, "\n");
646 if(pWantedType == MAPINFO_TYPE_CTF && cvar("g_ctf_win_mode") < 2)
649 cvar_set("fraglimit", fraglimit_caps);
651 else if(pWantedType == MAPINFO_TYPE_RACE && cvar("g_race_teams") >= 2)
654 cvar_set("fraglimit", fraglimit_teams);
659 cvar_set("fraglimit", fraglimit_normal);
663 float MapInfo_Type_FromString(string t)
665 if (t == "dm") return MAPINFO_TYPE_DEATHMATCH;
666 else if(t == "tdm") return MAPINFO_TYPE_TEAM_DEATHMATCH;
667 else if(t == "dom") return MAPINFO_TYPE_DOMINATION;
668 else if(t == "ctf") return MAPINFO_TYPE_CTF;
669 else if(t == "rune") return MAPINFO_TYPE_RUNEMATCH;
670 else if(t == "lms") return MAPINFO_TYPE_LMS;
671 else if(t == "arena") return MAPINFO_TYPE_ARENA;
672 else if(t == "ca") return MAPINFO_TYPE_CA;
673 else if(t == "kh") return MAPINFO_TYPE_KEYHUNT;
674 else if(t == "as") return MAPINFO_TYPE_ASSAULT;
675 else if(t == "ons") return MAPINFO_TYPE_ONSLAUGHT;
676 else if(t == "rc") return MAPINFO_TYPE_RACE;
677 else if(t == "nexball") return MAPINFO_TYPE_NEXBALL;
678 else if(t == "cts") return MAPINFO_TYPE_CTS;
679 else if(t == "freezetag") return MAPINFO_TYPE_FREEZETAG;
680 else if(t == "keepaway") return MAPINFO_TYPE_KEEPAWAY;
681 else if(t == "all") return MAPINFO_TYPE_ALL;
685 string MapInfo_Type_ToString(float t)
687 if (t == MAPINFO_TYPE_DEATHMATCH) return "dm";
688 else if(t == MAPINFO_TYPE_TEAM_DEATHMATCH) return "tdm";
689 else if(t == MAPINFO_TYPE_DOMINATION) return "dom";
690 else if(t == MAPINFO_TYPE_CTF) return "ctf";
691 else if(t == MAPINFO_TYPE_RUNEMATCH) return "rune";
692 else if(t == MAPINFO_TYPE_LMS) return "lms";
693 else if(t == MAPINFO_TYPE_ARENA) return "arena";
694 else if(t == MAPINFO_TYPE_CA) return "ca";
695 else if(t == MAPINFO_TYPE_KEYHUNT) return "kh";
696 else if(t == MAPINFO_TYPE_ASSAULT) return "as";
697 else if(t == MAPINFO_TYPE_ONSLAUGHT) return "ons";
698 else if(t == MAPINFO_TYPE_RACE) return "rc";
699 else if(t == MAPINFO_TYPE_NEXBALL) return "nexball";
700 else if(t == MAPINFO_TYPE_CTS) return "cts";
701 else if(t == MAPINFO_TYPE_FREEZETAG) return "freezetag";
702 else if(t == MAPINFO_TYPE_KEEPAWAY) return "keepaway";
703 else if(t == MAPINFO_TYPE_ALL) return "all";
707 void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
711 t = car(s); s = cdr(s);
713 // limited support of "" and comments
714 // remove trailing and leading " of t
715 if(substring(t, 0, 1) == "\"")
717 if(substring(t, -1, 1) == "\"")
718 t = substring(t, 1, -2);
721 // remove leading " of s
722 if(substring(s, 0, 1) == "\"")
724 s = substring(s, 1, -1);
726 // remove trailing " of s, and all that follows (cvar description)
727 o = strstrofs(s, "\"", 0);
729 s = substring(s, 0, o);
731 // remove // comments
732 o = strstrofs(s, "//", 0);
734 s = substring(s, 0, o);
736 // remove trailing spaces
737 while(substring(s, -1, 1) == " ")
738 s = substring(s, 0, -2);
744 fh = fopen(s, FILE_READ);
746 print("Map ", pFilename, " references not existing config file ", s, "\n");
751 if not((s = fgets(fh)))
754 // catch different sorts of comments
755 if(s == "") // empty lines
757 if(substring(s, 0, 1) == "#") // UNIX style
759 if(substring(s, 0, 2) == "//") // C++ style
761 if(substring(s, 0, 1) == "_") // q3map style
764 if(substring(s, 0, 4) == "set ")
765 s = substring(s, 4, -1);
766 if(substring(s, 0, 5) == "seta ")
767 s = substring(s, 5, -1);
769 _MapInfo_Parse_Settemp(pFilename, acl, type, s, recurse - 1);
775 print("Map ", pFilename, " uses too many levels of inclusion\n");
778 print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
779 else if not(cvar_value_issafe(t))
780 print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
781 else if not (cvar_value_issafe(s))
782 print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
783 else if(matchacl(MAPINFO_SETTEMP_ACL_SYSTEM, t) <= 0)
784 print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
785 else if(matchacl(acl, t) <= 0)
786 print("Map ", pFilename, " contains a denied setting, ignored\n");
789 if(type == 0) // server set
791 dprint("Applying temporary setting ", t, " := ", s, "\n");
792 if(cvar("g_campaign"))
793 cvar_set(t, s); // this is a wrapper and is always temporary anyway; no need to backup old values then
799 dprint("Applying temporary client setting ", t, " := ", s, "\n");
800 MapInfo_Map_clientstuff = strcat(
801 MapInfo_Map_clientstuff, "cl_cmd settemp \"", t, "\" \"", s, "\"\n"
807 float MapInfo_isRedundant(string fn, string t)
809 // normalize file name
810 fn = strreplace("_", "-", fn);
812 // normalize visible title
813 t = strreplace(": ", "-", t);
814 t = strreplace(":", "-", t);
815 t = strreplace(" ", "-", t);
816 t = strreplace("_", "-", t);
817 t = strreplace("'", "-", t);
819 if(!strcasecmp(fn, t))
822 // we allow the visible title to have punctuation the file name does
823 // not, but not vice versa
824 t = strreplace("-", "", t);
826 if(!strcasecmp(fn, t))
832 // load info about a map by name into the MapInfo_Map_* globals
833 float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
841 acl = MAPINFO_SETTEMP_ACL_USER;
843 if(strstrofs(pFilename, "/", 0) >= 0)
845 print("Invalid character in map name, ignored\n");
849 if(pGametypeToSet == 0)
850 if(MapInfo_Cache_Retrieve(pFilename))
855 MapInfo_Map_bspname = pFilename;
857 // default all generic fields so they have "good" values in case something fails
858 fn = strcat("maps/", pFilename, ".mapinfo");
859 fh = fopen(fn, FILE_READ);
862 fn = strcat("maps/autogenerated/", pFilename, ".mapinfo");
863 fh = fopen(fn, FILE_READ);
868 _MapInfo_Map_Reset();
869 r = _MapInfo_Generate(pFilename);
872 fh = fopen(fn, FILE_WRITE);
873 fputs(fh, strcat("title ", MapInfo_Map_title, "\n"));
874 fputs(fh, strcat("description ", MapInfo_Map_description, "\n"));
875 fputs(fh, strcat("author ", MapInfo_Map_author, "\n"));
876 if(_MapInfo_Map_worldspawn_music != "")
879 substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav"
881 substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg"
883 fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n"));
885 fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n"));
889 n = tokenize_console(cvar_string("g_cdtracks_remaplist"));
890 s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " ");
893 i = floor(random() * n);
894 if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0)
897 fputs(fh, strcat("cdtrack ", ftos(i + 1), "\n"));
899 if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS)
900 fputs(fh, "has weapons\n");
902 fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n");
903 if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_TURRETS)
904 fputs(fh, "has turrets\n");
906 fputs(fh, "// uncomment this if you added turrets: has turrets\n");
907 if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_VEHICLES)
908 fputs(fh, "has weapons\n");
910 fputs(fh, "// uncomment this if you added vehicles: has vehicles\n");
911 if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING)
912 fputs(fh, "frustrating\n");
914 for(i = 1; i <= MapInfo_Map_supportedGametypes; i *= 2)
915 if(MapInfo_Map_supportedGametypes & i)
916 fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i)));
918 if(fexists(strcat("scripts/", pFilename, ".arena")))
919 fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n");
921 fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n");
922 fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n");
923 fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n");
924 fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
925 fputs(fh, "// optional: hidden\n");
930 fh = fopen(fn, FILE_READ);
932 error("... but I just wrote it!");
935 print("WARNING: autogenerated mapinfo file ", fn, " has been loaded; please edit that file and move it to maps/", pFilename, ".mapinfo\n");
938 _MapInfo_Map_Reset();
941 if not((s = fgets(fh)))
944 // catch different sorts of comments
945 if(s == "") // empty lines
947 if(substring(s, 0, 1) == "#") // UNIX style
949 if(substring(s, 0, 2) == "//") // C++ style
951 if(substring(s, 0, 1) == "_") // q3map style
954 p = strstrofs(s, "//", 0);
956 s = substring(s, 0, p);
958 t = car(s); s = cdr(s);
960 MapInfo_Map_title = s;
961 else if(t == "description")
962 MapInfo_Map_description = s;
963 else if(t == "author")
964 MapInfo_Map_author = s;
967 t = car(s); s = cdr(s);
968 if (t == "weapons") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
969 else if(t == "turrets") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_TURRETS;
970 else if(t == "vehicles") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_VEHICLES;
971 else if(t == "new_toys") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
973 dprint("Map ", pFilename, " supports unknown feature ", t, ", ignored\n");
975 else if(t == "hidden")
977 MapInfo_Map_flags |= MAPINFO_FLAG_HIDDEN;
979 else if(t == "forbidden")
981 MapInfo_Map_flags |= MAPINFO_FLAG_FORBIDDEN;
983 else if(t == "frustrating")
985 MapInfo_Map_flags |= MAPINFO_FLAG_FRUSTRATING;
989 t = car(s); s = cdr(s);
990 f = MapInfo_Type_FromString(t);
991 print("Map ", pFilename, " contains the legacy 'type' keyword which is deprecated and will be removed in the future. Please migrate the mapinfo file to 'gametype'.\n");
993 _MapInfo_Map_ApplyGametype (s, pGametypeToSet, f, TRUE);
995 dprint("Map ", pFilename, " supports unknown game type ", t, ", ignored\n");
997 else if(t == "gametype")
999 t = car(s); s = cdr(s);
1000 f = MapInfo_Type_FromString(t);
1002 _MapInfo_Map_ApplyGametypeEx (s, pGametypeToSet, f);
1004 dprint("Map ", pFilename, " supports unknown game type ", t, ", ignored\n");
1006 else if(t == "size")
1008 float a, b, c, d, e;
1009 t = car(s); s = cdr(s); a = stof(t);
1010 t = car(s); s = cdr(s); b = stof(t);
1011 t = car(s); s = cdr(s); c = stof(t);
1012 t = car(s); s = cdr(s); d = stof(t);
1013 t = car(s); s = cdr(s); e = stof(t);
1015 print("Map ", pFilename, " contains an incorrect size line (not enough params), syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
1018 t = car(s); s = cdr(s); f = stof(t);
1020 print("Map ", pFilename, " contains an incorrect size line (too many params), syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
1023 if(a >= d || b >= e || c >= f)
1024 print("Map ", pFilename, " contains an incorrect size line, mins have to be < maxs\n");
1027 MapInfo_Map_mins_x = a;
1028 MapInfo_Map_mins_y = b;
1029 MapInfo_Map_mins_z = c;
1030 MapInfo_Map_maxs_x = d;
1031 MapInfo_Map_maxs_y = e;
1032 MapInfo_Map_maxs_z = f;
1037 else if(t == "settemp_for_type")
1039 t = car(s); s = cdr(s);
1040 if((f = MapInfo_Type_FromString(t)))
1042 if(f & pGametypeToSet)
1044 _MapInfo_Parse_Settemp(pFilename, acl, 0, s, 1);
1049 dprint("Map ", pFilename, " has a setting for unknown game type ", t, ", ignored\n");
1052 else if(t == "clientsettemp_for_type")
1054 t = car(s); s = cdr(s);
1055 if((f = MapInfo_Type_FromString(t)))
1057 if(f & pGametypeToSet)
1059 _MapInfo_Parse_Settemp(pFilename, acl, 1, s, 1);
1064 dprint("Map ", pFilename, " has a client setting for unknown game type ", t, ", ignored\n");
1069 if not(cvar_value_issafe(t))
1070 print("Map ", pFilename, " contains a potentially harmful fog setting, ignored\n");
1072 MapInfo_Map_fog = s;
1074 else if(t == "cdtrack")
1078 if not(cvar_value_issafe(t))
1079 print("Map ", pFilename, " contains a potentially harmful cdtrack, ignored\n");
1081 MapInfo_Map_clientstuff = strcat(
1082 MapInfo_Map_clientstuff, "cd loop \"", s, "\"\n"
1087 dprint("Map ", pFilename, " provides unknown info item ", t, ", ignored\n");
1093 if(!(MapInfo_Map_supportedGametypes & pGametypeToSet))
1095 error("Can't select the requested game type. This should never happen as the caller should prevent it!\n");
1096 //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
1101 if(MapInfo_Map_title == "<TITLE>")
1102 MapInfo_Map_titlestring = MapInfo_Map_bspname;
1103 else if(MapInfo_isRedundant(MapInfo_Map_bspname, MapInfo_Map_title))
1104 MapInfo_Map_titlestring = MapInfo_Map_title;
1106 MapInfo_Map_titlestring = sprintf(_("%s: %s"), MapInfo_Map_bspname, MapInfo_Map_title);
1108 MapInfo_Cache_Store();
1109 if(MapInfo_Map_supportedGametypes != 0)
1111 dprint("Map ", pFilename, " supports no game types, ignored\n");
1115 float MapInfo_FindName(string s)
1117 // if there is exactly one map of prefix s, return it
1118 // if not, return the null string
1119 // note that DP sorts glob results... so I can use a binary search
1123 // invariants: r is behind s, l-1 is equal or before
1126 m = floor((l + r) / 2);
1127 MapInfo_FindName_match = _MapInfo_GlobItem(MapInfo_FilterList_Lookup(m));
1128 cmp = strcasecmp(MapInfo_FindName_match, s);
1130 return m; // found and good
1132 l = m + 1; // l-1 is before s
1136 MapInfo_FindName_match = _MapInfo_GlobItem(MapInfo_FilterList_Lookup(l));
1137 MapInfo_FindName_firstResult = l;
1138 // r == l, so: l is behind s, l-1 is before
1139 // SO: if there is any, l is the one with the right prefix
1140 // and l+1 may be one too
1141 if(l == MapInfo_count)
1143 MapInfo_FindName_match = string_null;
1144 MapInfo_FindName_firstResult = -1;
1145 return -1; // no MapInfo_FindName_match, behind last item
1147 if(!startsWithNocase(MapInfo_FindName_match, s))
1149 MapInfo_FindName_match = string_null;
1150 MapInfo_FindName_firstResult = -1;
1151 return -1; // wrong prefix
1153 if(l == MapInfo_count - 1)
1154 return l; // last one, nothing can follow => unique
1155 if(startsWithNocase(_MapInfo_GlobItem(MapInfo_FilterList_Lookup(l + 1)), s))
1157 MapInfo_FindName_match = string_null;
1158 return -1; // ambigous MapInfo_FindName_match
1163 string MapInfo_FixName(string s)
1165 MapInfo_FindName(s);
1166 return MapInfo_FindName_match;
1169 float MapInfo_CurrentFeatures()
1173 if(!(cvar("g_lms") || cvar("g_minstagib") || cvar("g_nix") || cvar("g_weaponarena") || !cvar("g_pickup_items") || cvar("g_race") || cvar("g_cts") || cvar("g_nexball")))
1174 req |= MAPINFO_FEATURE_WEAPONS;
1178 float MapInfo_CurrentGametype()
1180 if(cvar("g_domination"))
1181 return MAPINFO_TYPE_DOMINATION;
1182 else if(cvar("g_ctf"))
1183 return MAPINFO_TYPE_CTF;
1184 else if(cvar("g_runematch"))
1185 return MAPINFO_TYPE_RUNEMATCH;
1186 else if(cvar("g_tdm"))
1187 return MAPINFO_TYPE_TEAM_DEATHMATCH;
1188 else if(cvar("g_assault"))
1189 return MAPINFO_TYPE_ASSAULT;
1190 else if(cvar("g_lms"))
1191 return MAPINFO_TYPE_LMS;
1192 else if(cvar("g_arena"))
1193 return MAPINFO_TYPE_ARENA;
1194 else if(cvar("g_ca"))
1195 return MAPINFO_TYPE_CA;
1196 else if(cvar("g_keyhunt"))
1197 return MAPINFO_TYPE_KEYHUNT;
1198 else if(cvar("g_onslaught"))
1199 return MAPINFO_TYPE_ONSLAUGHT;
1200 else if(cvar("g_race"))
1201 return MAPINFO_TYPE_RACE;
1202 else if(cvar("g_nexball"))
1203 return MAPINFO_TYPE_NEXBALL;
1204 else if(cvar("g_cts"))
1205 return MAPINFO_TYPE_CTS;
1206 else if(cvar("g_freezetag"))
1207 return MAPINFO_TYPE_FREEZETAG;
1208 else if(cvar("g_keepaway"))
1209 return MAPINFO_TYPE_KEEPAWAY;
1211 return MAPINFO_TYPE_DEATHMATCH;
1214 float _MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
1216 if(!MapInfo_Get_ByName(s, 1, 0))
1218 if((MapInfo_Map_supportedGametypes & MapInfo_CurrentGametype()) == 0)
1220 if((MapInfo_Map_supportedFeatures & MapInfo_CurrentFeatures()) != MapInfo_CurrentFeatures())
1225 float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
1228 r = _MapInfo_CheckMap(s);
1229 MapInfo_ClearTemps();
1233 string MapInfo_GetGameTypeCvar(float t)
1237 case MAPINFO_TYPE_DEATHMATCH: return "g_dm";
1238 case MAPINFO_TYPE_TEAM_DEATHMATCH: return "g_tdm";
1239 case MAPINFO_TYPE_DOMINATION: return "g_domination";
1240 case MAPINFO_TYPE_CTF: return "g_ctf";
1241 case MAPINFO_TYPE_RUNEMATCH: return "g_runematch";
1242 case MAPINFO_TYPE_LMS: return "g_lms";
1243 case MAPINFO_TYPE_ARENA: return "g_arena";
1244 case MAPINFO_TYPE_CA: return "g_ca";
1245 case MAPINFO_TYPE_KEYHUNT: return "g_kh";
1246 case MAPINFO_TYPE_ASSAULT: return "g_assault";
1247 case MAPINFO_TYPE_ONSLAUGHT: return "g_onslaught";
1248 case MAPINFO_TYPE_RACE: return "g_race";
1249 case MAPINFO_TYPE_NEXBALL: return "g_nexball";
1250 case MAPINFO_TYPE_FREEZETAG: return "g_freezetag";
1251 case MAPINFO_TYPE_CTS: return "g_cts";
1252 case MAPINFO_TYPE_KEEPAWAY: return "g_keepaway";
1257 void MapInfo_SwitchGameType(float t)
1259 cvar_set("gamecfg", "0");
1260 cvar_set("g_dm", (t == MAPINFO_TYPE_DEATHMATCH) ? "1" : "0");
1261 cvar_set("g_tdm", (t == MAPINFO_TYPE_TEAM_DEATHMATCH) ? "1" : "0");
1262 cvar_set("g_domination", (t == MAPINFO_TYPE_DOMINATION) ? "1" : "0");
1263 cvar_set("g_ctf", (t == MAPINFO_TYPE_CTF) ? "1" : "0");
1264 cvar_set("g_runematch", (t == MAPINFO_TYPE_RUNEMATCH) ? "1" : "0");
1265 cvar_set("g_lms", (t == MAPINFO_TYPE_LMS) ? "1" : "0");
1266 cvar_set("g_arena", (t == MAPINFO_TYPE_ARENA) ? "1" : "0");
1267 cvar_set("g_ca", (t == MAPINFO_TYPE_CA) ? "1" : "0");
1268 cvar_set("g_keyhunt", (t == MAPINFO_TYPE_KEYHUNT) ? "1" : "0");
1269 cvar_set("g_assault", (t == MAPINFO_TYPE_ASSAULT) ? "1" : "0");
1270 cvar_set("g_onslaught", (t == MAPINFO_TYPE_ONSLAUGHT) ? "1" : "0");
1271 cvar_set("g_race", (t == MAPINFO_TYPE_RACE) ? "1" : "0");
1272 cvar_set("g_nexball", (t == MAPINFO_TYPE_NEXBALL) ? "1" : "0");
1273 cvar_set("g_cts", (t == MAPINFO_TYPE_CTS) ? "1" : "0");
1274 cvar_set("g_freezetag", (t == MAPINFO_TYPE_FREEZETAG) ? "1" : "0");
1275 cvar_set("g_keepaway", (t == MAPINFO_TYPE_KEEPAWAY) ? "1" : "0");
1278 void MapInfo_LoadMap(string s)
1280 MapInfo_Map_supportedGametypes = 0;
1281 // we shouldn't need this, as LoadMapSettings already fixes the gametype
1282 //if(!MapInfo_CheckMap(s))
1284 // print("EMERGENCY: can't play the selected map in the given game mode. Falling back to DM.\n");
1285 // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
1287 localcmd(strcat("\nsettemp_restore\nchangelevel ", s, "\n"));
1290 string MapInfo_ListAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
1295 // to make absolutely sure:
1296 MapInfo_Enumerate();
1297 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
1300 for(i = 0; i < MapInfo_count; ++i)
1301 out = strcat(out, " ", _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i)));
1302 return substring(out, 1, strlen(out) - 1);
1305 string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
1310 // to make absolutely sure:
1311 MapInfo_Enumerate();
1312 MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, pRequiredFlags, pForbiddenFlags, 0);
1315 for(i = 0; i < MapInfo_count; ++i)
1316 out = strcat(out, " ", _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i)));
1318 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
1320 return substring(out, 1, strlen(out) - 1);
1323 void MapInfo_LoadMapSettings(string s) // to be called from worldspawn
1326 if(!_MapInfo_CheckMap(s)) // with underscore, it keeps temps
1328 if(MapInfo_Map_supportedGametypes == 0)
1330 print("Mapinfo system is not functional at all. Assuming deathmatch.\n");
1331 MapInfo_Map_supportedGametypes = MAPINFO_TYPE_DEATHMATCH;
1332 _MapInfo_Map_ApplyGametypeEx("", t0, t0);
1333 return; // do not call Get_ByName!
1337 while(!(MapInfo_Map_supportedGametypes & 1))
1340 MapInfo_Map_supportedGametypes = floor(MapInfo_Map_supportedGametypes / 2);
1342 // t is now a supported mode!
1343 t0 = MapInfo_CurrentGametype();
1344 if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
1346 print("EMERGENCY: can't play the selected map in the given game mode. Working with only the override settings.\n");
1347 cvar_settemp_restore();
1348 _MapInfo_Map_ApplyGametypeEx("", t0, t0);
1349 return; // do not call Get_ByName!
1353 print("EMERGENCY: can't play the selected map in the given game mode. Falling back to a supported mode.\n");
1354 MapInfo_SwitchGameType(t);
1357 cvar_settemp_restore();
1358 MapInfo_Get_ByName(s, 1, MapInfo_CurrentGametype());
1361 void MapInfo_ClearTemps()
1363 MapInfo_Map_bspname = string_null;
1364 MapInfo_Map_title = string_null;
1365 MapInfo_Map_titlestring = string_null;
1366 MapInfo_Map_description = string_null;
1367 MapInfo_Map_author = string_null;
1368 MapInfo_Map_clientstuff = string_null;
1369 MapInfo_Map_supportedGametypes = 0;
1370 MapInfo_Map_supportedFeatures = 0;
1373 void MapInfo_Shutdown()
1375 MapInfo_ClearTemps();
1376 MapInfo_Filter_Free();
1377 MapInfo_Cache_Destroy();
1378 if(_MapInfo_globopen)
1380 search_end(_MapInfo_globhandle);
1381 _MapInfo_globhandle = -1;
1382 _MapInfo_globopen = FALSE;
1386 float MapInfo_ForbiddenFlags()
1389 f = MAPINFO_FLAG_FORBIDDEN;
1392 if not(cvar("g_maplist_allow_hidden"))
1394 f |= MAPINFO_FLAG_HIDDEN;
1396 if not(cvar("g_maplist_allow_frustrating"))
1397 f |= MAPINFO_FLAG_FRUSTRATING;
1402 float MapInfo_RequiredFlags()
1407 if(cvar("g_maplist_allow_frustrating") > 1)
1408 f |= MAPINFO_FLAG_FRUSTRATING;