mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(editor): preserve PlacedObject uniqueId across JSON save/load
uniqueId was always regenerated on load, so re-saving the same zone produced a different uniqueId per placement each time. Since syncToTerrain copies obj.uniqueId into MDDF/MODF, the ADT also rotated uniqueIds across cycles. Now JSON stores uniqueId, the loader reads it back when present (falling back to nextUniqueId() for legacy files), and uniqueIdCounter_ is bumped past any loaded value so future placements never collide.
This commit is contained in:
parent
882321863a
commit
4d11949048
1 changed files with 12 additions and 2 deletions
|
|
@ -263,7 +263,8 @@ bool ObjectPlacer::saveToFile(const std::string& path) const {
|
|||
{"path", o.path},
|
||||
{"pos", {o.position.x, o.position.y, o.position.z}},
|
||||
{"rot", {o.rotation.x, o.rotation.y, o.rotation.z}},
|
||||
{"scale", o.scale}
|
||||
{"scale", o.scale},
|
||||
{"uniqueId", o.uniqueId}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +307,16 @@ bool ObjectPlacer::loadFromFile(const std::string& path) {
|
|||
}
|
||||
|
||||
if (!obj.path.empty()) {
|
||||
obj.uniqueId = nextUniqueId();
|
||||
// Preserve original uniqueId from JSON if present so ADT round-trip
|
||||
// is stable. Bump uniqueIdCounter_ past any loaded value to avoid
|
||||
// collisions with future placements.
|
||||
if (jo.contains("uniqueId")) {
|
||||
obj.uniqueId = jo["uniqueId"].get<uint32_t>();
|
||||
if (obj.uniqueId >= uniqueIdCounter_)
|
||||
uniqueIdCounter_ = obj.uniqueId + 1;
|
||||
} else {
|
||||
obj.uniqueId = nextUniqueId();
|
||||
}
|
||||
objects_.push_back(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue