string compare and tolower

actorid
eduard 12 years ago
parent 8545667bbd
commit c75a5ae212

@ -34,6 +34,12 @@ namespace
return sum;
}
bool compare_string_ci(std::string str1, std::string str2)
{
boost::algorithm::to_lower(str1);
return str1 == str2;
}
}
MWWorld::ContainerStore::ContainerStore() : mStateId (0), mCachedWeight (0), mWeightUpToDate (false) {}
@ -75,11 +81,11 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr)
MWWorld::LiveCellRef<ESM::Miscellaneous> *gold =
ptr.get<ESM::Miscellaneous>();
if (Misc::compare_string_ci(gold->ref.mRefID, "gold_001")
|| Misc::compare_string_ci(gold->ref.mRefID, "gold_005")
|| Misc::compare_string_ci(gold->ref.mRefID, "gold_010")
|| Misc::compare_string_ci(gold->ref.mRefID, "gold_025")
|| Misc::compare_string_ci(gold->ref.mRefID, "gold_100"))
if (compare_string_ci(gold->ref.mRefID, "gold_001")
|| compare_string_ci(gold->ref.mRefID, "gold_005")
|| compare_string_ci(gold->ref.mRefID, "gold_010")
|| compare_string_ci(gold->ref.mRefID, "gold_025")
|| compare_string_ci(gold->ref.mRefID, "gold_100"))
{
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001");
@ -87,7 +93,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr)
ref.getPtr().getRefData().setCount(count);
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
{
if (Misc::compare_string_ci((*iter).get<ESM::Miscellaneous>()->ref.mRefID, "gold_001"))
if (compare_string_ci((*iter).get<ESM::Miscellaneous>()->ref.mRefID, "gold_001"))
{
(*iter).getRefData().setCount( (*iter).getRefData().getCount() + count);
flagAsModified();

@ -6,7 +6,6 @@
#include <string.h>
#include <libs/platform/strings.h>
#include <boost/algorithm/string.hpp>
@ -92,10 +91,6 @@ bool stringCompareNoCase (std::string first, std::string second)
else
return false;
}
bool compare_string_ci(std::string str1, std::string str2)
{
boost::algorithm::to_lower(str1);
return str1 == str2;
}
}

@ -18,13 +18,12 @@ bool ibegins(const char* str1, const char* str2);
/// Case insensitive, returns true if str1 ends with substring str2
bool iends(const char* str1, const char* str2);
///
std::string toLower (const std::string& name);
/// Case fold compare
bool stringCompareNoCase (std::string first, std::string second);
bool compare_string_ci (std::string first, std::string second);
}
#endif

Loading…
Cancel
Save