X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapinfo.qc;h=9dd02ca4c2955e25b1c1347343ee0a7e62d9a7b7;hb=616650bb18362024afeed71fed91d33dc1708d09;hp=366538de71b0346b013d36b32fd7a3315fa0e1ad;hpb=cb67dc78c81fe79e704952b6cd056353af24bb68;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 366538de7..9dd02ca4c 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -78,6 +78,7 @@ float MapInfo_Cache_Retrieve(string map) MapInfo_Map_supportedGametypes = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i)); MapInfo_Map_supportedFeatures = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i)); MapInfo_Map_flags = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i)); + return 1; } @@ -326,6 +327,10 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp { } else if(startsWith(v, "weapon_")) MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS; + else if(startsWith(v, "turret_")) + MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_TURRETS; + else if(startsWith(v, "vehicle_")) + MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_VEHICLES; else if(v == "target_music" || v == "trigger_music") _MapInfo_Map_worldspawn_music = string_null; // don't use regular BGM } @@ -467,8 +472,7 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl { sa = car(s); if(sa != "") - if(cvar("g_ctf_win_mode") < 2) - cvar_set("fraglimit", sa); + cvar_set("fraglimit", sa); s = cdr(s); } @@ -530,26 +534,11 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl string _MapInfo_GetDefaultEx(float t) { - switch(t) - { - case MAPINFO_TYPE_DEATHMATCH: return "timelimit=20 pointlimit=30 leadlimit=0"; - case MAPINFO_TYPE_TEAM_DEATHMATCH: return "timelimit=20 pointlimit=50 teams=2 leadlimit=0"; - case MAPINFO_TYPE_DOMINATION: return "timelimit=20 pointlimit=200 teams=2 leadlimit=0"; - case MAPINFO_TYPE_CTF: return "timelimit=20 pointlimit=300 caplimit=10 leadlimit=0"; - case MAPINFO_TYPE_RUNEMATCH: return "timelimit=20 pointlimit=200 leadlimit=0"; - case MAPINFO_TYPE_LMS: return "timelimit=20 lives=9 leadlimit=0"; - case MAPINFO_TYPE_ARENA: return "timelimit=20 pointlimit=10 leadlimit=0"; - case MAPINFO_TYPE_CA: return "timelimit=20 pointlimit=10 leadlimit=0"; - case MAPINFO_TYPE_KEYHUNT: return "timelimit=20 pointlimit=1000 teams=3 leadlimit=0"; - case MAPINFO_TYPE_ASSAULT: return "timelimit=20"; - case MAPINFO_TYPE_RACE: return "timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0"; - case MAPINFO_TYPE_ONSLAUGHT: return "timelimit=20"; - case MAPINFO_TYPE_NEXBALL: return "timelimit=20 pointlimit=5 leadlimit=0"; - case MAPINFO_TYPE_CTS: return "timelimit=20 skill=-1"; - case MAPINFO_TYPE_FREEZETAG: return "timelimit=20 pointlimit=10 teams=2 leadlimit=0"; - case MAPINFO_TYPE_KEEPAWAY: return "timelimit=20 pointlimit=30"; - default: return ""; - } + entity e; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.weapons) + return e.model2; + return ""; } void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) @@ -557,7 +546,6 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) string sa, k, v; float p; string fraglimit_normal; - string fraglimit_caps; string fraglimit_teams; MapInfo_Map_supportedGametypes |= pThisType; @@ -575,7 +563,6 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) cvar_set("g_race_qualifying_timelimit", cvar_defstring("g_race_qualifying_timelimit")); fraglimit_normal = string_null; - fraglimit_caps = string_null; fraglimit_teams = string_null; s = strcat(_MapInfo_GetDefaultEx(pWantedType), " ", s); @@ -607,14 +594,10 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) { cvar_set("leadlimit", v); } - else if(k == "pointlimit" || k == "fraglimit" || k == "lives" || k == "laplimit") + else if(k == "pointlimit" || k == "fraglimit" || k == "lives" || k == "laplimit" || k == "caplimit") { fraglimit_normal = v; } - else if(k == "caplimit") - { - fraglimit_caps = v; - } else if(k == "teampointlimit" || k == "teamlaplimit") { fraglimit_teams = v; @@ -639,12 +622,7 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) } } - if(pWantedType == MAPINFO_TYPE_CTF && cvar("g_ctf_win_mode") < 2) - { - if(fraglimit_caps) - cvar_set("fraglimit", fraglimit_caps); - } - else if(pWantedType == MAPINFO_TYPE_RACE && cvar("g_race_teams") >= 2) + if(pWantedType == MAPINFO_TYPE_RACE && cvar("g_race_teams") >= 2) { if(fraglimit_teams) cvar_set("fraglimit", fraglimit_teams); @@ -658,46 +636,51 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) float MapInfo_Type_FromString(string t) { - if (t == "dm") return MAPINFO_TYPE_DEATHMATCH; - else if(t == "tdm") return MAPINFO_TYPE_TEAM_DEATHMATCH; - else if(t == "dom") return MAPINFO_TYPE_DOMINATION; - else if(t == "ctf") return MAPINFO_TYPE_CTF; - else if(t == "rune") return MAPINFO_TYPE_RUNEMATCH; - else if(t == "lms") return MAPINFO_TYPE_LMS; - else if(t == "arena") return MAPINFO_TYPE_ARENA; - else if(t == "ca") return MAPINFO_TYPE_CA; - else if(t == "kh") return MAPINFO_TYPE_KEYHUNT; - else if(t == "as") return MAPINFO_TYPE_ASSAULT; - else if(t == "ons") return MAPINFO_TYPE_ONSLAUGHT; - else if(t == "rc") return MAPINFO_TYPE_RACE; - else if(t == "nexball") return MAPINFO_TYPE_NEXBALL; - else if(t == "cts") return MAPINFO_TYPE_CTS; - else if(t == "freezetag") return MAPINFO_TYPE_FREEZETAG; - else if(t == "keepaway") return MAPINFO_TYPE_KEEPAWAY; - else if(t == "all") return MAPINFO_TYPE_ALL; - else return 0; + entity e; + if(t == "nexball") + { + print("MapInfo_Type_FromString (probably ", MapInfo_Map_bspname, "): using deprecated name '", t); + t = "nb"; + print("'. Should use '", t, "'.\n"); + } + if(t == "freezetag") + { + print("MapInfo_Type_FromString (probably ", MapInfo_Map_bspname, "): using deprecated name '", t); + t = "ft"; + print("'. Should use '", t, "'.\n"); + } + if(t == "keepaway") + { + print("MapInfo_Type_FromString (probably ", MapInfo_Map_bspname, "): using deprecated name '", t); + t = "ka"; + print("'. Should use '", t, "'.\n"); + } + if(t == "all") + return MAPINFO_TYPE_ALL; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.mdl) + return e.weapons; + return 0; } string MapInfo_Type_ToString(float t) { - if (t == MAPINFO_TYPE_DEATHMATCH) return "dm"; - else if(t == MAPINFO_TYPE_TEAM_DEATHMATCH) return "tdm"; - else if(t == MAPINFO_TYPE_DOMINATION) return "dom"; - else if(t == MAPINFO_TYPE_CTF) return "ctf"; - else if(t == MAPINFO_TYPE_RUNEMATCH) return "rune"; - else if(t == MAPINFO_TYPE_LMS) return "lms"; - else if(t == MAPINFO_TYPE_ARENA) return "arena"; - else if(t == MAPINFO_TYPE_CA) return "ca"; - else if(t == MAPINFO_TYPE_KEYHUNT) return "kh"; - else if(t == MAPINFO_TYPE_ASSAULT) return "as"; - else if(t == MAPINFO_TYPE_ONSLAUGHT) return "ons"; - else if(t == MAPINFO_TYPE_RACE) return "rc"; - else if(t == MAPINFO_TYPE_NEXBALL) return "nexball"; - else if(t == MAPINFO_TYPE_CTS) return "cts"; - else if(t == MAPINFO_TYPE_FREEZETAG) return "freezetag"; - else if(t == MAPINFO_TYPE_KEEPAWAY) return "keepaway"; - else if(t == MAPINFO_TYPE_ALL) return "all"; - else return ""; + entity e; + if(t == MAPINFO_TYPE_ALL) + return "all"; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.weapons) + return e.mdl; + return ""; +} + +string MapInfo_Type_ToText(float t) +{ + entity e; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.weapons) + return e.message; + return _("@!#%'n Tuba Throwing"); } void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse) @@ -810,6 +793,7 @@ float MapInfo_isRedundant(string fn, string t) t = strreplace(":", "-", t); t = strreplace(" ", "-", t); t = strreplace("_", "-", t); + t = strreplace("'", "-", t); if(!strcasecmp(fn, t)) return TRUE; @@ -825,7 +809,7 @@ float MapInfo_isRedundant(string fn, string t) } // load info about a map by name into the MapInfo_Map_* globals -float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet) +float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, float pGametypeToSet) { string fn; string s, t; @@ -895,6 +879,14 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype fputs(fh, "has weapons\n"); else fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n"); + if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_TURRETS) + fputs(fh, "has turrets\n"); + else + fputs(fh, "// uncomment this if you added turrets: has turrets\n"); + if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_VEHICLES) + fputs(fh, "has weapons\n"); + else + fputs(fh, "// uncomment this if you added vehicles: has vehicles\n"); if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) fputs(fh, "frustrating\n"); @@ -953,6 +945,8 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype { t = car(s); s = cdr(s); 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 == "new_toys") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS; else dprint("Map ", pFilename, " supports unknown feature ", t, ", ignored\n"); @@ -1073,29 +1067,43 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype } fclose(fh); - if(pGametypeToSet) - { - if(!(MapInfo_Map_supportedGametypes & pGametypeToSet)) - { - error("Can't select the requested game type. This should never happen as the caller should prevent it!\n"); - //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH); - //return; - } - } - - if(MapInfo_Map_titlestring == "