From dcacfc866581868317364554883fd8c24f150ed6 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Jan 2013 23:21:13 -0500 Subject: [PATCH] Fix export of Emote Anims Bug in the registry key list refactor... We wrote out all the keys in the key list instead of only the keys with objects. This meant we got a lot of garbage (empty) objects when exporting [Fem|M]aleWave. --- .../PubUtilLib/plResMgr/plRegistryKeyList.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index 6c99b06f..2daca544 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -217,15 +217,27 @@ void plRegistryKeyList::Write(hsStream* s) s->WriteLE32(0); s->WriteByte(0); // Deprecated flags - s->WriteLE32(fKeys.size()); + // We only write out keys with data. Fill this value in later... + uint32_t countPos = s->GetPosition(); + s->WriteLE32(0); - // Write out all our keys + // Write out all our keys with data + uint32_t keyCount = 0; for (auto it = fKeys.begin(); it != fKeys.end(); ++it) - (*it)->Write(s); + { + plKeyImp* key = *it; + if (key->ObjectIsLoaded()) + { + ++keyCount; + key->Write(s); + } + } - // Go back to the start and write the length of our data + // Rewind and write out data size and key count uint32_t endPos = s->GetPosition(); s->SetPosition(beginPos); s->WriteLE32(endPos-beginPos-sizeof(uint32_t)); + s->SetPosition(countPos); + s->WriteLE32(keyCount); s->SetPosition(endPos); }