1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/components/esm3/globalscript.cpp
elsid 6d261d38dd
Add functions to read and write ESM::RefId and use them
To be later changed with another implementation.
2023-02-13 22:07:58 +01:00

42 lines
834 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.load(esm, 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())
mTargetRef.save(esm, true, "FRMR");
}
}
}