[Client] Clear FortifyAttribute effects when server sets modifier to 0

0.6.2
David Cernat 7 years ago
parent 2944be18ae
commit 047ad40b96

@ -295,6 +295,30 @@ namespace MWMechanics
mSpellsChanged = true; mSpellsChanged = true;
} }
/*
Start of tes3mp addition
Allow the purging of an effect for a specific arg (attribute or skill)
*/
void ActiveSpells::purgeEffectByArg(short effectId, int effectArg)
{
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); ++it)
{
for (std::vector<ActiveEffect>::iterator effectIt = it->second.mEffects.begin();
effectIt != it->second.mEffects.end();)
{
if (effectIt->mEffectId == effectId && effectIt->mArg == effectArg)
effectIt = it->second.mEffects.erase(effectIt);
else
++effectIt;
}
}
mSpellsChanged = true;
}
/*
End of tes3mp addition
*/
void ActiveSpells::clear() void ActiveSpells::clear()
{ {
mSpells.clear(); mSpells.clear();

@ -94,6 +94,16 @@ namespace MWMechanics
/// Remove all effects with CASTER_LINKED flag that were cast by \a casterActorId /// Remove all effects with CASTER_LINKED flag that were cast by \a casterActorId
void purge (int casterActorId); void purge (int casterActorId);
/*
Start of tes3mp addition
Allow the purging of an effect for a specific arg (attribute or skill)
*/
void purgeEffectByArg(short effectId, int effectArg);
/*
End of tes3mp addition
*/
/// Remove all spells /// Remove all spells
void clear(); void clear();

@ -19,6 +19,7 @@
#include "../mwinput/inputmanagerimp.hpp" #include "../mwinput/inputmanagerimp.hpp"
#include "../mwmechanics/activespells.hpp"
#include "../mwmechanics/aitravel.hpp" #include "../mwmechanics/aitravel.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/mechanicsmanagerimp.hpp" #include "../mwmechanics/mechanicsmanagerimp.hpp"
@ -790,6 +791,12 @@ void LocalPlayer::setAttributes()
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
// If the server wants to clear our attribute's non-zero modifier, we need to remove
// the spell effect causing it, to avoid an infinite loop where the effect keeps resetting
// the modifier
if (creatureStats.mAttributes[i].mMod == 0 && ptrCreatureStats->getAttribute(i).getModifier() > 0)
ptrCreatureStats->getActiveSpells().purgeEffectByArg(ESM::MagicEffect::FortifyAttribute, i);
attributeValue.readState(creatureStats.mAttributes[i]); attributeValue.readState(creatureStats.mAttributes[i]);
ptrCreatureStats->setAttribute(i, attributeValue); ptrCreatureStats->setAttribute(i, attributeValue);
} }

Loading…
Cancel
Save