mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(wob): clamp out-of-range indices at save time
Symmetric with the load-side index clamp.
This commit is contained in:
parent
dbb3be86f2
commit
9cb8b160ef
1 changed files with 5 additions and 1 deletions
|
|
@ -259,7 +259,11 @@ bool WoweeBuildingLoader::save(const WoweeBuilding& bld, const std::string& base
|
|||
}
|
||||
f.write(reinterpret_cast<const char*>(sanVerts.data()),
|
||||
vc * sizeof(WoweeBuilding::Vertex));
|
||||
f.write(reinterpret_cast<const char*>(grp.indices.data()), ic * 4);
|
||||
// Clamp out-of-range indices on save too — symmetric with load.
|
||||
const uint32_t vMax = vc > 0 ? vc - 1 : 0;
|
||||
std::vector<uint32_t> sanIdx = grp.indices;
|
||||
for (auto& idx : sanIdx) if (idx > vMax) idx = 0;
|
||||
f.write(reinterpret_cast<const char*>(sanIdx.data()), ic * 4);
|
||||
|
||||
for (const auto& tp : grp.texturePaths) writeStr(tp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue