mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
To change fewer things with the master implementation, the Id isn't changed to lower case on creation
lower case utility functions used in comparison functions
This commit is contained in:
parent
65cdd489fb
commit
d49f60d2d6
@ -38,7 +38,7 @@ namespace MWWorld
|
||||
|
||||
for (const ESM::Global& esmGlobal : globals)
|
||||
{
|
||||
mVariables.insert(std::make_pair(esmGlobal.mId.getRefIdString(), esmGlobal));
|
||||
mVariables.insert(std::make_pair(Misc::StringUtils::lowerCase(esmGlobal.mId.getRefIdString()), esmGlobal));
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ namespace MWWorld
|
||||
// Deleted globals can't appear there, so isDeleted will be ignored here.
|
||||
global.load(reader, isDeleted);
|
||||
|
||||
Collection::iterator iter = mVariables.find(global.mId.getRefIdString());
|
||||
Collection::iterator iter = mVariables.find(Misc::StringUtils::lowerCase(global.mId.getRefIdString()));
|
||||
if (iter != mVariables.end())
|
||||
iter->second = global;
|
||||
|
||||
|
@ -8,17 +8,17 @@ namespace ESM
|
||||
{
|
||||
bool RefId::operator==(const RefId& rhs) const
|
||||
{
|
||||
return this->mId == rhs.mId;
|
||||
return Misc::StringUtils::ciEqual(mId, rhs.mId);
|
||||
}
|
||||
|
||||
bool RefId::operator<(const RefId& rhs) const
|
||||
{
|
||||
return mId < rhs.mId;
|
||||
return Misc::StringUtils::ciLess(mId, rhs.mId);
|
||||
}
|
||||
|
||||
bool RefId::operator>(const RefId& rhs) const
|
||||
{
|
||||
return mId > rhs.mId;
|
||||
return Misc::StringUtils::ciMore(mId, rhs.mId);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const RefId& refId)
|
||||
@ -30,7 +30,7 @@ namespace ESM
|
||||
RefId RefId::stringRefId(std::string_view id)
|
||||
{
|
||||
RefId newRefId;
|
||||
newRefId.mId = Misc::StringUtils::lowerCase(id);
|
||||
newRefId.mId = id;
|
||||
return newRefId;
|
||||
}
|
||||
|
||||
@ -41,3 +41,8 @@ namespace ESM
|
||||
|
||||
const RefId RefId::sEmpty = {};
|
||||
}
|
||||
|
||||
std::size_t std::hash<ESM::RefId>::operator()(const ESM::RefId& k) const
|
||||
{
|
||||
return Misc::StringUtils::CiHash()(k.getRefIdString());
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace std
|
||||
template <>
|
||||
struct hash<ESM::RefId>
|
||||
{
|
||||
std::size_t operator()(const ESM::RefId& k) const { return std::hash<std::string>()(k.getRefIdString()); }
|
||||
std::size_t operator()(const ESM::RefId& k) const;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -20,6 +20,16 @@ namespace Misc::StringUtils
|
||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharLess());
|
||||
}
|
||||
|
||||
struct CiCharMore
|
||||
{
|
||||
bool operator()(char x, char y) const { return toLower(x) > toLower(y); }
|
||||
};
|
||||
|
||||
inline bool ciMore(std::string_view x, std::string_view y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharMore());
|
||||
}
|
||||
|
||||
inline bool ciEqual(std::string_view x, std::string_view y)
|
||||
{
|
||||
if (std::size(x) != std::size(y))
|
||||
|
Loading…
Reference in New Issue
Block a user