#include "loadstat.hpp" #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" namespace ESM { unsigned int Static::sRecordId = REC_STAT; Static::Static() : mIsDeleted(false) {} void Static::load(ESMReader &esm) { mIsDeleted = false; bool hasName = false; while (esm.hasMoreSubs()) { esm.getSubName(); uint32_t name = esm.retSubName().val; switch (name) { case ESM::FourCC<'N','A','M','E'>::value: mId = esm.getHString(); hasName = true; break; case ESM::FourCC<'D','E','L','E'>::value: esm.skipHSub(); mIsDeleted = true; break; case ESM::FourCC<'M','O','D','L'>::value: mModel = esm.getHString(); break; default: esm.fail("Unknown subrecord"); break; } } if (!hasName) esm.fail("Missing NAME subrecord"); } void Static::save(ESMWriter &esm) const { esm.writeHNCString("NAME", mId); if (mIsDeleted) { esm.writeHNCString("DELE", ""); } else { esm.writeHNCString("MODL", mModel); } } void Static::blank() { mModel.clear(); mIsDeleted = false; } }