fix string case update

actorid
greye 12 years ago
parent 8b2785400b
commit 7e0713f6c4

@ -40,16 +40,6 @@
#include "filter.hpp" #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<std::string &>(str)).find(Misc::StringUtils::toLower(const_cast<std::string &>(substr)).c_str(),pos);
}
}
namespace MWDialogue namespace MWDialogue
{ {
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) : DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) :
@ -70,13 +60,13 @@ namespace MWDialogue
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it) for (; it != dialogs.end(); ++it)
{ {
mDialogueMap[Misc::StringUtils::toLower(const_cast<std::string &>(it->mId))] = *it; mDialogueMap[Misc::StringUtils::lowerCase(it->mId)] = *it;
} }
} }
void DialogueManager::addTopic (const std::string& topic) void DialogueManager::addTopic (const std::string& topic)
{ {
mKnownTopics[Misc::StringUtils::toLower(const_cast<std::string &>(topic))] = true; mKnownTopics[Misc::StringUtils::lowerCase(topic)] = true;
} }
void DialogueManager::parseText (const std::string& text) void DialogueManager::parseText (const std::string& text)
@ -84,7 +74,7 @@ namespace MWDialogue
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++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) if(pos !=std::string::npos)
{ {
mKnownTopics[*it] = true; mKnownTopics[*it] = true;
@ -274,10 +264,11 @@ namespace MWDialogue
{ {
if (filter.search (*iter)) if (filter.search (*iter))
{ {
mActorKnownTopics.push_back ( Misc::StringUtils::toLower(const_cast<std::string &>(iter->mId))); std::string lower = Misc::StringUtils::lowerCase(iter->mId);
mActorKnownTopics.push_back (lower);
//does the player know the topic? //does the player know the topic?
if (mKnownTopics.find ( Misc::StringUtils::toLower(const_cast<std::string &>(iter->mId))) != mKnownTopics.end()) if (mKnownTopics.find (lower) != mKnownTopics.end())
{ {
keywordList.push_back (iter->mId); keywordList.push_back (iter->mId);
} }
@ -415,7 +406,7 @@ namespace MWDialogue
{ {
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->askQuestion(question); win->askQuestion(question);
mChoiceMap[Misc::StringUtils::toLower(const_cast<std::string &>(question))] = choice; mChoiceMap[Misc::StringUtils::lowerCase(question)] = choice;
mIsInChoice = true; mIsInChoice = true;
} }

@ -71,7 +71,6 @@ namespace MWDialogue
virtual void persuade (int type); virtual void persuade (int type);
virtual int getTemporaryDispositionChange () const; virtual int getTemporaryDispositionChange () const;
virtual void applyTemporaryDispositionChange (int delta); virtual void applyTemporaryDispositionChange (int delta);
void toLower(std::string question);
}; };
} }

@ -271,7 +271,7 @@ namespace MWGui
for (MWWorld::ContainerStoreIterator it = invStore.begin(); for (MWWorld::ContainerStoreIterator it = invStore.begin();
it != invStore.end(); ++it) 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 it->getRefData().getCount();
} }
return 0; return 0;

@ -72,7 +72,7 @@ namespace MWScript
Interpreter::Type_Integer sum = 0; Interpreter::Type_Integer sum = 0;
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) 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(); sum += iter->getRefData().getCount();
runtime.push (sum); runtime.push (sum);
@ -105,7 +105,7 @@ namespace MWScript
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count; for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count;
++iter) ++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); itemName = MWWorld::Class::get(*iter).getName(*iter);
@ -163,7 +163,7 @@ namespace MWScript
MWWorld::ContainerStoreIterator it = invStore.begin(); MWWorld::ContainerStoreIterator it = invStore.begin();
for (; it != invStore.end(); ++it) 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; break;
} }
if (it == invStore.end()) if (it == invStore.end())
@ -263,7 +263,7 @@ namespace MWScript
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
{ {
MWWorld::ContainerStoreIterator it = invStore.getSlot (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); runtime.push(1);
return; return;
@ -283,7 +283,6 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
const std::string &name = runtime.getStringLiteral (runtime[0].mInteger); const std::string &name = runtime.getStringLiteral (runtime[0].mInteger);
std::string creatureName = Misc::StringUtils::toLower (const_cast<std::string &>(name));
runtime.pop(); runtime.pop();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
@ -291,7 +290,7 @@ namespace MWScript
it != invStore.end(); ++it) 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); runtime.push(1);
return; return;

@ -621,7 +621,7 @@ namespace MWWorld
{ {
if (isPlayer) if (isPlayer)
if (!newCell.isExterior()) if (!newCell.isExterior())
changeToInteriorCell(Misc::StringUtils::toLower(const_cast<std::string &> (newCell.mCell->mName)), pos); changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.mCell->mName), pos);
else else
{ {
int cellX = newCell.mCell->getGridX(); int cellX = newCell.mCell->getGridX();

Loading…
Cancel
Save