forked from teamnwah/openmw-tes3coop
Merge remote-tracking branch 'trombonecot/comparestring'
This commit is contained in:
commit
8b2785400b
8 changed files with 28 additions and 85 deletions
|
@ -42,35 +42,11 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
std::string toLower (const std::string& name)
|
||||
{
|
||||
std::string lowerCase;
|
||||
|
||||
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||
(int(*)(int)) std::tolower);
|
||||
|
||||
return lowerCase;
|
||||
}
|
||||
|
||||
bool stringCompareNoCase (std::string first, std::string second)
|
||||
{
|
||||
unsigned int i=0;
|
||||
while ( (i<first.length()) && (i<second.length()) )
|
||||
{
|
||||
if (tolower(first[i])<tolower(second[i])) return true;
|
||||
else if (tolower(first[i])>tolower(second[i])) return false;
|
||||
++i;
|
||||
}
|
||||
if (first.length()<second.length())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//helper function
|
||||
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
|
||||
{
|
||||
return toLower(str).find(toLower(substr),pos);
|
||||
{
|
||||
return Misc::StringUtils::toLower(const_cast<std::string &>(str)).find(Misc::StringUtils::toLower(const_cast<std::string &>(substr)).c_str(),pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,13 +70,13 @@ namespace MWDialogue
|
|||
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
|
||||
for (; it != dialogs.end(); ++it)
|
||||
{
|
||||
mDialogueMap[toLower(it->mId)] = *it;
|
||||
mDialogueMap[Misc::StringUtils::toLower(const_cast<std::string &>(it->mId))] = *it;
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueManager::addTopic (const std::string& topic)
|
||||
{
|
||||
mKnownTopics[toLower(topic)] = true;
|
||||
mKnownTopics[Misc::StringUtils::toLower(const_cast<std::string &>(topic))] = true;
|
||||
}
|
||||
|
||||
void DialogueManager::parseText (const std::string& text)
|
||||
|
@ -298,10 +274,10 @@ namespace MWDialogue
|
|||
{
|
||||
if (filter.search (*iter))
|
||||
{
|
||||
mActorKnownTopics.push_back (toLower (iter->mId));
|
||||
mActorKnownTopics.push_back ( Misc::StringUtils::toLower(const_cast<std::string &>(iter->mId)));
|
||||
|
||||
//does the player know the topic?
|
||||
if (mKnownTopics.find (toLower (iter->mId)) != mKnownTopics.end())
|
||||
if (mKnownTopics.find ( Misc::StringUtils::toLower(const_cast<std::string &>(iter->mId))) != mKnownTopics.end())
|
||||
{
|
||||
keywordList.push_back (iter->mId);
|
||||
}
|
||||
|
@ -359,7 +335,7 @@ namespace MWDialogue
|
|||
win->setServices (windowServices);
|
||||
|
||||
// sort again, because the previous sort was case-sensitive
|
||||
keywordList.sort(stringCompareNoCase);
|
||||
keywordList.sort(Misc::StringUtils::ciEqual);
|
||||
win->setKeywords(keywordList);
|
||||
|
||||
mChoice = choice;
|
||||
|
@ -439,7 +415,7 @@ namespace MWDialogue
|
|||
{
|
||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||
win->askQuestion(question);
|
||||
mChoiceMap[toLower(question)] = choice;
|
||||
mChoiceMap[Misc::StringUtils::toLower(const_cast<std::string &>(question))] = choice;
|
||||
mIsInChoice = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace MWDialogue
|
|||
virtual void persuade (int type);
|
||||
virtual int getTemporaryDispositionChange () const;
|
||||
virtual void applyTemporaryDispositionChange (int delta);
|
||||
void toLower(std::string question);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -24,19 +24,6 @@
|
|||
#include "scrollwindow.hpp"
|
||||
#include "spellwindow.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string toLower (const std::string& name)
|
||||
{
|
||||
std::string lowerCase;
|
||||
|
||||
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||
(int(*)(int)) std::tolower);
|
||||
|
||||
return lowerCase;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
|
@ -284,7 +271,7 @@ namespace MWGui
|
|||
for (MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||
it != invStore.end(); ++it)
|
||||
{
|
||||
if (toLower(it->getCellRef().mRefID) == "gold_001")
|
||||
if (Misc::StringUtils::toLower(it->getCellRef().mRefID) == "gold_001")
|
||||
return it->getRefData().getCount();
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -25,19 +25,6 @@
|
|||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string toLower (const std::string& name)
|
||||
{
|
||||
std::string lowerCase;
|
||||
|
||||
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||
(int(*)(int)) std::tolower);
|
||||
|
||||
return lowerCase;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Container
|
||||
|
@ -85,7 +72,7 @@ namespace MWScript
|
|||
Interpreter::Type_Integer sum = 0;
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
||||
if (toLower(iter->getCellRef().mRefID) == toLower(item))
|
||||
if (Misc::StringUtils::toLower(iter->getCellRef().mRefID) == Misc::StringUtils::toLower(item))
|
||||
sum += iter->getRefData().getCount();
|
||||
|
||||
runtime.push (sum);
|
||||
|
@ -118,7 +105,7 @@ namespace MWScript
|
|||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count;
|
||||
++iter)
|
||||
{
|
||||
if (toLower(iter->getCellRef().mRefID) == toLower(item))
|
||||
if (Misc::StringUtils::toLower(iter->getCellRef().mRefID) == Misc::StringUtils::toLower(item))
|
||||
{
|
||||
itemName = MWWorld::Class::get(*iter).getName(*iter);
|
||||
|
||||
|
@ -176,7 +163,7 @@ namespace MWScript
|
|||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||
for (; it != invStore.end(); ++it)
|
||||
{
|
||||
if (toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
if (Misc::StringUtils::toLower(it->getCellRef().mRefID) == Misc::StringUtils::toLower(item))
|
||||
break;
|
||||
}
|
||||
if (it == invStore.end())
|
||||
|
@ -276,7 +263,7 @@ namespace MWScript
|
|||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
||||
if (it != invStore.end() && toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
if (it != invStore.end() && Misc::StringUtils::toLower(it->getCellRef().mRefID) == Misc::StringUtils::toLower(item))
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
|
@ -294,8 +281,9 @@ namespace MWScript
|
|||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string creatureName = toLower (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();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
|
@ -303,7 +291,7 @@ namespace MWScript
|
|||
it != invStore.end(); ++it)
|
||||
{
|
||||
|
||||
if (toLower(it->getCellRef().mSoul) == toLower(creatureName))
|
||||
if (Misc::StringUtils::toLower(it->getCellRef().mSoul) == Misc::StringUtils::toLower(creatureName))
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
|
|
|
@ -607,16 +607,6 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
std::string toLower (const std::string& name)
|
||||
{
|
||||
std::string lowerCase;
|
||||
|
||||
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||
(int(*)(int)) std::tolower);
|
||||
|
||||
return lowerCase;
|
||||
}
|
||||
|
||||
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
||||
{
|
||||
ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
|
@ -631,7 +621,7 @@ namespace MWWorld
|
|||
{
|
||||
if (isPlayer)
|
||||
if (!newCell.isExterior())
|
||||
changeToInteriorCell(toLower(newCell.mCell->mName), pos);
|
||||
changeToInteriorCell(Misc::StringUtils::toLower(const_cast<std::string &> (newCell.mCell->mName)), pos);
|
||||
else
|
||||
{
|
||||
int cellX = newCell.mCell->getGridX();
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
#include "stringops.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include <string.h>
|
||||
#include <libs/platform/strings.h>
|
||||
|
||||
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
|
|
3
extern/shiny/CMakeLists.txt
vendored
3
extern/shiny/CMakeLists.txt
vendored
|
@ -70,6 +70,3 @@ endif()
|
|||
|
||||
|
||||
link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(SHINY_LIBRARY ${SHINY_LIBRARY} PARENT_SCOPE)
|
||||
set(SHINY_OGREPLATFORM_LIBRARY ${SHINY_OGREPLATFORM_LIBRARY} PARENT_SCOPE)
|
||||
|
|
8
extern/shiny/Main/MaterialInstance.cpp
vendored
8
extern/shiny/Main/MaterialInstance.cpp
vendored
|
@ -72,8 +72,6 @@ namespace sh
|
|||
allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get();
|
||||
}
|
||||
|
||||
bool useShaders = mShadersEnabled || !allowFixedFunction;
|
||||
|
||||
// get passes of the top-most parent
|
||||
PassVector passes = getPasses();
|
||||
if (passes.size() == 0)
|
||||
|
@ -93,7 +91,7 @@ namespace sh
|
|||
// create or retrieve shaders
|
||||
bool hasVertex = it->hasProperty("vertex_program");
|
||||
bool hasFragment = it->hasProperty("fragment_program");
|
||||
if (useShaders)
|
||||
if (mShadersEnabled || !allowFixedFunction)
|
||||
{
|
||||
it->setContext(context);
|
||||
it->mShaderProperties.setContext(context);
|
||||
|
@ -146,7 +144,7 @@ namespace sh
|
|||
bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end();
|
||||
bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end();
|
||||
if ( (foundVertex || foundFragment)
|
||||
|| (((!useShaders || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get()))
|
||||
|| (((!mShadersEnabled || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get()))
|
||||
{
|
||||
boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState ();
|
||||
texIt->copyAll (texUnit.get(), context);
|
||||
|
@ -154,7 +152,7 @@ namespace sh
|
|||
mTexUnits.push_back(texUnit);
|
||||
|
||||
// set texture unit indices (required by GLSL)
|
||||
if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL)
|
||||
if (mShadersEnabled && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL)
|
||||
{
|
||||
pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i);
|
||||
|
||||
|
|
Loading…
Reference in a new issue