From 9cb8b160ef0d050dec076e9b42068e3a968b8938 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:29:29 -0700 Subject: [PATCH] fix(wob): clamp out-of-range indices at save time Symmetric with the load-side index clamp. --- src/pipeline/wowee_building.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pipeline/wowee_building.cpp b/src/pipeline/wowee_building.cpp index a303f892..bba6add8 100644 --- a/src/pipeline/wowee_building.cpp +++ b/src/pipeline/wowee_building.cpp @@ -259,7 +259,11 @@ bool WoweeBuildingLoader::save(const WoweeBuilding& bld, const std::string& base } f.write(reinterpret_cast(sanVerts.data()), vc * sizeof(WoweeBuilding::Vertex)); - f.write(reinterpret_cast(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 sanIdx = grp.indices; + for (auto& idx : sanIdx) if (idx > vMax) idx = 0; + f.write(reinterpret_cast(sanIdx.data()), ic * 4); for (const auto& tp : grp.texturePaths) writeStr(tp);