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.
This commit is contained in:
Kelsi 2026-05-06 06:49:51 -07:00
parent bc1839d9ab
commit aa9ef6f2ca

View file

@ -3,6 +3,7 @@
#include <fstream>
#include <cstring>
#include <filesystem>
#include <cmath>
namespace wowee {
namespace editor {
@ -42,6 +43,9 @@ void ADTWriter::writeU16(std::vector<uint8_t>& buf, uint16_t val) {
}
void ADTWriter::writeFloat(std::vector<uint8_t>& 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);