1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 18:29:55 +00:00
openmw/components/esm/loadstat.cpp

65 lines
1.5 KiB
C++
Raw Normal View History

#include "loadstat.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
2012-09-17 07:37:50 +00:00
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;
}
}