1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:53:52 +00:00

ESMStore: fill mIds in setUp()

This commit is contained in:
scrawl 2015-12-11 15:55:45 +01:00
parent ed27f0da25
commit b856460f86
2 changed files with 18 additions and 14 deletions

View file

@ -114,10 +114,6 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
} else { } else {
dialogue = 0; dialogue = 0;
} }
// Insert the reference into the global lookup
if (!id.mId.empty() && isCacheableRecord(n.val)) {
mIds[Misc::StringUtils::lowerCase (id.mId)] = n.val;
}
} }
listener->setProgress(static_cast<size_t>(esm.getFileOffset() / (float)esm.getFileSize() * 1000)); listener->setProgress(static_cast<size_t>(esm.getFileOffset() / (float)esm.getFileSize() * 1000));
} }
@ -125,9 +121,20 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
void ESMStore::setUp() void ESMStore::setUp()
{ {
std::map<int, StoreBase *>::iterator it = mStores.begin(); mIds.clear();
for (; it != mStores.end(); ++it) {
it->second->setUp(); std::map<int, StoreBase *>::iterator storeIt = mStores.begin();
for (; storeIt != mStores.end(); ++storeIt) {
if (isCacheableRecord(storeIt->first))
{
std::vector<std::string> identifiers;
storeIt->second->listIdentifier(identifiers);
for (std::vector<std::string>::const_iterator record = identifiers.begin(); record != identifiers.end(); ++record)
mIds[*record] = storeIt->first;
}
storeIt->second->setUp();
} }
mSkills.setUp(); mSkills.setUp();
mMagicEffects.setUp(); mMagicEffects.setUp();
@ -189,18 +196,13 @@ void ESMStore::setUp()
case ESM::REC_LEVC: case ESM::REC_LEVC:
{ {
RecordId id = mStores[type]->read (reader); mStores[type]->read (reader);
// FIXME: there might be stale dynamic IDs in mIds from an earlier savegame
// that really should be cleared instead of just overwritten
mIds[id.mId] = type;
} }
if (type==ESM::REC_NPC_) if (type==ESM::REC_NPC_)
{ {
// NPC record will always be last and we know that there can be only one // NPC record will always be last and we know that there can be only one
// dynamic NPC record (player) -> We are done here with dynamic record laoding // dynamic NPC record (player) -> We are done here with dynamic record loading
setUp(); setUp();
const ESM::NPC *player = mNpcs.find ("player"); const ESM::NPC *player = mNpcs.find ("player");

View file

@ -32,6 +32,8 @@ namespace MWWorld
virtual ~StoreBase() {} virtual ~StoreBase() {}
virtual void setUp() {} virtual void setUp() {}
/// List identifiers of records contained in this Store (case-smashed). No-op for Stores that don't use string IDs.
virtual void listIdentifier(std::vector<std::string> &list) const {} virtual void listIdentifier(std::vector<std::string> &list) const {}
virtual size_t getSize() const = 0; virtual size_t getSize() const = 0;