From 3065600a86a0ff725b88cb224c5573bb09b84b06 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 4 Feb 2017 17:54:59 +0100 Subject: [PATCH] Skip expensive visitEffectSources call if no summoned creatures or summon effects are active --- apps/openmw/mwmechanics/actors.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 6290109b2..73d6d9cf3 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -732,11 +732,19 @@ namespace MWMechanics } } - UpdateSummonedCreatures updateSummonedCreatures(ptr); - creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures); - if (ptr.getClass().hasInventoryStore(ptr)) - ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures); - updateSummonedCreatures.process(); + bool hasSummonEffect = false; + for (MagicEffects::Collection::const_iterator it = effects.begin(); it != effects.end(); ++it) + if (it->first.mId >= ESM::MagicEffect::SummonScamp && it->first.mId <= ESM::MagicEffect::SummonStormAtronach) + hasSummonEffect = true; + + if (!creatureStats.getSummonedCreatureMap().empty() || !creatureStats.getSummonedCreatureGraveyard().empty() || hasSummonEffect) + { + UpdateSummonedCreatures updateSummonedCreatures(ptr); + creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures); + if (ptr.getClass().hasInventoryStore(ptr)) + ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures); + updateSummonedCreatures.process(); + } } void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration)