X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapinfo.qc;h=3d06854578acbda85607a119a59bea958e9c4d4d;hp=1b1dc154709973e67e35cc960cf5902b2bc8d7e0;hb=d6fa4cbca32e3eb9a1c21a27e97b0c6cbc970fd5;hpb=7d48e976c8a9b3f80350b2ad41d9feec2797cf76 diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 1b1dc15470..3d06854578 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -84,7 +84,7 @@ float MapInfo_Cache_Retrieve(string map) // GLOB HANDLING (for all BSP files) float _MapInfo_globopen; -float _MapInfo_globcount; +float _MapInfo_globcount; float _MapInfo_globhandle; string _MapInfo_GlobItem(float i) { @@ -141,7 +141,7 @@ float _MapInfo_FilterList_cmp(float i, float j, entity pass) float MapInfo_FilterGametype(float pGametype, float pFeatures, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate) { float i, j; - if not(_MapInfo_filtered_allocated) + if (!_MapInfo_filtered_allocated) { _MapInfo_filtered_allocated = 1; _MapInfo_filtered = buf_create(); @@ -164,7 +164,7 @@ float MapInfo_FilterGametype(float pGametype, float pFeatures, float pFlagsRequi } MapInfo_count = j + 1; MapInfo_ClearTemps(); - + // sometimes the glob isn't sorted nicely, so fix it here... heapsort(MapInfo_count, _MapInfo_FilterList_swap, _MapInfo_FilterList_cmp, world); @@ -257,7 +257,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp for(;;) { - if not((s = fgets(fh))) + if (!((s = fgets(fh)))) break; if(inWorldspawn == 1) if(startsWith(s, "}")) @@ -313,6 +313,8 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF; else if(v == "team_CTF_blueflag") MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF; + else if(v == "invasion_spawnpoint") + MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_INVASION; else if(v == "target_assault_roundend") MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ASSAULT; else if(v == "onslaught_generator") @@ -341,6 +343,8 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_TURRETS; else if(startsWith(v, "vehicle_")) MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_VEHICLES; + else if(startsWith(v, "monster_")) + MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_MONSTERS; else if(v == "target_music" || v == "trigger_music") _MapInfo_Map_worldspawn_music = string_null; // don't use regular BGM } @@ -370,8 +374,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_FREEZETAG; MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CA; } - if( diameter < 4096) - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ARENA; if(spawnpoints >= 12 && diameter > 5120) MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_KEYHUNT; } @@ -379,7 +381,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE) if(!spawnplaces) { - MapInfo_Map_supportedGametypes &~= MAPINFO_TYPE_RACE; + MapInfo_Map_supportedGametypes &= ~MAPINFO_TYPE_RACE; MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS; } @@ -416,7 +418,6 @@ string _MapInfo_GetDefault(float t) case MAPINFO_TYPE_DOMINATION: return "200 20 0"; case MAPINFO_TYPE_CTF: return "300 20 10 0"; case MAPINFO_TYPE_LMS: return "9 20 0"; - case MAPINFO_TYPE_ARENA: return "10 20 0"; case MAPINFO_TYPE_CA: return "10 20 0"; case MAPINFO_TYPE_KEYHUNT: return "1000 20 3 0"; case MAPINFO_TYPE_ASSAULT: return "20 0"; @@ -442,7 +443,7 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl if(load_default) _MapInfo_Map_ApplyGametype(_MapInfo_GetDefault(pThisType), pWantedType, pThisType, FALSE); - + if(pWantedType == MAPINFO_TYPE_ASSAULT || pWantedType == MAPINFO_TYPE_ONSLAUGHT || pWantedType == MAPINFO_TYPE_RACE || pWantedType == MAPINFO_TYPE_CTS) // these modes don't use fraglimit { cvar_set("fraglimit", "0"); @@ -509,7 +510,7 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl s = cdr(s); } */ - + // rc = timelimit timelimit_qualification laps laps_teamplay if(pWantedType == MAPINFO_TYPE_RACE) { @@ -603,14 +604,11 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) p = strstrofs(sa, "=", 0); if(p < 0) { - k = "timelimit"; - v = s; - } - else - { - k = substring(sa, 0, p); - v = substring(sa, p+1, -1); + print("Invalid gametype setting in mapinfo for gametype ", MapInfo_Type_ToString(pWantedType), ": ", sa, "\n"); + continue; } + k = substring(sa, 0, p); + v = substring(sa, p+1, -1); if(k == "timelimit") { @@ -635,6 +633,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) cvar_set("g_freezetag_teams", v); cvar_set("g_keyhunt_teams", v); cvar_set("g_domination_default_teams", v); + cvar_set("g_invasion_teams", v); } else if(k == "qualifying_timelimit") { @@ -646,7 +645,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) } else { - print("Invalid gametype key in mapinfo: ", k, "\n"); + print("Invalid gametype setting in mapinfo for gametype ", MapInfo_Type_ToString(pWantedType), ": ", sa, "\n"); } } @@ -683,6 +682,12 @@ float MapInfo_Type_FromString(string t) t = "ka"; print("'. Should use '", t, "'.\n"); } + if(t == "invasion") + { + print("MapInfo_Type_FromString (probably ", MapInfo_Map_bspname, "): using deprecated name '", t); + t = "inv"; + print("'. Should use '", t, "'.\n"); + } if(t == "all") return MAPINFO_TYPE_ALL; for(e = MapInfo_Type_first; e; e = e.enemy) @@ -691,10 +696,19 @@ float MapInfo_Type_FromString(string t) return 0; } +string MapInfo_Type_Description(float t) +{ + entity e; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.items) + return e.gametype_description; + return ""; +} + string MapInfo_Type_ToString(float t) { entity e; - if(t == MAPINFO_TYPE_ALL) + if(t == MAPINFO_TYPE_ALL) return "all"; for(e = MapInfo_Type_first; e; e = e.enemy) if(t == e.items) @@ -708,6 +722,7 @@ string MapInfo_Type_ToText(float t) for(e = MapInfo_Type_first; e; e = e.enemy) if(t == e.items) return e.message; + /* xgettext:no-c-format */ return _("@!#%'n Tuba Throwing"); } @@ -734,12 +749,12 @@ void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, o = strstrofs(s, "\"", 0); if(o >= 0) s = substring(s, 0, o); - + // remove // comments o = strstrofs(s, "//", 0); if(o >= 0) s = substring(s, 0, o); - + // remove trailing spaces while(substring(s, -1, 1) == " ") s = substring(s, 0, -2); @@ -755,7 +770,7 @@ void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, { for(;;) { - if not((s = fgets(fh))) + if (!((s = fgets(fh)))) break; // catch different sorts of comments @@ -783,9 +798,9 @@ void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, } else if(t == "") print("Map ", pFilename, " contains a potentially harmful setting, ignored\n"); - else if not(cvar_value_issafe(t)) + else if (!cvar_value_issafe(t)) print("Map ", pFilename, " contains a potentially harmful setting, ignored\n"); - else if not (cvar_value_issafe(s)) + else if (!cvar_value_issafe(s)) print("Map ", pFilename, " contains a potentially harmful setting, ignored\n"); else if(matchacl(MAPINFO_SETTEMP_ACL_SYSTEM, t) <= 0) print("Map ", pFilename, " contains a potentially harmful setting, ignored\n"); @@ -912,7 +927,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo else fputs(fh, "// uncomment this if you added turrets: has turrets\n"); if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_VEHICLES) - fputs(fh, "has weapons\n"); + fputs(fh, "has vehicles\n"); else fputs(fh, "// uncomment this if you added vehicles: has vehicles\n"); if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) @@ -945,7 +960,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo _MapInfo_Map_Reset(); for(;;) { - if not((s = fgets(fh))) + if (!((s = fgets(fh)))) break; // catch different sorts of comments @@ -975,6 +990,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo if (t == "weapons") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS; else if(t == "turrets") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_TURRETS; else if(t == "vehicles") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_VEHICLES; + else if(t == "monsters") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_MONSTERS; else if(t == "new_toys") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS; else dprint("Map ", pFilename, " supports unknown feature ", t, ", ignored\n"); @@ -1077,7 +1093,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo } else if(t == "fog") { - if not(cvar_value_issafe(s)) + if (!cvar_value_issafe(s)) print("Map ", pFilename, " contains a potentially harmful fog setting, ignored\n"); else MapInfo_Map_fog = s; @@ -1087,7 +1103,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo t = car(s); s = cdr(s); if(pGametypeToSet) // FIXME is this check right here? { - if not(cvar_value_issafe(t)) + if (!cvar_value_issafe(t)) print("Map ", pFilename, " contains a potentially harmful cdtrack, ignored\n"); else MapInfo_Map_clientstuff = strcat( @@ -1120,7 +1136,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype if(cvar("g_tdm_on_dm_maps")) { // if this is set, all DM maps support TDM too - if not(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH) + if (!(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH)) if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH) _MapInfo_Map_ApplyGametypeEx ("", pGametypeToSet, MAPINFO_TYPE_TEAM_DEATHMATCH); } @@ -1129,7 +1145,8 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype { if(!(MapInfo_Map_supportedGametypes & pGametypeToSet)) { - error("Can't select the requested game type. This should never happen as the caller should prevent it!\n"); + //error("Can't select the requested game type. This should never happen as the caller should prevent it!\n"); + return 0; //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH); //return; } @@ -1250,7 +1267,7 @@ void MapInfo_LoadMap(string s, float reinit) // print("EMERGENCY: can't play the selected map in the given game mode. Falling back to DM.\n"); // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH); //} - + cvar_settemp_restore(); if(reinit) localcmd(strcat("\nmap ", s, "\n")); @@ -1258,14 +1275,14 @@ void MapInfo_LoadMap(string s, float reinit) localcmd(strcat("\nchangelevel ", s, "\n")); } -string MapInfo_ListAllowedMaps(float pRequiredFlags, float pForbiddenFlags) +string MapInfo_ListAllowedMaps(float type, float pRequiredFlags, float pForbiddenFlags) { string out; float i; // to make absolutely sure: MapInfo_Enumerate(); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0); + MapInfo_FilterGametype(type, MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0); out = ""; for(i = 0; i < MapInfo_count; ++i) @@ -1368,11 +1385,11 @@ float MapInfo_ForbiddenFlags() f = MAPINFO_FLAG_FORBIDDEN; #ifndef MENUQC - if not(cvar("g_maplist_allow_hidden")) + if (!cvar("g_maplist_allow_hidden")) #endif f |= MAPINFO_FLAG_HIDDEN; - if not(cvar("g_maplist_allow_frustrating")) + if (!cvar("g_maplist_allow_frustrating")) f |= MAPINFO_FLAG_FRUSTRATING; return f;