|
|
|
@ -3,16 +3,61 @@
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
|
|
|
|
|
#include <components/esm/attr.hpp>
|
|
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
|
{
|
|
|
|
|
int Race::MaleFemale::getValue(bool male) const
|
|
|
|
|
int32_t Race::RADTstruct::getAttribute(ESM::RefId attribute, bool male) const
|
|
|
|
|
{
|
|
|
|
|
int index = ESM::Attribute::refIdToIndex(attribute);
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!male)
|
|
|
|
|
index++;
|
|
|
|
|
return mAttributeValues[static_cast<size_t>(index)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Race::RADTstruct::setAttribute(ESM::RefId attribute, bool male, int32_t value)
|
|
|
|
|
{
|
|
|
|
|
int index = ESM::Attribute::refIdToIndex(attribute);
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
if (!male)
|
|
|
|
|
index++;
|
|
|
|
|
mAttributeValues[static_cast<size_t>(index)] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Race::RADTstruct::load(ESMReader& esm)
|
|
|
|
|
{
|
|
|
|
|
return male ? mMale : mFemale;
|
|
|
|
|
esm.getSubHeader();
|
|
|
|
|
for (auto& bonus : mBonus)
|
|
|
|
|
{
|
|
|
|
|
esm.getT(bonus.mSkill);
|
|
|
|
|
esm.getT(bonus.mBonus);
|
|
|
|
|
}
|
|
|
|
|
esm.getT(mAttributeValues);
|
|
|
|
|
esm.getT(mMaleHeight);
|
|
|
|
|
esm.getT(mFemaleHeight);
|
|
|
|
|
esm.getT(mMaleWeight);
|
|
|
|
|
esm.getT(mFemaleWeight);
|
|
|
|
|
esm.getT(mFlags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Race::MaleFemaleF::getValue(bool male) const
|
|
|
|
|
void Race::RADTstruct::save(ESMWriter& esm) const
|
|
|
|
|
{
|
|
|
|
|
return male ? mMale : mFemale;
|
|
|
|
|
esm.startSubRecord("RADT");
|
|
|
|
|
for (const auto& bonus : mBonus)
|
|
|
|
|
{
|
|
|
|
|
esm.writeT(bonus.mSkill);
|
|
|
|
|
esm.writeT(bonus.mBonus);
|
|
|
|
|
}
|
|
|
|
|
esm.writeT(mAttributeValues);
|
|
|
|
|
esm.writeT(mMaleHeight);
|
|
|
|
|
esm.writeT(mFemaleHeight);
|
|
|
|
|
esm.writeT(mMaleWeight);
|
|
|
|
|
esm.writeT(mFemaleWeight);
|
|
|
|
|
esm.writeT(mFlags);
|
|
|
|
|
esm.endRecord("RADT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Race::load(ESMReader& esm, bool& isDeleted)
|
|
|
|
@ -37,7 +82,7 @@ namespace ESM
|
|
|
|
|
mName = esm.getHString();
|
|
|
|
|
break;
|
|
|
|
|
case fourCC("RADT"):
|
|
|
|
|
esm.getHTSized<140>(mData);
|
|
|
|
|
mData.load(esm);
|
|
|
|
|
hasData = true;
|
|
|
|
|
break;
|
|
|
|
|
case fourCC("DESC"):
|
|
|
|
@ -71,7 +116,7 @@ namespace ESM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
esm.writeHNOCString("FNAM", mName);
|
|
|
|
|
esm.writeHNT("RADT", mData, 140);
|
|
|
|
|
mData.save(esm);
|
|
|
|
|
mPowers.save(esm);
|
|
|
|
|
esm.writeHNOString("DESC", mDescription);
|
|
|
|
|
}
|
|
|
|
@ -90,11 +135,10 @@ namespace ESM
|
|
|
|
|
bonus.mBonus = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& attribute : mData.mAttributeValues)
|
|
|
|
|
attribute.mMale = attribute.mFemale = 1;
|
|
|
|
|
mData.mAttributeValues.fill(1);
|
|
|
|
|
|
|
|
|
|
mData.mHeight.mMale = mData.mHeight.mFemale = 1;
|
|
|
|
|
mData.mWeight.mMale = mData.mWeight.mFemale = 1;
|
|
|
|
|
mData.mMaleHeight = mData.mFemaleHeight = 1;
|
|
|
|
|
mData.mMaleWeight = mData.mFemaleWeight = 1;
|
|
|
|
|
|
|
|
|
|
mData.mFlags = 0;
|
|
|
|
|
}
|
|
|
|
|