2012-09-17 07:37:50 +00:00
|
|
|
#include "effectlist.hpp"
|
|
|
|
|
2012-09-23 18:41:41 +00:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2012-09-17 07:37:50 +00:00
|
|
|
|
2024-02-24 13:03:24 +00:00
|
|
|
#include <components/misc/concepts.hpp>
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2024-02-24 13:03:24 +00:00
|
|
|
template <Misc::SameAsWithoutCvref<ENAMstruct> T>
|
|
|
|
void decompose(T&& v, const auto& f)
|
|
|
|
{
|
|
|
|
f(v.mEffectID, v.mSkill, v.mAttribute, v.mRange, v.mArea, v.mDuration, v.mMagnMin, v.mMagnMax);
|
|
|
|
}
|
2012-09-17 07:37:50 +00:00
|
|
|
|
|
|
|
void EffectList::load(ESMReader& esm)
|
|
|
|
{
|
2014-09-20 11:32:32 +00:00
|
|
|
mList.clear();
|
2012-09-17 07:37:50 +00:00
|
|
|
while (esm.isNextSub("ENAM"))
|
|
|
|
{
|
2015-02-12 03:56:05 +00:00
|
|
|
add(esm);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2012-09-17 07:37:50 +00:00
|
|
|
}
|
|
|
|
|
2024-03-25 13:50:23 +00:00
|
|
|
void EffectList::populate(const std::vector<ENAMstruct>& effects)
|
|
|
|
{
|
|
|
|
mList.clear();
|
|
|
|
for (size_t i = 0; i < effects.size(); i++)
|
|
|
|
mList.push_back({ effects[i], static_cast<uint32_t>(i) });
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectList::updateIndexes()
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < mList.size(); i++)
|
|
|
|
mList[i].mIndex = i;
|
|
|
|
}
|
|
|
|
|
2015-02-12 03:56:05 +00:00
|
|
|
void EffectList::add(ESMReader& esm)
|
|
|
|
{
|
|
|
|
ENAMstruct s;
|
2024-02-24 13:03:24 +00:00
|
|
|
esm.getSubComposite(s);
|
2024-03-25 13:50:23 +00:00
|
|
|
mList.push_back({ s, static_cast<uint32_t>(mList.size()) });
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 10:32:35 +00:00
|
|
|
void EffectList::save(ESMWriter& esm) const
|
2012-09-17 07:37:50 +00:00
|
|
|
{
|
2024-03-25 13:50:23 +00:00
|
|
|
for (const IndexedENAMstruct& enam : mList)
|
2013-09-16 10:32:35 +00:00
|
|
|
{
|
2024-03-25 13:50:23 +00:00
|
|
|
esm.writeNamedComposite("ENAM", enam.mData);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2012-09-17 07:37:50 +00:00
|
|
|
}
|
|
|
|
|
2024-03-25 13:50:23 +00:00
|
|
|
bool IndexedENAMstruct::operator!=(const IndexedENAMstruct& rhs) const
|
|
|
|
{
|
|
|
|
return mData.mEffectID != rhs.mData.mEffectID || mData.mArea != rhs.mData.mArea
|
|
|
|
|| mData.mRange != rhs.mData.mRange || mData.mSkill != rhs.mData.mSkill
|
|
|
|
|| mData.mAttribute != rhs.mData.mAttribute || mData.mMagnMin != rhs.mData.mMagnMin
|
|
|
|
|| mData.mMagnMax != rhs.mData.mMagnMax || mData.mDuration != rhs.mData.mDuration;
|
|
|
|
}
|
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
} // end namespace
|