From aa9ef6f2ca65ce532dd90beafc8cca8ac02e272e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 06:49:51 -0700 Subject: [PATCH] fix(adt): scrub NaN/inf floats at write time ADTWriter::writeFloat now coerces non-finite values to 0 before emitting bits, so a stray NaN in a chunk position, MDDF rotation, or MODF extent can't leak into the saved ADT and produce invisible terrain or off-map placements after reload. --- tools/editor/adt_writer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/editor/adt_writer.cpp b/tools/editor/adt_writer.cpp index b4815f07..3e5d5033 100644 --- a/tools/editor/adt_writer.cpp +++ b/tools/editor/adt_writer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace wowee { namespace editor { @@ -42,6 +43,9 @@ void ADTWriter::writeU16(std::vector& buf, uint16_t val) { } void ADTWriter::writeFloat(std::vector& buf, float val) { + // Reject NaN/inf — would silently turn into invisible terrain or + // off-map placements after the next ADT load. + if (!std::isfinite(val)) val = 0.0f; uint32_t bits; std::memcpy(&bits, &val, 4); writeU32(buf, bits);