1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 21:29:56 +00:00
openmw/components/esm3/globalscript.cpp
2023-04-09 00:23:32 +02:00

41 lines
847 B
C++

#include "globalscript.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
void GlobalScript::load(ESMReader& esm)
{
mId = esm.getHNRefId("NAME");
mLocals.load(esm);
mRunning = 0;
esm.getHNOT(mRunning, "RUN_");
mTargetRef = RefNum{};
mTargetId = esm.getHNORefId("TARG");
if (esm.peekNextSub("FRMR"))
mTargetRef = esm.getFormId(true, "FRMR");
}
void GlobalScript::save(ESMWriter& esm) const
{
esm.writeHNRefId("NAME", mId);
mLocals.save(esm);
if (mRunning)
esm.writeHNT("RUN_", mRunning);
if (!mTargetId.empty())
{
esm.writeHNORefId("TARG", mTargetId);
if (mTargetRef.isSet())
esm.writeFormId(mTargetRef, true, "FRMR");
}
}
}