X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapinfo.qc;h=82c5673d8b44ee22cb479844517c44e8e30cea73;hb=315ab0f2f959b04e5a10f2d98ab95656eab74ee3;hp=270a30147724bf61b66e7c8893897c24d52b7803;hpb=577ea550e7e877bc2d8b8a0f382e337d3fa8beed;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 270a30147..82c5673d8 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -38,7 +38,7 @@ void MapInfo_Cache_Store() return; s = db_get(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname); - if(!s) // empty string is NOT valid here! + if(s == "") { i = buf_getsize(_MapInfo_Cache_Buf_IndexToMapData); db_put(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname, ftos(i)); @@ -65,7 +65,7 @@ float MapInfo_Cache_Retrieve(string map) return 0; s = db_get(_MapInfo_Cache_DB_NameToIndex, map); - if(!s) + if(s == "") return 0; i = stof(s); @@ -89,6 +89,8 @@ float _MapInfo_globhandle; string _MapInfo_GlobItem(float i) { string s; + if(!_MapInfo_globopen) + return string_null; s = search_getfilename(_MapInfo_globhandle, i); return substring(s, 5, strlen(s) - 9); // without maps/ and .bsp } @@ -96,11 +98,19 @@ string _MapInfo_GlobItem(float i) void MapInfo_Enumerate() { if(_MapInfo_globopen) + { search_end(_MapInfo_globhandle); + _MapInfo_globopen = 0; + } MapInfo_Cache_Invalidate(); _MapInfo_globhandle = search_begin("maps/*.bsp", TRUE, TRUE); - _MapInfo_globcount = search_getsize(_MapInfo_globhandle); - _MapInfo_globopen = 1; + if(_MapInfo_globhandle >= 0) + { + _MapInfo_globcount = search_getsize(_MapInfo_globhandle); + _MapInfo_globopen = 1; + } + else + _MapInfo_globcount = 0; } // filter the info by game type mask (updates MapInfo_count) @@ -242,6 +252,8 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp spawnpoints = 0; spawnplaces = 0; _MapInfo_Map_worldspawn_music = ""; + mapMins = '0 0 0'; + mapMaxs = '0 0 0'; for(;;) { @@ -301,8 +313,6 @@ 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 == "runematch_spawn_point") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH; else if(v == "target_assault_roundend") MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ASSAULT; else if(v == "onslaught_generator") @@ -352,7 +362,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp else { MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_DEATHMATCH; // DM always works - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH; // Rune always works MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_LMS; // LMS always works MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_KEEPAWAY; // Keepaway always works @@ -406,7 +415,6 @@ string _MapInfo_GetDefault(float t) case MAPINFO_TYPE_TEAM_DEATHMATCH: return "50 20 2 0"; case MAPINFO_TYPE_DOMINATION: return "200 20 0"; case MAPINFO_TYPE_CTF: return "300 20 10 0"; - case MAPINFO_TYPE_RUNEMATCH: return "200 20 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"; @@ -468,12 +476,27 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl s = cdr(s); } + if(pWantedType == MAPINFO_TYPE_CA) + { + sa = car(s); + if(sa != "") + cvar_set("g_ca_teams", sa); + s = cdr(s); + } + + if(pWantedType == MAPINFO_TYPE_FREEZETAG) + { + sa = car(s); + if(sa != "") + cvar_set("g_freezetag_teams", sa); + s = cdr(s); + } + if(pWantedType == MAPINFO_TYPE_CTF) { sa = car(s); if(sa != "") - if(cvar("g_ctf_win_mode") < 2) - cvar_set("fraglimit", sa); + cvar_set("fraglimit", sa); s = cdr(s); } @@ -535,26 +558,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.items) + return e.model2; + return ""; } void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) @@ -562,7 +570,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,12 +582,13 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) cvar_set("leadlimit", cvar_defstring("leadlimit")); cvar_set("fraglimit", cvar_defstring("fraglimit")); cvar_set("g_tdm_teams", cvar_defstring("g_tdm_teams")); + cvar_set("g_ca_teams", cvar_defstring("g_ca_teams")); + cvar_set("g_freezetag_teams", cvar_defstring("g_freezetag_teams")); cvar_set("g_keyhunt_teams", cvar_defstring("g_keyhunt_teams")); cvar_set("g_domination_default_teams", cvar_defstring("g_domination_default_teams")); 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); @@ -612,14 +620,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; @@ -627,6 +631,8 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) else if(k == "teams") { cvar_set("g_tdm_teams", v); + cvar_set("g_ca_teams", v); + cvar_set("g_freezetag_teams", v); cvar_set("g_keyhunt_teams", v); cvar_set("g_domination_default_teams", v); } @@ -644,12 +650,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); @@ -664,11 +665,29 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType) float MapInfo_Type_FromString(string t) { 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.model2) - return e.weapons; + if(t == e.mdl) + return e.items; return 0; } @@ -678,11 +697,20 @@ string MapInfo_Type_ToString(float t) if(t == MAPINFO_TYPE_ALL) return "all"; for(e = MapInfo_Type_first; e; e = e.enemy) - if(t == e.weapons) - return e.model2; + if(t == e.items) + return e.mdl; return ""; } +string MapInfo_Type_ToText(float t) +{ + entity e; + for(e = MapInfo_Type_first; e; e = e.enemy) + if(t == e.items) + return e.message; + return _("@!#%'n Tuba Throwing"); +} + void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse) { string t; @@ -943,7 +971,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo MapInfo_Map_author = s; else if(t == "has") { - t = car(s); s = cdr(s); + 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; @@ -1170,13 +1198,13 @@ float MapInfo_CurrentFeatures() float MapInfo_CurrentGametype() { - float prev, i; + float prev; entity e; prev = cvar("gamecfg"); for(e = MapInfo_Type_first; e; e = e.enemy) - if(cvar(e.mdl)) - if(prev != e.weapons) - return e.weapons; + if(cvar(e.netname)) + if(prev != e.items) + return e.items; if(prev) return prev; return MAPINFO_TYPE_DEATHMATCH; @@ -1201,20 +1229,11 @@ float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with th return r; } -string MapInfo_GetGameTypeCvar(float t) -{ - entity e; - for(e = MapInfo_Type_first; e; e = e.enemy) - if(e.weapons == t) - return e.mdl; - return ""; -} - void MapInfo_SwitchGameType(float t) { entity e; for(e = MapInfo_Type_first; e; e = e.enemy) - cvar_set(e.mdl, (t == e.weapons) ? "1" : "0"); + cvar_set(e.netname, (t == e.items) ? "1" : "0"); } void MapInfo_LoadMap(string s, float reinit)