Skip to content

Commit

Permalink
Fix an issue whereby ObjIDs are not preserved.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hoikas committed Oct 19, 2023
1 parent 0d948a2 commit c1797bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/ResManager/plResManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1797bf

Please sign in to comment.