1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-30 07:21:12 +00:00
OpenMW/components/esm/loadglob.cpp
Stanislav Bas 8b7b3d2a4e Refine DELE handling in ESM records. Add position-independent DELE search
(cherry picked from commit ad353e6dd0b41e388e2ec3fbcc4bf15d1ef71e57)
2015-12-05 07:20:36 +11:00

56 lines
1.1 KiB
C++

#include "loadglob.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Global::sRecordId = REC_GLOB;
Global::Global()
: mIsDeleted(false)
{}
void Global::load (ESMReader &esm)
{
mIsDeleted = false;
mId = esm.getHNString ("NAME");
if (esm.isNextSub ("DELE"))
{
esm.skipHSub();
mIsDeleted = true;
}
else
{
mValue.read (esm, ESM::Variant::Format_Global);
}
}
void Global::save (ESMWriter &esm) const
{
esm.writeHNCString ("NAME", mId);
if (mIsDeleted)
{
esm.writeHNCString ("DELE", "");
}
else
{
mValue.write (esm, ESM::Variant::Format_Global);
}
}
void Global::blank()
{
mValue.setType (ESM::VT_None);
mIsDeleted = false;
}
bool operator== (const Global& left, const Global& right)
{
return left.mId==right.mId && left.mValue==right.mValue;
}
}