diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index 8cbdd700c7..ed4cb9b85f 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -201,6 +201,16 @@ bool plRegistryKeyList::SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange return foundKey != nullptr; } +void plRegistryKeyList::PrepForWrite() +{ + uint32_t objectID = 1; + for (plKeyImp* key : fKeys) { + if (key->ObjectIsLoaded()) { + key->SetObjectID(objectID++); + } + } +} + void plRegistryKeyList::Read(hsStream* s) { uint32_t keyListLen = s->ReadLE32(); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h index 6e71efa7ab..21fac7a019 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h @@ -97,6 +97,10 @@ class plRegistryKeyList void SetKeyUsed(plKeyImp* key) { ++fReffedKeys; } bool SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange); + // Export time only. Before we write to disk, assign all the loaded keys + // sequential object IDs that they can use to do fast lookups at load time. + void PrepForWrite(); + void Read(hsStream* s); void Write(hsStream* s); }; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index 2624fbf3be..8109076a28 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -230,6 +230,9 @@ void plRegistryPageNode::Write() for (it = fKeyLists.begin(); it != fKeyLists.end(); it++) { plRegistryKeyList* keyList = it->second; + if (fIsNewPage) + keyList->PrepForWrite(); + int ver = plVersion::GetCreatableVersion(keyList->GetClassType()); fPageInfo.AddClassVersion(keyList->GetClassType(), ver); }