mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-12 04:14:05 +00:00
Issue #256: added operator+= for MagicEffects
This commit is contained in:
parent
79055e281d
commit
5236bcb557
@ -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
|
||||
{
|
||||
Collection::const_iterator iter = mCollection.find (key);
|
||||
|
@ -69,6 +69,8 @@ namespace MWMechanics
|
||||
|
||||
void add (const ESM::EffectList& list);
|
||||
|
||||
MagicEffects& operator+= (const MagicEffects& effects);
|
||||
|
||||
EffectParam get (const EffectKey& key) const;
|
||||
///< This function can safely be used for keys that are not present.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user