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"
|
2022-01-22 14:58:41 +00:00
|
|
|
#include "components/esm/defs.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-20 14:23:14 +00:00
|
|
|
void BodyPart::load(ESMReader &esm, bool &isDeleted)
|
2015-07-07 12:37:42 +00:00
|
|
|
{
|
2015-07-20 14:23:14 +00:00
|
|
|
isDeleted = false;
|
2021-07-25 09:53:41 +00:00
|
|
|
mRecordFlags = esm.getRecordFlags();
|
2015-07-07 12:37:42 +00:00
|
|
|
|
2015-07-16 16:52:31 +00:00
|
|
|
bool hasName = false;
|
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();
|
2021-10-17 00:52:22 +00:00
|
|
|
switch (esm.retSubName().toInt())
|
2015-07-09 18:45:24 +00:00
|
|
|
{
|
2022-04-11 22:18:39 +00:00
|
|
|
case SREC_NAME:
|
2015-07-16 16:52:31 +00:00
|
|
|
mId = esm.getHString();
|
|
|
|
hasName = true;
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("MODL"):
|
2015-07-09 18:45:24 +00:00
|
|
|
mModel = esm.getHString();
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("FNAM"):
|
2015-07-09 18:45:24 +00:00
|
|
|
mRace = esm.getHString();
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("BYDT"):
|
2022-04-10 11:35:00 +00:00
|
|
|
esm.getHTSized<4>(mData);
|
2015-07-09 18:45:24 +00:00
|
|
|
hasData = true;
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case SREC_DELE:
|
2015-07-20 14:23:14 +00:00
|
|
|
esm.skipHSub();
|
|
|
|
isDeleted = true;
|
|
|
|
break;
|
2015-07-09 18:45:24 +00:00
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
2015-07-16 16:52:31 +00:00
|
|
|
break;
|
2015-07-09 18:45:24 +00:00
|
|
|
}
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
2015-07-09 18:45:24 +00:00
|
|
|
|
2015-07-16 16:52:31 +00:00
|
|
|
if (!hasName)
|
|
|
|
esm.fail("Missing NAME subrecord");
|
2015-07-20 14:23:14 +00:00
|
|
|
if (!hasData && !isDeleted)
|
2015-07-09 18:45:24 +00:00
|
|
|
esm.fail("Missing BYDT subrecord");
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
void BodyPart::save(ESMWriter &esm, bool isDeleted) const
|
2015-07-07 12:37:42 +00:00
|
|
|
{
|
2015-07-09 18:45:24 +00:00
|
|
|
esm.writeHNCString("NAME", mId);
|
2015-07-16 16:52:31 +00:00
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
if (isDeleted)
|
2015-07-09 18:45:24 +00:00
|
|
|
{
|
2021-07-06 04:57:58 +00:00
|
|
|
esm.writeHNString("DELE", "", 3);
|
2015-07-09 18:45:24 +00:00
|
|
|
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();
|
|
|
|
}
|
2011-04-06 16:11:08 +00:00
|
|
|
}
|