1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00

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

This commit is contained in:
elsid 2023-03-03 13:34:06 +01:00
parent cd6a5b5a0e
commit 3975003778
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
2 changed files with 4 additions and 6 deletions

View File

@ -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;

View File

@ -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