mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
feat(wom): tryLoadByGamePath accepts extraPrefixes for per-zone search roots
The shared helper only probed custom_zones/models/ + output/models/, but the editor's exportZone writes to output/<map>/models/. Added an extraPrefixes parameter that's tried before the defaults — main game's terrain_manager now passes ['output/<map>/models/', 'custom_zones/<map>/ models/'] so per-zone WOM exports override globals. Also removes the last duplicate WOM-loading code from terrain_manager.
This commit is contained in:
parent
99aaab3aa8
commit
f36309a96f
3 changed files with 34 additions and 23 deletions
|
|
@ -500,17 +500,26 @@ M2Model WoweeModelLoader::toM2(const WoweeModel& wom) {
|
|||
return m;
|
||||
}
|
||||
|
||||
WoweeModel WoweeModelLoader::tryLoadByGamePath(const std::string& gamePath) {
|
||||
WoweeModel WoweeModelLoader::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(), '\\', '/');
|
||||
for (const char* prefix : {"custom_zones/models/", "output/models/"}) {
|
||||
std::string full = std::string(prefix) + base;
|
||||
auto tryPrefix = [&](const std::string& prefix) -> WoweeModel {
|
||||
std::string full = prefix + base;
|
||||
if (exists(full)) {
|
||||
auto wom = load(full);
|
||||
if (wom.isValid()) return wom;
|
||||
}
|
||||
return {};
|
||||
};
|
||||
for (const auto& p : extraPrefixes) {
|
||||
if (auto w = tryPrefix(p); w.isValid()) return w;
|
||||
}
|
||||
for (const char* p : {"custom_zones/models/", "output/models/"}) {
|
||||
if (auto w = tryPrefix(p); w.isValid()) return w;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue