2011-04-08 13:58:21 +00:00
|
|
|
#include "loadench.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-08 13:58:21 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
unsigned int Enchantment::sRecordId = REC_ENCH;
|
2011-04-08 13:58:21 +00:00
|
|
|
|
|
|
|
void Enchantment::load(ESMReader &esm)
|
|
|
|
{
|
2015-02-12 03:56:05 +00:00
|
|
|
mEffects.mList.clear();
|
|
|
|
bool hasData = false;
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
|
|
|
uint32_t name = esm.retSubName().val;
|
|
|
|
switch (name)
|
|
|
|
{
|
|
|
|
case ESM::FourCC<'E','N','D','T'>::value:
|
|
|
|
esm.getHT(mData, 16);
|
|
|
|
hasData = true;
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'E','N','A','M'>::value:
|
|
|
|
mEffects.add(esm);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!hasData)
|
|
|
|
esm.fail("Missing ENDT subrecord");
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
2012-09-17 07:37:50 +00:00
|
|
|
|
2013-09-16 10:32:35 +00:00
|
|
|
void Enchantment::save(ESMWriter &esm) const
|
2012-04-06 19:04:30 +00:00
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNT("ENDT", mData, 16);
|
|
|
|
mEffects.save(esm);
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
|
2014-06-30 18:40:34 +00:00
|
|
|
void Enchantment::blank()
|
|
|
|
{
|
|
|
|
mData.mType = 0;
|
|
|
|
mData.mCost = 0;
|
|
|
|
mData.mCharge = 0;
|
|
|
|
mData.mAutocalc = 0;
|
|
|
|
|
|
|
|
mEffects.mList.clear();
|
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|