From 7e0713f6c4d414a0df087f7d4954c36709b02ce0 Mon Sep 17 00:00:00 2001 From: greye Date: Mon, 31 Dec 2012 11:22:40 +0400 Subject: [PATCH] fix string case update --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 23 ++++++------------- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 1 - apps/openmw/mwgui/inventorywindow.cpp | 2 +- apps/openmw/mwscript/containerextensions.cpp | 13 +++++------ apps/openmw/mwworld/worldimp.cpp | 2 +- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 80999c5ff4..d81421f811 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -40,16 +40,6 @@ #include "filter.hpp" -namespace -{ - - //helper function - std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) - { - return Misc::StringUtils::toLower(const_cast(str)).find(Misc::StringUtils::toLower(const_cast(substr)).c_str(),pos); - } -} - namespace MWDialogue { DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) : @@ -70,13 +60,13 @@ namespace MWDialogue MWWorld::Store::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) { - mDialogueMap[Misc::StringUtils::toLower(const_cast(it->mId))] = *it; + mDialogueMap[Misc::StringUtils::lowerCase(it->mId)] = *it; } } void DialogueManager::addTopic (const std::string& topic) { - mKnownTopics[Misc::StringUtils::toLower(const_cast(topic))] = true; + mKnownTopics[Misc::StringUtils::lowerCase(topic)] = true; } void DialogueManager::parseText (const std::string& text) @@ -84,7 +74,7 @@ namespace MWDialogue std::list::iterator it; for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++it) { - size_t pos = find_str_ci(text,*it,0); + size_t pos = Misc::StringUtils::lowerCase(text).find(*it, 0); if(pos !=std::string::npos) { mKnownTopics[*it] = true; @@ -274,10 +264,11 @@ namespace MWDialogue { if (filter.search (*iter)) { - mActorKnownTopics.push_back ( Misc::StringUtils::toLower(const_cast(iter->mId))); + std::string lower = Misc::StringUtils::lowerCase(iter->mId); + mActorKnownTopics.push_back (lower); //does the player know the topic? - if (mKnownTopics.find ( Misc::StringUtils::toLower(const_cast(iter->mId))) != mKnownTopics.end()) + if (mKnownTopics.find (lower) != mKnownTopics.end()) { keywordList.push_back (iter->mId); } @@ -415,7 +406,7 @@ namespace MWDialogue { MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->askQuestion(question); - mChoiceMap[Misc::StringUtils::toLower(const_cast(question))] = choice; + mChoiceMap[Misc::StringUtils::lowerCase(question)] = choice; mIsInChoice = true; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index b0bef5ea09..98b27f7744 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -71,7 +71,6 @@ namespace MWDialogue virtual void persuade (int type); virtual int getTemporaryDispositionChange () const; virtual void applyTemporaryDispositionChange (int delta); - void toLower(std::string question); }; } diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index dd75b8216a..ffb6c5282e 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -271,7 +271,7 @@ namespace MWGui for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (Misc::StringUtils::toLower(it->getCellRef().mRefID) == "gold_001") + if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001")) return it->getRefData().getCount(); } return 0; diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 2cdad2a908..1fa69d1fd6 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -72,7 +72,7 @@ namespace MWScript Interpreter::Type_Integer sum = 0; for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) - if (Misc::StringUtils::toLower(iter->getCellRef().mRefID) == Misc::StringUtils::toLower(item)) + if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item)) sum += iter->getRefData().getCount(); runtime.push (sum); @@ -105,7 +105,7 @@ namespace MWScript for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count; ++iter) { - if (Misc::StringUtils::toLower(iter->getCellRef().mRefID) == Misc::StringUtils::toLower(item)) + if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item)) { itemName = MWWorld::Class::get(*iter).getName(*iter); @@ -163,7 +163,7 @@ namespace MWScript MWWorld::ContainerStoreIterator it = invStore.begin(); for (; it != invStore.end(); ++it) { - if (Misc::StringUtils::toLower(it->getCellRef().mRefID) == Misc::StringUtils::toLower(item)) + if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, item)) break; } if (it == invStore.end()) @@ -263,7 +263,7 @@ namespace MWScript for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) { MWWorld::ContainerStoreIterator it = invStore.getSlot (slot); - if (it != invStore.end() && Misc::StringUtils::toLower(it->getCellRef().mRefID) == Misc::StringUtils::toLower(item)) + if (it != invStore.end() && Misc::StringUtils::ciEqual(it->getCellRef().mRefID, item)) { runtime.push(1); return; @@ -282,8 +282,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - const std::string &name = runtime.getStringLiteral (runtime[0].mInteger); - std::string creatureName = Misc::StringUtils::toLower (const_cast(name)); + const std::string &name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); @@ -291,7 +290,7 @@ namespace MWScript it != invStore.end(); ++it) { - if (Misc::StringUtils::toLower(it->getCellRef().mSoul) == Misc::StringUtils::toLower(creatureName)) + if (Misc::StringUtils::ciEqual(it->getCellRef().mSoul, name)) { runtime.push(1); return; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index e38fcf7174..3995123b0e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -621,7 +621,7 @@ namespace MWWorld { if (isPlayer) if (!newCell.isExterior()) - changeToInteriorCell(Misc::StringUtils::toLower(const_cast (newCell.mCell->mName)), pos); + changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.mCell->mName), pos); else { int cellX = newCell.mCell->getGridX();