From 34cdd2bb1f63a38dbe4741c817259f6cd986eea2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 3 Dec 2013 14:39:54 +0100 Subject: [PATCH] deal with dialogue/info records that don't exist anymore --- apps/openmw/mwdialogue/journalimp.cpp | 44 +++++++++++++++++++-------- apps/openmw/mwdialogue/journalimp.hpp | 2 ++ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwdialogue/journalimp.cpp b/apps/openmw/mwdialogue/journalimp.cpp index b9359aae6..f24a93356 100644 --- a/apps/openmw/mwdialogue/journalimp.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -48,6 +48,22 @@ namespace MWDialogue return iter->second; } + bool Journal::isThere (const std::string& topicId, const std::string& infoId) const + { + if (const ESM::Dialogue *dialogue = + MWBase::Environment::get().getWorld()->getStore().get().search (topicId)) + { + if (infoId.empty()) + return true; + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->mId == infoId) + return true; + } + + return false; + } Journal::Journal() {} @@ -207,30 +223,32 @@ namespace MWDialogue ESM::JournalEntry record; record.load (reader); - switch (record.mType) - { - case ESM::JournalEntry::Type_Quest: + if (isThere (record.mTopic, record.mInfo)) + switch (record.mType) + { + case ESM::JournalEntry::Type_Quest: - getQuest (record.mTopic).insertEntry (record); - break; + getQuest (record.mTopic).insertEntry (record); + break; - case ESM::JournalEntry::Type_Journal: + case ESM::JournalEntry::Type_Journal: - mJournal.push_back (record); - break; + mJournal.push_back (record); + break; - case ESM::JournalEntry::Type_Topic: + case ESM::JournalEntry::Type_Topic: - getTopic (record.mTopic).insertEntry (record); - break; - } + getTopic (record.mTopic).insertEntry (record); + break; + } } else if (type==ESM::REC_QUES) { ESM::QuestState record; record.load (reader); - mQuests.insert (std::make_pair (record.mTopic, record)); + if (isThere (record.mTopic)) + mQuests.insert (std::make_pair (record.mTopic, record)); } } } diff --git a/apps/openmw/mwdialogue/journalimp.hpp b/apps/openmw/mwdialogue/journalimp.hpp index 54c49df01..86091a12d 100644 --- a/apps/openmw/mwdialogue/journalimp.hpp +++ b/apps/openmw/mwdialogue/journalimp.hpp @@ -21,6 +21,8 @@ namespace MWDialogue Topic& getTopic (const std::string& id); + bool isThere (const std::string& topicId, const std::string& infoId = "") const; + public: Journal();