diff --git a/include/pipeline/adt_loader.hpp b/include/pipeline/adt_loader.hpp index d107b46c..4f867520 100644 --- a/include/pipeline/adt_loader.hpp +++ b/include/pipeline/adt_loader.hpp @@ -113,6 +113,8 @@ struct ADTTerrain { float extentUpper[3]; uint16_t flags; uint16_t doodadSet; + uint16_t nameSet = 0; // MODF nameSet (rare; usually 0) + uint16_t scale = 1024; // MODF scale * 1024 (1024 = 1.0) }; std::vector wmoPlacements; diff --git a/src/pipeline/adt_loader.cpp b/src/pipeline/adt_loader.cpp index 12154407..f9f3f472 100644 --- a/src/pipeline/adt_loader.cpp +++ b/src/pipeline/adt_loader.cpp @@ -248,6 +248,13 @@ void ADTLoader::parseMODF(const uint8_t* data, size_t size, ADTTerrain& terrain) placement.extentUpper[2] = readFloat(data, offset + 52); placement.flags = readUInt16(data, offset + 56); placement.doodadSet = readUInt16(data, offset + 58); + // WotLK MODF entries include trailing nameSet + scale (4 bytes); older + // expansions left them as padding. + if (offset + 64 <= size) { + placement.nameSet = readUInt16(data, offset + 60); + placement.scale = readUInt16(data, offset + 62); + if (placement.scale == 0) placement.scale = 1024; + } terrain.wmoPlacements.push_back(placement); } diff --git a/tools/editor/adt_writer.cpp b/tools/editor/adt_writer.cpp index 1630341d..b4815f07 100644 --- a/tools/editor/adt_writer.cpp +++ b/tools/editor/adt_writer.cpp @@ -154,11 +154,10 @@ void ADTWriter::writeMODF(std::vector& buf, const pipeline::ADTTerrain& writeFloat(buf, p.extentUpper[2]); writeU16(buf, p.flags); writeU16(buf, p.doodadSet); - // MODF entry is 64 bytes total; we wrote 60, pad with nameSet(0) + scale(1024). - // Loader treats entrySize as 64, so missing trailing bytes mis-align the - // next entry. scale=1024 = 1.0 in MODF's fixed-point u16 encoding. - writeU16(buf, 0); - writeU16(buf, 1024); + // MODF entry is 64 bytes total; the trailing nameSet + scale slots are + // populated when present (WotLK+) and default to (0, 1024) otherwise. + writeU16(buf, p.nameSet); + writeU16(buf, p.scale != 0 ? p.scale : 1024); } patchSize(buf, start); }