From c1797bf9c1c36e9abccd20d16ae6df3c2a67203c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 18 Oct 2023 21:43:22 -0400 Subject: [PATCH] Fix an issue whereby ObjIDs are not preserved. Previously, when a uoid is read in from the stream, the ObjID from the stream is discarded and reassigned to the value we already know. If the key is not already known, then the next sequential ID is given. If we want to preserve IDs, then we probably want to preserve *all* IDs, even those mid-stream. This is most apparent when diffing PRPs. IDs of zero are special values to the game client that mean "always look this up by name." This situation exists in the wild, right now, on MOULa's BahroCave_District_YeeshaCave.prp. When this file is read, libHSPlasma assigns sequential IDs to the `plMipmap` references in the layers if the Textures PRP is not already loaded. If the common PRP_as_Text.py is used to diff the PRP, a comparison is made against a random/junk value, resulting in a spurious looking change. See H-uru/moul-assets#244 for an example of the confusion. --- core/ResManager/plResManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/ResManager/plResManager.cpp b/core/ResManager/plResManager.cpp index fdac103c..d05df664 100644 --- a/core/ResManager/plResManager.cpp +++ b/core/ResManager/plResManager.cpp @@ -71,7 +71,11 @@ plKey plResManager::readUoid(hsStream* S) k->readUoid(S); if (!k->getLocation().isValid()) return plKey(); - return AddKey(k); + + plKey newkey = AddKey(k); + if (preserveIDs) + newkey->setID(k->getID()); + return newkey; } void plResManager::writeKey(hsStream* S, const plKey& key)