2011-04-08 13:58:21 +00:00
|
|
|
#include "loadcrea.hpp"
|
|
|
|
|
2012-09-23 18:41:41 +00:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2012-09-17 07:37:50 +00:00
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
namespace ESM {
|
|
|
|
|
2012-04-08 09:51:52 +00:00
|
|
|
void Creature::load(ESMReader &esm)
|
2011-04-08 13:58:21 +00:00
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
mModel = esm.getHNString("MODL");
|
|
|
|
mOriginal = esm.getHNOString("CNAM");
|
|
|
|
mName = esm.getHNOString("FNAM");
|
|
|
|
mScript = esm.getHNOString("SCRI");
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.getHNT(mData, "NPDT", 96);
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.getHNT(mFlags, "FLAG");
|
|
|
|
mScale = 1.0;
|
|
|
|
esm.getHNOT(mScale, "XSCL");
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
mInventory.load(esm);
|
2012-08-29 17:35:06 +00:00
|
|
|
mSpells.load(esm);
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-05-17 11:12:38 +00:00
|
|
|
if (esm.isNextSub("AIDT"))
|
|
|
|
{
|
2012-08-29 17:35:06 +00:00
|
|
|
esm.getHExact(&mAiData, sizeof(mAiData));
|
|
|
|
mHasAI = true;
|
2012-05-17 11:12:38 +00:00
|
|
|
}
|
|
|
|
else
|
2012-08-29 17:35:06 +00:00
|
|
|
mHasAI = false;
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-08-29 17:35:06 +00:00
|
|
|
mAiPackage.load(esm);
|
2011-04-08 13:58:21 +00:00
|
|
|
esm.skipRecord();
|
|
|
|
}
|
|
|
|
|
2012-04-06 19:04:30 +00:00
|
|
|
void Creature::save(ESMWriter &esm)
|
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
esm.writeHNOCString("CNAM", mOriginal);
|
|
|
|
esm.writeHNOCString("FNAM", mName);
|
|
|
|
esm.writeHNOCString("SCRI", mScript);
|
|
|
|
esm.writeHNT("NPDT", mData, 96);
|
|
|
|
esm.writeHNT("FLAG", mFlags);
|
|
|
|
if (mScale != 1.0) {
|
|
|
|
esm.writeHNT("XSCL", mScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
mInventory.save(esm);
|
|
|
|
mSpells.save(esm);
|
2012-09-18 15:30:19 +00:00
|
|
|
if (mHasAI) {
|
|
|
|
esm.writeHNT("AIDT", mAiData, sizeof(mAiData));
|
|
|
|
}
|
2012-09-17 07:37:50 +00:00
|
|
|
mAiPackage.save(esm);
|
2012-04-06 19:04:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|