1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 09:15:35 +00:00
openmw/components/esm3/globalscript.cpp
2022-09-22 21:35:26 +03:00

41 lines
835 B
C++

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