2013-12-15 15:16:50 +00:00
|
|
|
#include "globalscript.hpp"
|
|
|
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
|
|
|
|
void GlobalScript::load(ESMReader& esm)
|
2013-12-15 15:16:50 +00:00
|
|
|
{
|
2023-02-12 18:36:56 +00:00
|
|
|
mId = esm.getHNRefId("NAME");
|
2013-12-15 15:16:50 +00:00
|
|
|
|
|
|
|
mLocals.load(esm);
|
|
|
|
|
|
|
|
mRunning = 0;
|
|
|
|
esm.getHNOT(mRunning, "RUN_");
|
2014-07-15 11:05:38 +00:00
|
|
|
|
2023-01-09 09:45:07 +00:00
|
|
|
mTargetRef = RefNum{};
|
2023-02-12 18:36:56 +00:00
|
|
|
mTargetId = esm.getHNORefId("TARG");
|
2020-05-10 12:57:06 +00:00
|
|
|
if (esm.peekNextSub("FRMR"))
|
|
|
|
mTargetRef.load(esm, true, "FRMR");
|
2013-12-15 15:16:50 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void GlobalScript::save(ESMWriter& esm) const
|
2013-12-15 15:16:50 +00:00
|
|
|
{
|
2023-02-12 18:36:56 +00:00
|
|
|
esm.writeHNRefId("NAME", mId);
|
2013-12-15 15:16:50 +00:00
|
|
|
|
|
|
|
mLocals.save(esm);
|
|
|
|
|
|
|
|
if (mRunning)
|
|
|
|
esm.writeHNT("RUN_", mRunning);
|
2014-07-15 11:05:38 +00:00
|
|
|
|
2020-05-10 12:57:06 +00:00
|
|
|
if (!mTargetId.empty())
|
|
|
|
{
|
2023-02-12 18:36:56 +00:00
|
|
|
esm.writeHNORefId("TARG", mTargetId);
|
2021-01-22 14:48:37 +00:00
|
|
|
if (mTargetRef.isSet())
|
2020-05-10 12:57:06 +00:00
|
|
|
mTargetRef.save(esm, true, "FRMR");
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2020-05-10 12:57:06 +00:00
|
|
|
}
|
2022-04-11 22:18:39 +00:00
|
|
|
|
|
|
|
}
|