feat(wob): tryLoadByGamePath helper, used by editor + terrain_manager

Mirrors the WOM tryLoadByGamePath API: probes custom_zones/buildings/ +
output/buildings/ by default, with optional extraPrefixes (e.g. per-zone
output/<map>/buildings/) checked first. Both the editor and the main
game's terrain_manager now use the helper, removing duplicate inline
lookup loops in two more places.
This commit is contained in:
Kelsi 2026-05-06 04:10:12 -07:00
parent f36309a96f
commit db068d480b
4 changed files with 48 additions and 31 deletions

View file

@ -431,5 +431,29 @@ WoweeBuilding WoweeBuildingLoader::fromWMO(const WMOModel& wmo, const std::strin
return bld;
}
WoweeBuilding WoweeBuildingLoader::tryLoadByGamePath(
const std::string& gamePath,
const std::vector<std::string>& extraPrefixes) {
std::string base = gamePath;
auto dot = base.rfind('.');
if (dot != std::string::npos) base = base.substr(0, dot);
std::replace(base.begin(), base.end(), '\\', '/');
auto tryPrefix = [&](const std::string& prefix) -> WoweeBuilding {
std::string full = prefix + base;
if (exists(full)) {
auto wob = load(full);
if (wob.isValid()) return wob;
}
return {};
};
for (const auto& p : extraPrefixes) {
if (auto w = tryPrefix(p); w.isValid()) return w;
}
for (const char* p : {"custom_zones/buildings/", "output/buildings/"}) {
if (auto w = tryPrefix(p); w.isValid()) return w;
}
return {};
}
} // namespace pipeline
} // namespace wowee