Use ESM::RefId as key for Globals::mVariables

depth-refraction
elsid 2 years ago
parent cd6a5b5a0e
commit 3975003778
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -37,7 +37,7 @@ namespace MWWorld
for (const ESM::Global& esmGlobal : globals)
{
mVariables.emplace(esmGlobal.mId.getRefIdString(), esmGlobal);
mVariables.emplace(esmGlobal.mId, esmGlobal);
}
}
@ -98,8 +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(global.mId.getRefIdString());
if (iter != mVariables.end())
if (const auto iter = mVariables.find(global.mId); iter != mVariables.end())
iter->second = global;
return true;

@ -2,8 +2,8 @@
#define GAME_MWWORLD_GLOBALS_H
#include <cstdint>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
#include <components/esm3/loadglob.hpp>
@ -29,8 +29,7 @@ namespace MWWorld
class Globals
{
private:
using Collection
= std::unordered_map<std::string, ESM::Global, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual>;
using Collection = std::map<ESM::RefId, ESM::Global, std::less<>>;
Collection mVariables; // type, value

Loading…
Cancel
Save