Fix signature of MWMechanics::MagicEffects::get. Fix a mistake in the docs.

simplify_debugging
Mads Buvik Sandvei 1 year ago
parent 03ff03005d
commit 85a30c9ad0

@ -564,10 +564,9 @@ namespace MWLua
key = MWMechanics::EffectKey(id, ESM::Skill::stringToSkillId(argStr.value())); key = MWMechanics::EffectKey(id, ESM::Skill::stringToSkillId(argStr.value()));
} }
std::optional<MWMechanics::EffectParam> param;
if (auto* store = effects.getStore()) if (auto* store = effects.getStore())
if (store->get(key, param)) if (auto effect = store->get(key))
return ActiveEffect{ key, param.value() }; return ActiveEffect{ key, effect.value() };
return sol::nullopt; return sol::nullopt;
}; };
} }

@ -158,21 +158,18 @@ namespace MWMechanics
EffectParam MagicEffects::getOrDefault(const EffectKey& key) const EffectParam MagicEffects::getOrDefault(const EffectKey& key) const
{ {
std::optional<EffectParam> param; return get(key).value_or(EffectParam());
get(key, param);
return param.value_or(EffectParam());
} }
bool MagicEffects::get(const EffectKey& key, std::optional<EffectParam>& param) const std::optional<EffectParam> MagicEffects::get(const EffectKey& key) const
{ {
Collection::const_iterator iter = mCollection.find(key); Collection::const_iterator iter = mCollection.find(key);
if (iter != mCollection.end()) if (iter != mCollection.end())
{ {
param = iter->second; return iter->second;
return true;
} }
return false; return std::nullopt;
} }
MagicEffects MagicEffects::diff(const MagicEffects& prev, const MagicEffects& now) MagicEffects MagicEffects::diff(const MagicEffects& prev, const MagicEffects& now)

@ -106,7 +106,7 @@ namespace MWMechanics
void setModifiers(const MagicEffects& effects); void setModifiers(const MagicEffects& effects);
EffectParam getOrDefault(const EffectKey& key) const; EffectParam getOrDefault(const EffectKey& key) const;
bool get(const EffectKey& key, std::optional<EffectParam>& param) const; std::optional<EffectParam> get(const EffectKey& key) const;
///< This function can safely be used for keys that are not present. ///< This function can safely be used for keys that are not present.
static MagicEffects diff(const MagicEffects& prev, const MagicEffects& now); static MagicEffects diff(const MagicEffects& prev, const MagicEffects& now);

@ -595,7 +595,6 @@
--- ---
-- @type ActiveEffect -- @type ActiveEffect
-- @field #ActiveEffect effect @{#ActiveEffect}
-- @field #any affectedSkill @{#SKILL} or nil -- @field #any affectedSkill @{#SKILL} or nil
-- @field #any affectedAttribute @{#ATTRIBUTE} or nil -- @field #any affectedAttribute @{#ATTRIBUTE} or nil
-- @field #string id Effect id string -- @field #string id Effect id string

Loading…
Cancel
Save