mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Fix annoying "Bad static key ID" asserts
This commit is contained in:
@ -164,26 +164,27 @@ bool plRegistryKeyList::SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id = key->GetUoid().GetObjectID();
|
uint32_t id = key->GetUoid().GetObjectID();
|
||||||
hsAssert(id <= fKeys.size(), "Bad static key id");
|
plKeyImp* foundKey = nullptr;
|
||||||
|
|
||||||
// Fixed Keys will have id == 0. Let's just make sure we have it before we toss it.
|
// Fixed Keys use ID == 0
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
|
||||||
hsAssert(key->GetUoid().GetLocation() == plLocation::kGlobalFixedLoc, "key id == 0 but not fixed?");
|
hsAssert(key->GetUoid().GetLocation() == plLocation::kGlobalFixedLoc, "key id == 0 but not fixed?");
|
||||||
if (!FindKey(key->GetName()))
|
else if (id < fKeys.size()) {
|
||||||
{
|
if (fKeys[id]->GetUoid().GetObjectID() == id)
|
||||||
hsAssert(false, "Couldn't find fixed key!");
|
foundKey = fKeys[id];
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (id > fKeys.size())
|
|
||||||
return false;
|
// Last chance: do a slow name search for that key.
|
||||||
|
if (!foundKey)
|
||||||
|
foundKey = FindKey(key->GetUoid().GetObjectName());
|
||||||
|
|
||||||
// Got that key, decrement the key counter
|
// Got that key, decrement the key counter
|
||||||
--fReffedKeys;
|
if (foundKey) {
|
||||||
if (fReffedKeys == 0)
|
--fReffedKeys;
|
||||||
loadStatusChange = kTypeUnloaded;
|
if (fReffedKeys == 0)
|
||||||
return true;
|
loadStatusChange = kTypeUnloaded;
|
||||||
|
}
|
||||||
|
return foundKey != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void plRegistryKeyList::Read(hsStream* s)
|
void plRegistryKeyList::Read(hsStream* s)
|
||||||
|
@ -1665,16 +1665,13 @@ void plResManager::IKeyReffed(plKeyImp* key)
|
|||||||
void plResManager::IKeyUnreffed(plKeyImp* key)
|
void plResManager::IKeyUnreffed(plKeyImp* key)
|
||||||
{
|
{
|
||||||
plRegistryPageNode* page = FindPage(key->GetUoid().GetLocation());
|
plRegistryPageNode* page = FindPage(key->GetUoid().GetLocation());
|
||||||
if (page == nil)
|
if (!page)
|
||||||
{
|
{
|
||||||
hsAssert(0, "Couldn't find page that key belongs to");
|
hsAssert(0, "Couldn't find page that key belongs to");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool removed = page->SetKeyUnused(key);
|
if (page->SetKeyUnused(key))
|
||||||
hsAssert(removed, "Key wasn't removed from page");
|
|
||||||
|
|
||||||
if (removed)
|
|
||||||
{
|
{
|
||||||
if (!page->IsLoaded())
|
if (!page->IsLoaded())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user