mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(wot): cap doodadNames/wmoNames at 65536 + guard non-string entries
Both name lists used n.get<std::string> which throws on non-string entries (would abort the entire WOT load). Real zones use ~5k names max; cap at 65536 (uint16 nameId range upper bound) so the cap is generous but bounded. Guard with is_string so a single bad entry just gets skipped instead of failing the file.
This commit is contained in:
parent
fc895ab564
commit
8e80f97bbc
1 changed files with 14 additions and 6 deletions
|
|
@ -173,10 +173,15 @@ bool WoweeTerrainLoader::loadMetadata(const std::string& wotPath, ADTTerrain& te
|
|||
}
|
||||
}
|
||||
|
||||
// Parse doodad placements
|
||||
// Parse doodad placements. n.get<std::string> throws on non-string
|
||||
// entries — guard with is_string and cap the list at 65536 (uint32
|
||||
// nameId range is far larger but real zones top out around ~5k).
|
||||
if (j.contains("doodadNames") && j["doodadNames"].is_array()) {
|
||||
for (const auto& n : j["doodadNames"])
|
||||
terrain.doodadNames.push_back(n.get<std::string>());
|
||||
constexpr size_t kMaxNames = 65536;
|
||||
for (const auto& n : j["doodadNames"]) {
|
||||
if (terrain.doodadNames.size() >= kMaxNames) break;
|
||||
if (n.is_string()) terrain.doodadNames.push_back(n.get<std::string>());
|
||||
}
|
||||
}
|
||||
// Helper used by both doodad and WMO loaders below.
|
||||
auto san3 = [](float& a, float& b, float& c) {
|
||||
|
|
@ -208,10 +213,13 @@ bool WoweeTerrainLoader::loadMetadata(const std::string& wotPath, ADTTerrain& te
|
|||
}
|
||||
}
|
||||
|
||||
// Parse WMO placements
|
||||
// Parse WMO placements (same guards as doodadNames above).
|
||||
if (j.contains("wmoNames") && j["wmoNames"].is_array()) {
|
||||
for (const auto& n : j["wmoNames"])
|
||||
terrain.wmoNames.push_back(n.get<std::string>());
|
||||
constexpr size_t kMaxWmoNames = 65536;
|
||||
for (const auto& n : j["wmoNames"]) {
|
||||
if (terrain.wmoNames.size() >= kMaxWmoNames) break;
|
||||
if (n.is_string()) terrain.wmoNames.push_back(n.get<std::string>());
|
||||
}
|
||||
}
|
||||
if (j.contains("wmos") && j["wmos"].is_array()) {
|
||||
for (const auto& jw : j["wmos"]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue