1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-02-01 05:18:26 +00:00
openmw/components/esm3/magiceffects.hpp
Telvanni 4Life 9159788c9b Address reviewer feedback and ran clang-format on modified files:
- Changed reverse lookup map constructor for gmsts, names, and ESM::MagicEffectIds to be more generic.
- Changed refIdToIndex to use map instead of array traversal.
- Removed redundant check from refIdToGmstString.
- Removed sMagicEffectNames and associated map. Removed dead code from loadmgef.cpp/hpp.
- Changed return types of magic effect bindings to RefId.
- Reverted ESMStore search to find.
- Changed std::map to std::unordered_map for faster lookups in resistance and weakness functions.
- Changed loadmgef To methods to pass RefId by value.
- Removed StringRefId alias MagicEffectId.
- Changed all effectId arguments in PR to pass-by-value.
- Removed ESM::MagicEffect::refIdToName function.
- Changed effect key type from long to ESM::RefId in OpGetEffect of mwscript.
- Removed superfluous MWWorld::Store<ESM::GameSettings> argument to MagicEffect store's setUp method.
- Removed transformation code from decompose for ENAM and IRDT structs.
- Changed resistance and weakness maps to initialization to use initialization instead of assignment.
- Changed sGmstEffectIds to constexpr array since all parameters are known at compile time.
- Changed getBoundItemsMap to use an unordered_map and have string_view values.
- MagicEffect store definition removed (uses standard template class TypedDynamicStore).
- Fixed bug in calculating sun damage that would have made vampires daywalkers in Mournhold.
- Removed polymorphic EffectKey constructor and added overload to getOrDefault.
- Placed ESM spec IRDT and ENAM structs in anonymous namespace.
- Added exception if attempting to serialize ENAM subrecords with out of bounds index.
- Added include format statements to satisfy Ubuntu CI linker.
2026-01-08 07:44:06 -05:00

55 lines
1.2 KiB
C++

#ifndef COMPONENTS_ESM_MAGICEFFECTS_H
#define COMPONENTS_ESM_MAGICEFFECTS_H
#include <components/esm/refid.hpp>
#include <map>
#include <string>
#include <tuple>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct MagicEffects
{
// <Effect Id, Base value, Modifier>
std::map<ESM::RefId, std::pair<int32_t, float>> mEffects;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct SummonKey
{
SummonKey(ESM::RefId effectId, const ESM::RefId& sourceId, int32_t index)
: mEffectId(effectId)
, mSourceId(sourceId)
, mEffectIndex(index)
{
}
ESM::RefId mEffectId;
ESM::RefId mSourceId;
int32_t mEffectIndex;
};
inline auto makeTupleRef(const SummonKey& value) noexcept
{
return std::tie(value.mEffectId, value.mSourceId, value.mEffectIndex);
}
inline bool operator==(const SummonKey& l, const SummonKey& r) noexcept
{
return makeTupleRef(l) == makeTupleRef(r);
}
inline bool operator<(const SummonKey& l, const SummonKey& r) noexcept
{
return makeTupleRef(l) < makeTupleRef(r);
}
}
#endif