From: bones_was_here Date: Mon, 13 Jan 2025 08:27:37 +0000 (+1000) Subject: q3compat: check for a map-specific .arena file even when there's another one in the pk3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=239f573e386ce73e9993335eb51783aec03c668d;p=xonotic%2Fxonotic-data.pk3dir.git q3compat: check for a map-specific .arena file even when there's another one in the pk3 This allows the server admin to work around pk3s containing an .arena file (or .defi file) that isn't valid for some map(s) in the pk3, without modifying the pk3. Or they could override the one in the pk3 (on a map-specific basis) to change some value(s). --- diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index db4296196..c928fcaf0 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -1007,28 +1007,33 @@ string _MapInfo_CheckArenaFile(string pFilename, string pMapname) string _MapInfo_FindArenaFile(string pFilename, string extension) { - string fallback = strcat("scripts/", pFilename, extension); - if(!checkextension("DP_QC_FS_SEARCH_PACKFILE")) - return _MapInfo_CheckArenaFile(fallback, pFilename); + // A valid arena file with the "default" name may have been created as a map-specific + // override of an arena file with a different name (possibly multi-map) in the pk3 + // (occasionally in the wild such file exists in the pk3 but isn't valid for a map in the pk3). + // Therefore we try the "default" name first. + string afile = _MapInfo_CheckArenaFile(strcat("scripts/", pFilename, extension), pFilename); + if (afile != "" + || !checkextension("DP_QC_FS_SEARCH_PACKFILE")) + return afile; + string base_pack = whichpack(strcat("maps/", pFilename, ".bsp")); if(base_pack == "") // this map isn't packaged! - return _MapInfo_CheckArenaFile(fallback, pFilename); - + return ""; int glob = search_packfile_begin(strcat("scripts/*", extension), true, true, base_pack); - if(glob < 0) - return _MapInfo_CheckArenaFile(fallback, pFilename); + if(glob < 0) // there's no matching file in the pack + return ""; int n = search_getsize(glob); for(int j = 0; j < n; ++j) { - string file = search_getfilename(glob, j); - if(_MapInfo_CheckArenaFile(file, pFilename) != "") + afile = search_getfilename(glob, j); + if(_MapInfo_CheckArenaFile(afile, pFilename) != "") { search_end(glob); - return file; + return afile; } } - search_end(glob); + return ""; // if we get here, a valid .arena file could not be found }