2011-04-08 13:58:21 +00:00
|
|
|
#include "loadrace.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 Race::sRecordId = REC_RACE;
|
|
|
|
|
2013-04-04 11:50:36 +00:00
|
|
|
int Race::MaleFemale::getValue (bool male) const
|
|
|
|
{
|
|
|
|
return male ? mMale : mFemale;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Race::MaleFemaleF::getValue (bool male) const
|
|
|
|
{
|
2015-03-08 00:07:29 +00:00
|
|
|
return static_cast<int>(male ? mMale : mFemale);
|
2013-04-04 11:50:36 +00:00
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
|
|
|
|
void Race::load(ESMReader &esm)
|
|
|
|
{
|
2015-02-10 22:16:25 +00:00
|
|
|
mPowers.mList.clear();
|
|
|
|
|
2015-07-07 17:56:26 +00:00
|
|
|
mId = esm.getHNString("NAME");
|
|
|
|
|
2015-02-10 22:16:25 +00:00
|
|
|
bool hasData = false;
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
|
|
|
uint32_t name = esm.retSubName().val;
|
|
|
|
switch (name)
|
|
|
|
{
|
|
|
|
case ESM::FourCC<'F','N','A','M'>::value:
|
|
|
|
mName = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'R','A','D','T'>::value:
|
|
|
|
esm.getHT(mData, 140);
|
|
|
|
hasData = true;
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'D','E','S','C'>::value:
|
|
|
|
mDescription = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'N','P','C','S'>::value:
|
|
|
|
mPowers.add(esm);
|
|
|
|
break;
|
|
|
|
default:
|
2015-02-12 03:56:05 +00:00
|
|
|
esm.fail("Unknown subrecord");
|
2015-02-10 22:16:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!hasData)
|
|
|
|
esm.fail("Missing RADT subrecord");
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
2013-09-16 10:32:35 +00:00
|
|
|
void Race::save(ESMWriter &esm) const
|
2012-04-06 19:04:30 +00:00
|
|
|
{
|
2015-07-07 17:56:26 +00:00
|
|
|
esm.writeHNCString("NAME", mId);
|
2014-04-13 11:23:50 +00:00
|
|
|
esm.writeHNOCString("FNAM", mName);
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNT("RADT", mData, 140);
|
|
|
|
mPowers.save(esm);
|
|
|
|
esm.writeHNOString("DESC", mDescription);
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 12:34:39 +00:00
|
|
|
void Race::blank()
|
|
|
|
{
|
|
|
|
mName.clear();
|
|
|
|
mDescription.clear();
|
|
|
|
|
|
|
|
mPowers.mList.clear();
|
|
|
|
|
|
|
|
for (int i=0; i<7; ++i)
|
|
|
|
{
|
|
|
|
mData.mBonus[i].mSkill = -1;
|
|
|
|
mData.mBonus[i].mBonus = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i<8; ++i)
|
|
|
|
mData.mAttributeValues[i].mMale = mData.mAttributeValues[i].mFemale = 1;
|
|
|
|
|
|
|
|
mData.mHeight.mMale = mData.mHeight.mFemale = 1;
|
|
|
|
mData.mWeight.mMale = mData.mWeight.mFemale = 1;
|
|
|
|
|
|
|
|
mData.mFlags = 0;
|
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|