2011-04-06 16:11:08 +00:00
|
|
|
#include "loadbody.hpp"
|
|
|
|
|
2012-09-23 18:41:41 +00:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2013-09-24 11:17:28 +00:00
|
|
|
#include "defs.hpp"
|
2015-07-07 12:37:42 +00:00
|
|
|
#include "util.hpp"
|
2012-09-17 07:37:50 +00:00
|
|
|
|
2011-04-06 16:11:08 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
unsigned int BodyPart::sRecordId = REC_BODY;
|
|
|
|
|
2015-07-09 18:45:24 +00:00
|
|
|
BodyPart::BodyPart()
|
|
|
|
: mIsDeleted(false)
|
|
|
|
{}
|
2011-04-06 16:11:08 +00:00
|
|
|
|
2015-07-09 18:45:24 +00:00
|
|
|
void BodyPart::load(ESMReader &esm)
|
2015-07-07 12:37:42 +00:00
|
|
|
{
|
2015-07-09 18:45:24 +00:00
|
|
|
mId = esm.getHNString("NAME");
|
|
|
|
if (mIsDeleted = readDeleSubRecord(esm))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-07-07 12:37:42 +00:00
|
|
|
|
2015-07-09 18:45:24 +00:00
|
|
|
bool hasData = false;
|
|
|
|
while (esm.hasMoreSubs())
|
2015-02-12 03:56:05 +00:00
|
|
|
{
|
2015-07-09 18:45:24 +00:00
|
|
|
esm.getSubName();
|
|
|
|
uint32_t name = esm.retSubName().val;
|
|
|
|
switch (name)
|
|
|
|
{
|
|
|
|
case ESM::FourCC<'M','O','D','L'>::value:
|
|
|
|
mModel = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'F','N','A','M'>::value:
|
|
|
|
mRace = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'B','Y','D','T'>::value:
|
|
|
|
esm.getHT(mData, 4);
|
|
|
|
hasData = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
|
}
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
2015-07-09 18:45:24 +00:00
|
|
|
|
|
|
|
if (!hasData)
|
|
|
|
esm.fail("Missing BYDT subrecord");
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
|
|
|
|
2015-07-09 18:45:24 +00:00
|
|
|
void BodyPart::save(ESMWriter &esm) const
|
2015-07-07 12:37:42 +00:00
|
|
|
{
|
2015-07-09 18:45:24 +00:00
|
|
|
esm.writeHNCString("NAME", mId);
|
|
|
|
if (mIsDeleted)
|
|
|
|
{
|
|
|
|
writeDeleSubRecord(esm);
|
|
|
|
return;
|
|
|
|
}
|
2015-07-07 12:37:42 +00:00
|
|
|
|
2015-07-09 18:45:24 +00:00
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
esm.writeHNOCString("FNAM", mRace);
|
|
|
|
esm.writeHNT("BYDT", mData, 4);
|
|
|
|
}
|
2011-04-06 16:11:08 +00:00
|
|
|
|
2014-07-01 10:37:22 +00:00
|
|
|
void BodyPart::blank()
|
|
|
|
{
|
|
|
|
mData.mPart = 0;
|
|
|
|
mData.mVampire = 0;
|
|
|
|
mData.mFlags = 0;
|
|
|
|
mData.mType = 0;
|
|
|
|
|
|
|
|
mModel.clear();
|
|
|
|
mRace.clear();
|
2015-07-07 12:37:42 +00:00
|
|
|
|
|
|
|
mIsDeleted = false;
|
2014-07-01 10:37:22 +00:00
|
|
|
}
|
2011-04-06 16:11:08 +00:00
|
|
|
}
|