mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-02 00:36:42 +00:00
Issue #256: added operator+= for MagicEffects
This commit is contained in:
parent
79055e281d
commit
5236bcb557
2 changed files with 26 additions and 0 deletions
|
@ -85,6 +85,30 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MagicEffects& MagicEffects::operator+= (const MagicEffects& effects)
|
||||||
|
{
|
||||||
|
if (this==&effects)
|
||||||
|
{
|
||||||
|
MagicEffects temp (effects);
|
||||||
|
*this += temp;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Collection::const_iterator iter (effects.Begin()); iter!=effects.End(); ++iter)
|
||||||
|
{
|
||||||
|
Collection::iterator result = mCollection.find (iter->first);
|
||||||
|
|
||||||
|
if (result!=mCollection.end())
|
||||||
|
{
|
||||||
|
result->second.mMagnitude += iter->second.mMagnitude;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mCollection.insert (*iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
EffectParam MagicEffects::get (const EffectKey& key) const
|
EffectParam MagicEffects::get (const EffectKey& key) const
|
||||||
{
|
{
|
||||||
Collection::const_iterator iter = mCollection.find (key);
|
Collection::const_iterator iter = mCollection.find (key);
|
||||||
|
|
|
@ -69,6 +69,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
void add (const ESM::EffectList& list);
|
void add (const ESM::EffectList& list);
|
||||||
|
|
||||||
|
MagicEffects& operator+= (const MagicEffects& effects);
|
||||||
|
|
||||||
EffectParam get (const EffectKey& key) const;
|
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.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue