Set magic effects that don't support variable durations to use duration of 1

coverity_scan^2
Allofich 8 years ago
parent 1c2e04747d
commit 610f36f47b

@ -463,7 +463,8 @@ namespace MWMechanics
}
else // target.getClass().isActor() == true
{
if (effectIt->mDuration == 0)
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
if (hasDuration && effectIt->mDuration == 0)
{
// duration 0 means apply full magnitude instantly
bool wasDead = target.getClass().getCreatureStats(target).isDead();
@ -479,7 +480,10 @@ namespace MWMechanics
ActiveSpells::ActiveEffect effect;
effect.mEffectId = effectIt->mEffectID;
effect.mArg = MWMechanics::EffectKey(*effectIt).mArg;
effect.mDuration = static_cast<float>(effectIt->mDuration);
if (!hasDuration)
effect.mDuration = 1.0f;
else
effect.mDuration = static_cast<float>(effectIt->mDuration);
effect.mMagnitude = magnitude;
targetEffects.add(MWMechanics::EffectKey(*effectIt), MWMechanics::EffectParam(effect.mMagnitude));

Loading…
Cancel
Save