2011-04-06 16:11:08 +00:00
|
|
|
#include "loadappa.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"
|
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 Apparatus::sRecordId = REC_APPA;
|
|
|
|
|
2011-04-06 16:11:08 +00:00
|
|
|
void Apparatus::load(ESMReader &esm)
|
|
|
|
{
|
2015-02-12 03:56:05 +00:00
|
|
|
bool hasData = false;
|
2013-02-27 22:43:03 +00:00
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
2015-02-12 03:56:05 +00:00
|
|
|
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:
|
|
|
|
mName = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'A','A','D','T'>::value:
|
|
|
|
esm.getHT(mData);
|
|
|
|
hasData = true;
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'S','C','R','I'>::value:
|
|
|
|
mScript = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'I','T','E','X'>::value:
|
|
|
|
mIcon = esm.getHString();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
|
}
|
2013-02-27 22:43:03 +00:00
|
|
|
}
|
2015-02-12 03:56:05 +00:00
|
|
|
if (!hasData)
|
|
|
|
esm.fail("Missing AADT");
|
2011-04-06 16:11:08 +00:00
|
|
|
}
|
2013-02-27 22:43:03 +00:00
|
|
|
|
2013-09-16 10:32:35 +00:00
|
|
|
void Apparatus::save(ESMWriter &esm) const
|
2012-04-06 19:04:30 +00:00
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
esm.writeHNCString("FNAM", mName);
|
|
|
|
esm.writeHNT("AADT", mData, 16);
|
|
|
|
esm.writeHNOCString("SCRI", mScript);
|
|
|
|
esm.writeHNCString("ITEX", mIcon);
|
2011-04-06 16:11:08 +00:00
|
|
|
}
|
2013-05-06 12:10:43 +00:00
|
|
|
|
|
|
|
void Apparatus::blank()
|
|
|
|
{
|
|
|
|
mData.mType = 0;
|
|
|
|
mData.mQuality = 0;
|
|
|
|
mData.mWeight = 0;
|
|
|
|
mData.mValue = 0;
|
|
|
|
mModel.clear();
|
|
|
|
mIcon.clear();
|
|
|
|
mScript.clear();
|
|
|
|
mName.clear();
|
|
|
|
}
|
2011-04-06 16:11:08 +00:00
|
|
|
}
|