mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 16:11:37 -04:00
Remove NAME handling from MWWorld::Globals
(cherry picked from commit 897a52cdda1cec48833af47c2798b6836c9f4d36)
This commit is contained in:
parent
2564eb9841
commit
f8b0cfc637
@ -13,7 +13,7 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
Globals::Collection::const_iterator Globals::find (const std::string& name) const
|
Globals::Collection::const_iterator Globals::find (const std::string& name) const
|
||||||
{
|
{
|
||||||
Collection::const_iterator iter = mVariables.find (name);
|
Collection::const_iterator iter = mVariables.find (Misc::StringUtils::lowerCase (name));
|
||||||
|
|
||||||
if (iter==mVariables.end())
|
if (iter==mVariables.end())
|
||||||
throw std::runtime_error ("unknown global variable: " + name);
|
throw std::runtime_error ("unknown global variable: " + name);
|
||||||
@ -23,7 +23,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
Globals::Collection::iterator Globals::find (const std::string& name)
|
Globals::Collection::iterator Globals::find (const std::string& name)
|
||||||
{
|
{
|
||||||
Collection::iterator iter = mVariables.find (name);
|
Collection::iterator iter = mVariables.find (Misc::StringUtils::lowerCase (name));
|
||||||
|
|
||||||
if (iter==mVariables.end())
|
if (iter==mVariables.end())
|
||||||
throw std::runtime_error ("unknown global variable: " + name);
|
throw std::runtime_error ("unknown global variable: " + name);
|
||||||
@ -40,28 +40,28 @@ namespace MWWorld
|
|||||||
for (MWWorld::Store<ESM::Global>::iterator iter = globals.begin(); iter!=globals.end();
|
for (MWWorld::Store<ESM::Global>::iterator iter = globals.begin(); iter!=globals.end();
|
||||||
++iter)
|
++iter)
|
||||||
{
|
{
|
||||||
mVariables.insert (std::make_pair (iter->mId, iter->mValue));
|
mVariables.insert (std::make_pair (Misc::StringUtils::lowerCase (iter->mId), *iter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ESM::Variant& Globals::operator[] (const std::string& name) const
|
const ESM::Variant& Globals::operator[] (const std::string& name) const
|
||||||
{
|
{
|
||||||
return find (name)->second;
|
return find (Misc::StringUtils::lowerCase (name))->second.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESM::Variant& Globals::operator[] (const std::string& name)
|
ESM::Variant& Globals::operator[] (const std::string& name)
|
||||||
{
|
{
|
||||||
return find (name)->second;
|
return find (Misc::StringUtils::lowerCase (name))->second.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char Globals::getType (const std::string& name) const
|
char Globals::getType (const std::string& name) const
|
||||||
{
|
{
|
||||||
Collection::const_iterator iter = mVariables.find (name);
|
Collection::const_iterator iter = mVariables.find (Misc::StringUtils::lowerCase (name));
|
||||||
|
|
||||||
if (iter==mVariables.end())
|
if (iter==mVariables.end())
|
||||||
return ' ';
|
return ' ';
|
||||||
|
|
||||||
switch (iter->second.getType())
|
switch (iter->second.mValue.getType())
|
||||||
{
|
{
|
||||||
case ESM::VT_Short: return 's';
|
case ESM::VT_Short: return 's';
|
||||||
case ESM::VT_Long: return 'l';
|
case ESM::VT_Long: return 'l';
|
||||||
@ -81,8 +81,7 @@ namespace MWWorld
|
|||||||
for (Collection::const_iterator iter (mVariables.begin()); iter!=mVariables.end(); ++iter)
|
for (Collection::const_iterator iter (mVariables.begin()); iter!=mVariables.end(); ++iter)
|
||||||
{
|
{
|
||||||
writer.startRecord (ESM::REC_GLOB);
|
writer.startRecord (ESM::REC_GLOB);
|
||||||
writer.writeHNString ("NAME", iter->first);
|
iter->second.save (writer);
|
||||||
iter->second.write (writer, ESM::Variant::Format_Global);
|
|
||||||
writer.endRecord (ESM::REC_GLOB);
|
writer.endRecord (ESM::REC_GLOB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,14 +90,13 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
if (type==ESM::REC_GLOB)
|
if (type==ESM::REC_GLOB)
|
||||||
{
|
{
|
||||||
std::string id = reader.getHNString ("NAME");
|
ESM::Global global;
|
||||||
|
global.load(reader);
|
||||||
|
|
||||||
Collection::iterator iter = mVariables.find (Misc::StringUtils::lowerCase (id));
|
Collection::iterator iter = mVariables.find (Misc::StringUtils::lowerCase (global.mId));
|
||||||
|
|
||||||
if (iter!=mVariables.end())
|
if (iter!=mVariables.end())
|
||||||
iter->second.read (reader, ESM::Variant::Format_Global);
|
iter->second = global;
|
||||||
else
|
|
||||||
reader.skipRecord();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <components/interpreter/types.hpp>
|
#include <components/interpreter/types.hpp>
|
||||||
#include <components/esm/variant.hpp>
|
#include <components/esm/loadglob.hpp>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::map<std::string, ESM::Variant> Collection;
|
typedef std::map<std::string, ESM::Global> Collection;
|
||||||
|
|
||||||
Collection mVariables; // type, value
|
Collection mVariables; // type, value
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user