1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-19 16:21:08 +00:00

Avoid needlessly copying the MagicEffects

This commit is contained in:
Chris Robinson 2013-08-27 21:40:31 -07:00
parent 281fdbd81b
commit 305b5fec0f

View File

@ -136,27 +136,24 @@ namespace MWMechanics
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
{
CreatureStats &creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
const MagicEffects &effects = creatureStats.getMagicEffects();
// attributes
for (int i=0; i<8; ++i)
for(int i = 0;i < ESM::Attribute::Length;++i)
{
int modifier =
creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::FortifyAttribute, i)).mMagnitude;
Stat<int> stat = creatureStats.getAttribute(i);
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).mMagnitude -
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).mMagnitude);
modifier -= creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::DrainAttribute, i)).mMagnitude;
creatureStats.getAttribute(i).setModifier (modifier);
creatureStats.setAttribute(i, stat);
}
// dynamic stats
MagicEffects effects = creatureStats.getMagicEffects();
for(int i = 0;i < 3;++i)
{
DynamicStat<float> stat = creatureStats.getDynamic(i);
stat.setModifier (
effects.get (EffectKey(80+i)).mMagnitude - effects.get (EffectKey(18+i)).mMagnitude);
stat.setModifier(effects.get(EffectKey(80+i)).mMagnitude -
effects.get(EffectKey(18+i)).mMagnitude);
creatureStats.setDynamic(i, stat);
}