From 700dde116e0563ba5aa11f83654e05890496b1b8 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sat, 2 Jul 2016 05:17:24 +0200 Subject: [PATCH] Show remnant corprus effects in magic window --- apps/openmw/mwmechanics/spells.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index b4bf7ca6f..118d3c551 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -249,6 +249,10 @@ namespace MWMechanics void Spells::visitEffectSources(EffectSourceVisitor &visitor) const { + // needed to combine effects from mSpells and mPermanentSpellEffects, + // while still grouping them by their source spell + std::map combinedEffects; + for (TIterator it = begin(); it != end(); ++it) { const ESM::Spell* spell = it->first; @@ -272,7 +276,24 @@ namespace MWMechanics random = it->second.mEffectRands.at(i); float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random; - visitor.visit(MWMechanics::EffectKey(*effectIt), spell->mName, spell->mId, -1, magnitude); + combinedEffects[spell].add(MWMechanics::EffectKey(*effectIt), magnitude); + } + } + + for (std::map::const_iterator it = mPermanentSpellEffects.begin(); + it != mPermanentSpellEffects.end(); ++it) + { + combinedEffects[it->first] += it->second; + } + + for (std::map::const_iterator it = combinedEffects.begin(); + it != combinedEffects.end(); ++it) + { + const ESM::Spell * spell = it->first; + for (MagicEffects::Collection::const_iterator effectIt = it->second.begin(); + effectIt != it->second.end(); ++effectIt) + { + visitor.visit(effectIt->first, spell->mName, spell->mId, -1, effectIt->second.getMagnitude()); } } }