1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/components/esm3/magiceffects.cpp

36 lines
840 B
C++

#include "magiceffects.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
void MagicEffects::save(ESMWriter& esm) const
{
for (const auto& [key, params] : mEffects)
{
esm.writeHNT("EFID", key);
esm.writeHNT("BASE", params.first);
esm.writeHNT("MODI", params.second);
}
}
void MagicEffects::load(ESMReader& esm)
{
while (esm.isNextSub("EFID"))
{
int id;
std::pair<int, float> params;
esm.getHT(id);
esm.getHNT(params.first, "BASE");
if (esm.getFormatVersion() <= MaxClearModifiersFormatVersion)
params.second = 0.f;
else
esm.getHNT(params.second, "MODI");
mEffects.emplace(id, params);
}
}
}