diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 90f0c0231..3188136b3 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -549,10 +549,10 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); actorKnownTopics.clear(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { - mDialogueMap[it->first] = it->second; + mDialogueMap[toLower(it->first)] = it->second; } } @@ -602,8 +602,8 @@ namespace MWDialogue //greeting bool greetingFound = false; //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.type == ESM::Dialogue::Greeting) @@ -702,8 +702,8 @@ namespace MWDialogue mChoice = -1; actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.type == ESM::Dialogue::Topic) @@ -713,7 +713,7 @@ namespace MWDialogue { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { - actorKnownTopics.push_back(it->first); + actorKnownTopics.push_back(toLower(it->first)); //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ac6681e27..fc7a36382 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -183,6 +183,16 @@ void DialogueWindow::addText(std::string text) void DialogueWindow::addTitle(std::string text) { + // This is called from the dialogue manager, so text is + // case-smashed - thus we have to retrieve the correct case + // of the text through the topic list. + for (size_t i=0; igetItemCount(); ++i) + { + std::string item = topicsList->getItemNameAt(i); + if (lower_string(item) == text) + text = item; + } + history->addDialogHeading(text); } diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index d7a4100aa..48bf050cd 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -90,6 +90,75 @@ namespace ESMS } }; + // Same as RecListT, but does not case-smash the IDs + // Note that lookups (search or find) are still case insensitive + template + struct RecListCaseT : RecList + { + virtual ~RecListCaseT() {} + + typedef std::map MapType; + + MapType list; + + // Load one object of this type + void load(ESMReader &esm, const std::string &id) + { + //std::string id2 = toLower (id); + + list[id].load(esm); + } + + // Find the given object ID, or return NULL if not found. + const X* search(const std::string &id) const + { + std::string id2 = toLower (id); + + for (typename MapType::const_iterator iter = list.begin(); + iter != list.end(); ++iter) + { + if (toLower(iter->first) == id2) + return &iter->second; + } + + return NULL; + } + + // non-const version + X* search(const std::string &id) + { + std::string id2 = toLower (id); + + for (typename MapType::iterator iter = list.begin(); + iter != list.end(); ++iter) + { + if (toLower(iter->first) == id2) + return &iter->second; + } + + return NULL; + } + + // Find the given object ID (throws an exception if not found) + const X* find(const std::string &id) const + { + const X *object = search (id); + + if (!object) + throw std::runtime_error ("object " + id + " not found"); + + return object; + } + + int getSize() { return list.size(); } + + virtual void listIdentifier (std::vector& identifier) const + { + for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) + identifier.push_back (iter->first); + } + }; + /// Modified version of RecListT for records, that need to store their own ID template struct RecListWithIDT : RecList diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 2b5b977aa..c676601e5 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -71,15 +71,13 @@ void ESMStore::load(ESMReader &esm) if (n.val==ESM::REC_DIAL) { - RecListT& recList = static_cast& > (*it->second); + RecListCaseT& recList = static_cast& > (*it->second); - id = recList.toLower (id); + ESM::Dialogue* d = recList.search (id); - RecListT::MapType::iterator iter = recList.list.find (id); + assert (d != NULL); - assert (iter!=recList.list.end()); - - dialogue = &iter->second; + dialogue = d; } else dialogue = 0; diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 857682089..507196a86 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -40,9 +40,9 @@ namespace ESMS RecListT clothes; RecListT contChange; RecListT containers; - RecListWithIDT creatures; + RecListWithIDT creatures; RecListT creaChange; - RecListT dialogs; + RecListCaseT dialogs; RecListT doors; RecListT enchants; RecListT factions; @@ -53,7 +53,7 @@ namespace ESMS RecListT lights; RecListT lockpicks; RecListT miscItems; - RecListWithIDT npcs; + RecListWithIDT npcs; RecListT npcChange; RecListT probes; RecListT races;