1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 13:23:53 +00:00
openmw/components/esm3/globalscript.cpp
elsid c173348cbe
Use default initializers for ESM::RefNum members
Instead of unset function that is removed now and assignments all over the code.
2023-01-10 00:44:51 +01:00

41 lines
922 B
C++

#include "globalscript.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
void GlobalScript::load(ESMReader& esm)
{
mId = ESM::RefId::stringRefId(esm.getHNString("NAME"));
mLocals.load(esm);
mRunning = 0;
esm.getHNOT(mRunning, "RUN_");
mTargetRef = RefNum{};
mTargetId = ESM::RefId::stringRefId(esm.getHNOString("TARG"));
if (esm.peekNextSub("FRMR"))
mTargetRef.load(esm, true, "FRMR");
}
void GlobalScript::save(ESMWriter& esm) const
{
esm.writeHNString("NAME", mId.getRefIdString());
mLocals.save(esm);
if (mRunning)
esm.writeHNT("RUN_", mRunning);
if (!mTargetId.empty())
{
esm.writeHNOString("TARG", mTargetId.getRefIdString());
if (mTargetRef.isSet())
mTargetRef.save(esm, true, "FRMR");
}
}
}