1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 22:53:53 +00:00
openmw/components/esm3/magiceffects.cpp

36 lines
848 B
C++
Raw Normal View History

#include "magiceffects.hpp"
#include "esmreader.hpp"
2022-09-22 18:26:05 +00:00
#include "esmwriter.hpp"
namespace ESM
{
2022-09-22 18:26:05 +00:00
void MagicEffects::save(ESMWriter& esm) const
{
2022-09-22 18:26:05 +00:00
for (const auto& [key, params] : mEffects)
{
esm.writeHNT("EFID", key);
esm.writeHNT("BASE", params.first);
esm.writeHNT("MODI", params.second);
}
}
2022-09-22 18:26:05 +00:00
void MagicEffects::load(ESMReader& esm)
{
2022-09-22 18:26:05 +00:00
while (esm.isNextSub("EFID"))
{
2023-10-24 17:25:52 +00:00
int32_t id;
std::pair<int32_t, float> params;
2022-09-22 18:26:05 +00:00
esm.getHT(id);
esm.getHNT(params.first, "BASE");
if (esm.getFormatVersion() <= MaxClearModifiersFormatVersion)
2022-09-22 18:26:05 +00:00
params.second = 0.f;
else
esm.getHNT(params.second, "MODI");
mEffects.emplace(id, params);
}
}
}