12 #define WARN_COND false 15 #define WARN_COND (!autocvar_g_mapinfo_ignore_warnings && MapInfo_Map_bspname == mi_shortname) 160 return _MapInfo_FilterGametype(pGametype.m_flags, pFeatures, pFlagsRequired, pFlagsForbidden, pAbortOnGenerate);
176 LOG_TRACE(
"Autogenerated a .mapinfo, doing the rest later.");
210 if((
strstrofs(strtolower(title), strtolower(sf), 0)) >= 0)
214 MapInfo_count = j + 1;
239 for(
float i = 0; i < l; ++i)
242 if((ch !=
" ") && (ch !=
"\""))
244 for(
float j = l - i - 1; j > 0; --j)
247 if(ch !=
" ")
if(ch !=
"\"")
272 float diameter, spawnpoints;
278 fn =
strcat(
"maps/", pFilename,
".ent");
283 fn =
strcat(
"maps/", pFilename,
".bsp");
288 LOG_INFO(
"Analyzing ", fn,
" to generate initial mapinfo");
301 if (!((s =
fgets(fh))))
303 if(inWorldspawn == 1)
310 if(k ==
"classname" && v ==
"worldspawn")
312 else if(k ==
"author")
314 else if(k ==
"_description")
316 else if(k ==
"music")
318 else if(k ==
"noise")
320 else if(k ==
"message")
337 mapMins.x =
min(mapMins.x, o.x);
338 mapMins.y =
min(mapMins.y, o.y);
339 mapMins.z =
min(mapMins.z, o.z);
340 mapMaxs.x =
max(mapMaxs.x, o.x);
341 mapMaxs.y =
max(mapMaxs.y, o.y);
342 mapMaxs.z =
max(mapMaxs.z, o.z);
344 else if(k ==
"race_place")
349 else if(k ==
"classname")
351 if(v ==
"info_player_team1")
353 else if(v ==
"info_player_team2")
355 else if(v ==
"info_player_start")
357 else if(v ==
"info_player_deathmatch")
359 else if(v ==
"weapon_nex")
361 else if(v ==
"weapon_railgun")
371 else if(v ==
"target_music" || v ==
"trigger_music")
374 FOREACH(Gametypes,
true, it.m_generate_mapinfo(it, v));
380 LOG_WARN(fn,
" ended still in worldspawn, BUG");
383 diameter =
vlen(mapMaxs - mapMins);
385 int twoBaseModes = 0;
386 FOREACH(Gametypes, it.m_isTwoBaseMode(), twoBaseModes |= it.m_flags);
436 if(!(pThisType.m_flags & pWantedType.m_flags))
442 if(!pWantedType.
frags)
459 if(pWantedType.m_setTeams)
463 pWantedType.m_setTeams(sa);
468 if(pWantedType == MAPINFO_TYPE_RACE)
473 cvar_set(
"g_race_qualifying_timelimit", sa);
478 if(
cvar(
"g_race_teams") < 2)
484 if(
cvar(
"g_race_teams") >= 2)
489 if(!pWantedType.
frags)
504 return t ? t.model2 :
"";
509 return t ? t.
team :
false;
515 if (!(pThisType.m_flags & pWantedType.m_flags))
530 if (sa ==
"")
continue;
557 fraglimit_normal =
v;
560 case "teampointlimit":
572 FOREACH(Gametypes,
true, handled |= it.m_parse_mapinfo(k, v));
577 if (pWantedType == MAPINFO_TYPE_RACE &&
cvar(
"g_race_teams") >= 2)
580 cvar_set(
"fraglimit", fraglimit_teams);
585 cvar_set(
"fraglimit", fraglimit_normal);
591 string replacement =
"";
594 case "nexball": replacement =
"nb";
break;
595 case "freezetag": replacement =
"ft";
break;
596 case "keepaway": replacement =
"ka";
break;
597 case "invasion": replacement =
"inv";
break;
598 case "assault": replacement =
"as";
break;
599 case "race": replacement =
"rc";
break;
601 if (replacement !=
"")
604 LOG_WARNF(
"MapInfo_Type_FromString (probably %s): using deprecated name '%s'. Should use '%s'.",
MapInfo_Map_bspname, gtype, replacement);
607 FOREACH(Gametypes, it.mdl == gtype,
return it);
613 return t ? t.gametype_description :
"";
618 return t ? t.mdl :
"";
624 return t ? t.message : _(
"@!#%'n Tuba Throwing");
632 s = strreplace(
"\t",
"", s);
671 LOG_WARN(
"Map ", pFilename,
" references not existing config file ", s);
675 while((s =
fgets(fh)))
677 s = strreplace(
"\t",
"", s);
699 LOG_WARN(
"Map ", pFilename,
" uses too many levels of inclusion");
707 LOG_WARN(
"Map ", pFilename,
" contains a potentially harmful setting, ignored");
712 LOG_WARN(
"Map ", pFilename,
" contains a denied setting, ignored");
718 LOG_TRACE(
"Applying temporary setting ", t,
" := ", s);
720 if(
cvar(
"g_campaign"))
728 LOG_TRACE(
"Applying temporary client setting ", t,
" := ", s);
739 fn = strreplace(
"_",
"", fn);
740 fn = strreplace(
"-",
"", fn);
743 t = strreplace(
":",
"", t);
744 t = strreplace(
" ",
"", t);
745 t = strreplace(
"_",
"", t);
746 t = strreplace(
"-",
"", t);
747 t = strreplace(
"'",
"", t);
748 t = strdecolorize(t);
772 LOG_WARN(
"Invalid character in map name, ignored");
776 if(pGametypeToSet ==
NULL)
785 fn =
strcat(
"maps/", pFilename,
".mapinfo");
789 fn =
strcat(
"maps/autogenerated/", pFilename,
".mapinfo");
827 fputs(fh,
"has weapons\n");
829 fputs(fh,
"// uncomment this if you added weapon pickups: has weapons\n");
831 fputs(fh,
"has turrets\n");
833 fputs(fh,
"// uncomment this if you added turrets: has turrets\n");
835 fputs(fh,
"has vehicles\n");
837 fputs(fh,
"// uncomment this if you added vehicles: has vehicles\n");
839 fputs(fh,
"frustrating\n");
842 fputs(fh, sprintf(
"gametype %s // defaults: %s\n", MapInfo_Type_ToString(it), _MapInfo_GetDefaultEx(it)));
845 fputs(fh,
"// optional: fog density red green blue alpha mindist maxdist\n");
846 fputs(fh,
"// optional: settemp_for_type (all|gametypename) cvarname value\n");
847 fputs(fh,
"// optional: clientsettemp_for_type (all|gametypename) cvarname value\n");
848 fputs(fh,
"// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
849 fputs(fh,
"// optional: hidden\n");
856 error(
"... but I just wrote it!");
860 LOG_WARN(
"autogenerated mapinfo file ", fn,
" has been loaded; please edit that file and move it to maps/", pFilename,
".mapinfo");
866 if (!((s =
fgets(fh))))
886 else if(t ==
"description")
888 else if(t ==
"author")
899 LOG_WARN(
"Map ", pFilename,
" supports unknown feature ", t,
", ignored");
901 else if(t ==
"hidden")
905 else if(t ==
"forbidden")
909 else if(t ==
"frustrating")
913 else if(t ==
"noautomaplist")
917 else if(t ==
"gameversion_min")
931 LOG_DEBUG(
"Map ", pFilename,
" supports unknown game type ", t,
", ignored");
933 else if(t ==
"gametype")
940 LOG_DEBUG(
"Map ", pFilename,
" supports unknown game type ", t,
", ignored");
953 LOG_WARN(
"Map ", pFilename,
" contains an incorrect size line (not enough params), syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z");
961 LOG_WARN(
"Map ", pFilename,
" contains an incorrect size line (too many params), syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z");
965 if(a >= d || b >= e || c >= f)
968 LOG_WARN(
"Map ", pFilename,
" contains an incorrect size line, mins have to be < maxs");
982 else if(t ==
"settemp_for_type")
985 bool all = t ==
"all";
996 LOG_DEBUG(
"Map ", pFilename,
" has a setting for unknown game type ", t,
", ignored");
999 else if(t ==
"clientsettemp_for_type")
1002 bool all = t ==
"all";
1013 LOG_DEBUG(
"Map ", pFilename,
" has a client setting for unknown game type ", t,
", ignored");
1021 LOG_WARN(
"Map ", pFilename,
" contains a potentially harmful fog setting, ignored");
1026 else if(t ==
"cdtrack")
1040 LOG_WARN(
"Map ", pFilename,
" contains a potentially harmful cdtrack, ignored");
1049 LOG_WARN(
"Map ", pFilename,
" provides unknown info item ", t,
", ignored");
1064 LOG_WARN(
"Map ", pFilename,
" supports no game types, ignored");
1077 error(
"Can't select the requested game type. This should never happen as the caller should prevent it!\n");
1097 m =
floor((l + r) / 2);
1144 if(!(
cvar(
"g_instagib") ||
cvar(
"g_overkill") ||
cvar(
"g_nix") ||
cvar(
"g_weaponarena") || !
cvar(
"g_pickup_items") || !
cvar(
"g_melee_only")
1153 FOREACH(Gametypes,
cvar(it.netname) && it != prev,
return it);
1154 return prev ?
prev : MAPINFO_TYPE_DEATHMATCH;
1180 FOREACH(Gametypes,
true,
cvar_set(it.netname, (it == t) ?
"1" :
"0"));
1247 if(
cvar(
"g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
1249 LOG_SEVERE(
"can't play the selected map in the given game mode. Working with only the override settings.");
1257 FOREACH(Gametypes, it.m_priority == 2,
1259 MapInfo_Map_supportedGametypes |= it.m_flags;
1260 RandomSelection_AddEnt(it, 1, 1);
1264 LOG_SEVEREF(
"Mapinfo system is not functional at all. Falling back to a preferred mode (%s).", t.mdl);
1284 RandomSelection_AddEnt(it, 1, it.m_priority);
1290 LOG_WARNF(
"can't play the selected map in the given game mode (%s). Falling back to a supported mode (%s).", t_prev.mdl, t.mdl);
1294 LOG_WARNF(
"the selected map lacks features required by current settings; playing anyway.");
1329 if (!
cvar(
"g_maplist_allow_hidden"))
1333 if (!
cvar(
"g_maplist_allow_frustrating"))
1343 if(
cvar(
"g_maplist_allow_frustrating") > 1)
string MapInfo_Type_ToString(Gametype t)
int MapInfo_RequiredFlags()
ERASEABLE int db_create()
ERASEABLE void db_put(int db, string key, string value)
float _MapInfo_CheckMap(string s, bool gametype_only)
float MapInfo_Cache_Retrieve(string map)
float MapInfo_FilterList_Lookup(float i)
void _MapInfo_Map_Reset()
void MapInfo_LoadMapSettings(string s)
string MapInfo_Map_clientstuff
float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gametype pGametypeToSet)
float _MapInfo_GetTeamPlayBool(Gametype t)
int MapInfo_Map_supportedFeatures
float cvar_settemp(string tmp_cvar, string tmp_value)
int _MapInfo_Cache_Active
ERASEABLE void RandomSelection_Init()
const int MAPINFO_FEATURE_WEAPONS
Gametype MapInfo_LoadedGametype
void MapInfo_LoadMapSettings_SaveGameType(Gametype t)
ERASEABLE string cdr(string s)
returns all but first word
string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
string MapInfo_Type_ToText(Gametype t)
ERASEABLE void db_close(int db)
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
bool MapInfo_Get_ByID(int i)
int MapInfo_ForbiddenFlags()
ERASEABLE string car(string s)
returns first word
string MapInfo_Map_description
string _MapInfo_GlobItem(float i)
int _MapInfo_Cache_DB_NameToIndex
float matchacl(string acl, string str)
float _MapInfo_globhandle
string MapInfo_FindName_match
string MapInfo_Map_author
float _MapInfo_Generate(string pFilename)
int MapInfo_Map_supportedGametypes
void MapInfo_Cache_Destroy()
Gametype MapInfo_Type_FromString(string gtype, bool dowarn)
Gametype MapInfo_CurrentGametype()
void MapInfo_Filter_Free()
void MapInfo_Cache_Create()
bool frags
does this gametype use a point limit?
int MapInfo_CurrentFeatures()
const int MAPINFO_FEATURE_VEHICLES
string MapInfo_ListAllowedMaps(Gametype type, float pRequiredFlags, float pForbiddenFlags)
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"))
entity RandomSelection_chosen_ent
void _MapInfo_FilterList_swap(float i, float j, entity pass)
int MapInfo_Get_ByName(string pFilename, float pAllowGenerate, Gametype pGametypeToSet)
#define startsWith(haystack, needle)
void _MapInfo_Map_ApplyGametype(string s, Gametype pWantedType, Gametype pThisType, int load_default)
ERASEABLE bool startsWithNocase(string haystack, string needle)
string m_legacydefaults
DO NOT USE, this is compatibility for legacy maps!
bool autocvar_g_mapinfo_ignore_warnings
const int MAPINFO_FLAG_FORBIDDEN
ERASEABLE string db_get(int db, string key)
bool team
does this gametype support teamplay?
float MapInfo_CheckMap(string s)
void MapInfo_ClearTemps()
int _MapInfo_Cache_Buf_IndexToMapData
float _MapInfo_filtered_allocated
float MapInfo_isRedundant(string fn, string t)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float MapInfo_FindName_firstResult
float MapInfo_FindName(string s)
string MapInfo_Type_Description(Gametype t)
void MapInfo_Cache_Store()
ERASEABLE bool cvar_value_issafe(string s)
#define MAPINFO_SETTEMP_ACL_SYSTEM
void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThisType)
string MapInfo_Map_bspname
void MapInfo_FilterString(string sf)
const int MAPINFO_FLAG_HIDDEN
const int MAPINFO_FLAG_FRUSTRATING
float _MapInfo_FilterList_cmp(float i, float j, entity pass)
string MapInfo_FixName(string s)
int cvar_settemp_restore()
const int MAPINFO_FEATURE_TURRETS
float _MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
#define MAPINFO_SETTEMP_ACL_USER
void MapInfo_LoadMap(string s, float reinit)
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
string _MapInfo_GetDefaultEx(Gametype t)
#define pass(name, colormin, colormax)
const int MAPINFO_FEATURE_MONSTERS
string MapInfo_BSPName_ByID(float i)
void MapInfo_SwitchGameType(Gametype t)
#define FOREACH(list, cond, body)
const int MAPINFO_FLAG_NOAUTOMAPLIST
string _MapInfo_GetDefault(Gametype t)
void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
void MapInfo_Cache_Invalidate()
string _MapInfo_Map_worldspawn_music
string MapInfo_Map_titlestring