1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 20:15:35 +00:00
openmw/components/esm3/globalscript.cpp

42 lines
847 B
C++
Raw Normal View History

#include "globalscript.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
2022-09-22 18:26:05 +00:00
void GlobalScript::load(ESMReader& esm)
{
mId = esm.getHNRefId("NAME");
2022-09-22 18:26:05 +00:00
mLocals.load(esm);
2022-09-22 18:26:05 +00:00
mRunning = 0;
esm.getHNOT(mRunning, "RUN_");
mTargetRef = RefNum{};
mTargetId = esm.getHNORefId("TARG");
2022-09-22 18:26:05 +00:00
if (esm.peekNextSub("FRMR"))
2023-04-07 00:14:32 +00:00
mTargetRef = esm.getFormId(true, "FRMR");
2022-09-22 18:26:05 +00:00
}
2022-09-22 18:26:05 +00:00
void GlobalScript::save(ESMWriter& esm) const
{
esm.writeHNRefId("NAME", mId);
2022-09-22 18:26:05 +00:00
mLocals.save(esm);
2022-09-22 18:26:05 +00:00
if (mRunning)
esm.writeHNT("RUN_", mRunning);
2022-09-22 18:26:05 +00:00
if (!mTargetId.empty())
{
esm.writeHNORefId("TARG", mTargetId);
2022-09-22 18:26:05 +00:00
if (mTargetRef.isSet())
2023-04-07 00:14:32 +00:00
esm.writeFormId(mTargetRef, true, "FRMR");
2022-09-22 18:26:05 +00:00
}
}
}