mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
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:
parent
bc1839d9ab
commit
aa9ef6f2ca
1 changed files with 4 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue