diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index 8e691d6067..eb54e95016 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -4,7 +4,6 @@ #include #include -#include #include "esmstore.hpp" @@ -12,7 +11,7 @@ namespace MWWorld { Globals::Collection::const_iterator Globals::find(std::string_view name) const { - Collection::const_iterator iter = mVariables.find(Misc::StringUtils::lowerCase(name)); + Collection::const_iterator iter = mVariables.find(name); if (iter == mVariables.end()) throw std::runtime_error("unknown global variable: " + std::string{ name }); @@ -22,7 +21,7 @@ namespace MWWorld Globals::Collection::iterator Globals::find(std::string_view name) { - Collection::iterator iter = mVariables.find(Misc::StringUtils::lowerCase(name)); + Collection::iterator iter = mVariables.find(name); if (iter == mVariables.end()) throw std::runtime_error("unknown global variable: " + std::string{ name }); @@ -38,23 +37,23 @@ namespace MWWorld for (const ESM::Global& esmGlobal : globals) { - mVariables.insert(std::make_pair(Misc::StringUtils::lowerCase(esmGlobal.mId.getRefIdString()), esmGlobal)); + mVariables.emplace(esmGlobal.mId.getRefIdString(), esmGlobal); } } const ESM::Variant& Globals::operator[](std::string_view name) const { - return find(Misc::StringUtils::lowerCase(name))->second.mValue; + return find(name)->second.mValue; } ESM::Variant& Globals::operator[](std::string_view name) { - return find(Misc::StringUtils::lowerCase(name))->second.mValue; + return find(name)->second.mValue; } char Globals::getType(std::string_view name) const { - Collection::const_iterator iter = mVariables.find(Misc::StringUtils::lowerCase(name)); + Collection::const_iterator iter = mVariables.find(name); if (iter == mVariables.end()) return ' '; @@ -80,10 +79,10 @@ namespace MWWorld void Globals::write(ESM::ESMWriter& writer, Loading::Listener& progress) const { - for (Collection::const_iterator iter(mVariables.begin()); iter != mVariables.end(); ++iter) + for (const auto& variable : mVariables) { writer.startRecord(ESM::REC_GLOB); - iter->second.save(writer); + variable.second.save(writer); writer.endRecord(ESM::REC_GLOB); } } @@ -99,7 +98,7 @@ namespace MWWorld // Deleted globals can't appear there, so isDeleted will be ignored here. global.load(reader, isDeleted); - Collection::iterator iter = mVariables.find(Misc::StringUtils::lowerCase(global.mId.getRefIdString())); + Collection::iterator iter = mVariables.find(global.mId.getRefIdString()); if (iter != mVariables.end()) iter->second = global; diff --git a/apps/openmw/mwworld/globals.hpp b/apps/openmw/mwworld/globals.hpp index 337226ce8e..f94023a577 100644 --- a/apps/openmw/mwworld/globals.hpp +++ b/apps/openmw/mwworld/globals.hpp @@ -1,13 +1,14 @@ #ifndef GAME_MWWORLD_GLOBALS_H #define GAME_MWWORLD_GLOBALS_H -#include #include +#include #include #include #include +#include namespace ESM { @@ -27,7 +28,8 @@ namespace MWWorld class Globals { private: - typedef std::map Collection; + using Collection + = std::unordered_map; Collection mVariables; // type, value