Skip to content

Commit

Permalink
Assign sequential object IDs at Max export time
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Jul 15, 2023
1 parent ad38630 commit 5815cf1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ bool plRegistryKeyList::SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange
return foundKey != nullptr;
}

void plRegistryKeyList::PrepForWrite()
{
uint32_t objectID = 1;
for (auto it = fKeys.begin(); it != fKeys.end(); ++it) {
plKeyImp* key = *it;

if (key->ObjectIsLoaded()) {
key->SetObjectID(objectID++);
}
}
}

void plRegistryKeyList::Read(hsStream* s)
{
uint32_t keyListLen = s->ReadLE32();
Expand Down
4 changes: 4 additions & 0 deletions Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 static keys
// object ID's that they can use to do fast lookups at load time.
void PrepForWrite();

void Read(hsStream* s);
void Write(hsStream* s);
};
Expand Down
3 changes: 3 additions & 0 deletions Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5815cf1

Please sign in to comment.