1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 22:45:35 +00:00
openmw/components/esm/loadstat.cpp
Stanislav Bas 82363bf318 Make deleted flag a parameter of load/save methods (instead of a record member) in ESM records
(cherry picked from commit 4a16eba716)

Conflicts:
	components/esm/loadland.cpp
	components/esm/loadland.hpp
2015-12-05 11:20:31 +11:00

58 lines
1.4 KiB
C++

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