X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapinfo.qc;h=cca716a339abb4bc3cd78bbc2af6b7af2fd224a5;hb=b067640a0a39aa413ec687818cc402b9562d3a28;hp=43a05b1c0a77bdbcb7dc0a3e424ac687e7d1b482;hpb=f0d3b4fa8ab12a5b30bfc43f972bda35a9310691;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 43a05b1c0..cca716a33 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -231,7 +231,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp } if(fh < 0) return 0; - print("Analyzing ", fn, " to generate initial mapinfo; please edit that file later\n"); + print("Analyzing ", fn, " to generate initial mapinfo\n"); inWorldspawn = 2; MapInfo_Map_flags = 0; @@ -347,9 +347,11 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp 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 if(spawnpoints >= 8 && diameter > 4096) { MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_TEAM_DEATHMATCH; + MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_FREEZETAG; MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CA; } if( diameter < 4096) @@ -406,6 +408,11 @@ string _MapInfo_GetDefault(float t) case MAPINFO_TYPE_ONSLAUGHT: return "20 0"; case MAPINFO_TYPE_NEXBALL: return "5 20 0"; case MAPINFO_TYPE_CTS: return "20 0 0"; + case MAPINFO_TYPE_FREEZETAG: return "10 20 0"; + // NOTE: DO NOT ADD ANY MORE GAME TYPES HERE + // THIS IS JUST LEGACY SUPPORT FOR NEXUIZ MAPS + // ONLY ADD NEW STUFF TO _MapInfo_GetDefaultEx + // THIS FUNCTION WILL EVENTUALLY BE REMOVED default: return ""; } } @@ -462,6 +469,16 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl s = cdr(s); } + /* keepaway wuz here + if(pWantedType == MAPINFO_TYPE_KEEPAWAY) + { + sa = car(s); + if(sa != "") + cvar_set("fraglimit", sa); + s = cdr(s); + } + */ + // rc = timelimit timelimit_qualification laps laps_teamplay if(pWantedType == MAPINFO_TYPE_RACE) { @@ -526,6 +543,8 @@ string _MapInfo_GetDefaultEx(float t) 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 ""; } } @@ -650,6 +669,8 @@ float MapInfo_Type_FromString(string t) 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; } @@ -670,6 +691,8 @@ string MapInfo_Type_ToString(float t) 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 ""; } @@ -779,7 +802,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype { string fn; string s, t; - float fh, fh2; + float fh; float r, f, n, i, p; string acl; @@ -804,69 +827,72 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype fh = fopen(fn, FILE_READ); if(fh < 0) { - if(!pAllowGenerate) - return 0; - _MapInfo_Map_Reset(); - r = _MapInfo_Generate(pFilename); - if(!r) - return 0; - fh = fopen(fn, FILE_WRITE); - fputs(fh, strcat("title ", MapInfo_Map_title, "\n")); - fputs(fh, strcat("description ", MapInfo_Map_description, "\n")); - fputs(fh, strcat("author ", MapInfo_Map_author, "\n")); - if(_MapInfo_Map_worldspawn_music != "") + fn = strcat("maps/autogenerated/", pFilename, ".mapinfo"); + fh = fopen(fn, FILE_READ); + if(fh < 0) { - if( - substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav" - || - substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg" - ) - fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n")); + if(!pAllowGenerate) + return 0; + _MapInfo_Map_Reset(); + r = _MapInfo_Generate(pFilename); + if(!r) + return 0; + fh = fopen(fn, FILE_WRITE); + fputs(fh, strcat("title ", MapInfo_Map_title, "\n")); + fputs(fh, strcat("description ", MapInfo_Map_description, "\n")); + fputs(fh, strcat("author ", MapInfo_Map_author, "\n")); + if(_MapInfo_Map_worldspawn_music != "") + { + if( + substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav" + || + substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg" + ) + fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n")); + else + fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n")); + } else - fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n")); - } - else - { - n = tokenize_console(cvar_string("g_cdtracks_remaplist")); - s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); - for(;;) { - i = floor(random() * n); - if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0) - break; + n = tokenize_console(cvar_string("g_cdtracks_remaplist")); + s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); + for(;;) + { + i = floor(random() * n); + if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0) + break; + } + fputs(fh, strcat("cdtrack ", ftos(i + 1), "\n")); } - fputs(fh, strcat("cdtrack ", ftos(i + 1), "\n")); - } - if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) - fputs(fh, "has weapons\n"); - else - fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n"); - if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) - fputs(fh, "frustrating\n"); - - for(i = 1; i <= MapInfo_Map_supportedGametypes; i *= 2) - if(MapInfo_Map_supportedGametypes & i) - fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i))); - - fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ); - if(fh2 >= 0) - { - fclose(fh2); - fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n"); + if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) + fputs(fh, "has weapons\n"); + else + fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n"); + if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) + fputs(fh, "frustrating\n"); + + for(i = 1; i <= MapInfo_Map_supportedGametypes; i *= 2) + if(MapInfo_Map_supportedGametypes & i) + fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i))); + + if(fexists(strcat("scripts/", pFilename, ".arena"))) + fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n"); + + fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n"); + fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n"); + fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n"); + fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n"); + fputs(fh, "// optional: hidden\n"); + + fclose(fh); + r = 2; + // return r; + fh = fopen(fn, FILE_READ); + if(fh < 0) + error("... but I just wrote it!"); } - fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n"); - fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n"); - fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n"); - fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n"); - fputs(fh, "// optional: hidden\n"); - - fclose(fh); - r = 2; - // return r; - fh = fopen(fn, FILE_READ); - if(fh < 0) - error("... but I just wrote it!"); + print("WARNING: autogenerated mapinfo file ", fn, " has been loaded; please edit that file and move it to maps/", pFilename, ".mapinfo\n"); } _MapInfo_Map_Reset(); @@ -900,6 +926,7 @@ 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 == "new_toys") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS; else dprint("Map ", pFilename, " supports unknown feature ", t, ", ignored\n"); } @@ -919,6 +946,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype { t = car(s); s = cdr(s); f = MapInfo_Type_FromString(t); + 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"); if(f) _MapInfo_Map_ApplyGametype (s, pGametypeToSet, f, TRUE); else @@ -1022,8 +1050,9 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype { if(!(MapInfo_Map_supportedGametypes & pGametypeToSet)) { - print("Can't select the requested game type. Trying anyway with stupid settings.\n"); - _MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH); + 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; } } @@ -1125,6 +1154,10 @@ float MapInfo_CurrentGametype() return MAPINFO_TYPE_NEXBALL; else if(cvar("g_cts")) return MAPINFO_TYPE_CTS; + else if(cvar("g_freezetag")) + return MAPINFO_TYPE_FREEZETAG; + else if(cvar("g_keepaway")) + return MAPINFO_TYPE_KEEPAWAY; else return MAPINFO_TYPE_DEATHMATCH; } @@ -1165,7 +1198,9 @@ string MapInfo_GetGameTypeCvar(float t) case MAPINFO_TYPE_ONSLAUGHT: return "g_onslaught"; case MAPINFO_TYPE_RACE: return "g_race"; case MAPINFO_TYPE_NEXBALL: return "g_nexball"; + case MAPINFO_TYPE_FREEZETAG: return "g_freezetag"; case MAPINFO_TYPE_CTS: return "g_cts"; + case MAPINFO_TYPE_KEEPAWAY: return "g_keepaway"; default: return ""; } } @@ -1187,6 +1222,8 @@ void MapInfo_SwitchGameType(float t) cvar_set("g_race", (t == MAPINFO_TYPE_RACE) ? "1" : "0"); cvar_set("g_nexball", (t == MAPINFO_TYPE_NEXBALL) ? "1" : "0"); cvar_set("g_cts", (t == MAPINFO_TYPE_CTS) ? "1" : "0"); + cvar_set("g_freezetag", (t == MAPINFO_TYPE_FREEZETAG) ? "1" : "0"); + cvar_set("g_keepaway", (t == MAPINFO_TYPE_KEEPAWAY) ? "1" : "0"); } void MapInfo_LoadMap(string s) @@ -1216,6 +1253,24 @@ string MapInfo_ListAllowedMaps(float pRequiredFlags, float pForbiddenFlags) return substring(out, 1, strlen(out) - 1); } +string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags) +{ + string out; + float i; + + // to make absolutely sure: + MapInfo_Enumerate(); + MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, pRequiredFlags, pForbiddenFlags, 0); + + out = ""; + for(i = 0; i < MapInfo_count; ++i) + out = strcat(out, " ", _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i))); + + MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0); + + return substring(out, 1, strlen(out) - 1); +} + void MapInfo_LoadMapSettings(string s) // to be called from worldspawn { float t, t0; @@ -1225,6 +1280,8 @@ void MapInfo_LoadMapSettings(string s) // to be called from worldspawn { print("Mapinfo system is not functional at all. Assuming deathmatch.\n"); MapInfo_Map_supportedGametypes = MAPINFO_TYPE_DEATHMATCH; + _MapInfo_Map_ApplyGametypeEx("", t0, t0); + return; // do not call Get_ByName! } t = 1; @@ -1238,12 +1295,9 @@ void MapInfo_LoadMapSettings(string s) // to be called from worldspawn if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break")) { print("EMERGENCY: can't play the selected map in the given game mode. Working with only the override settings.\n"); - cvar_set("timelimit", "0"); - cvar_set("fraglimit", "0"); - cvar_set("g_tdm_teams", "2"); - cvar_set("g_keyhunt_teams", "3"); - cvar_set("g_race_qualifying_timelimit", "0"); - cvar_set("leadlimit", "0"); + cvar_settemp_restore(); + _MapInfo_Map_ApplyGametypeEx("", t0, t0); + return; // do not call Get_ByName! } else {