Core/Auras: Do not recheck aura positivity every aura effect apply/remove.

This commit is contained in:
QAston
2010-12-31 12:50:17 +01:00
parent 6c56f9e1b7
commit bb4bd46d21
4 changed files with 20 additions and 24 deletions
+1 -1
View File
@@ -3428,7 +3428,7 @@ bool Unit::_IsNoStackAuraDueToAura(Aura * appliedAura, Aura * existingAura) cons
return true;
}
void Unit::_HandleAuraEffect(AuraEffect * aurEff, bool apply)
void Unit::_RegisterAuraEffect(AuraEffect * aurEff, bool apply)
{
if (apply)
m_modAuras[aurEff->GetAuraType()].push_back(aurEff);
+1 -1
View File
@@ -1610,7 +1610,7 @@ class Unit : public WorldObject
void _RemoveNoStackAuraApplicationsDueToAura(Aura * aura);
void _RemoveNoStackAurasDueToAura(Aura * aura);
bool _IsNoStackAuraDueToAura(Aura * appliedAura, Aura * existingAura) const;
void _HandleAuraEffect(AuraEffect * aurEff, bool apply);
void _RegisterAuraEffect(AuraEffect * aurEff, bool apply);
// m_ownedAuras container management
AuraMap & GetOwnedAuras() { return m_ownedAuras; }
+16 -20
View File
@@ -78,14 +78,7 @@ m_effectsToApply(effMask), m_removeMode(AURA_REMOVE_NONE), m_needClientUpdate(fa
sLog->outDebug("Aura: %u Effect: %d could not find empty unit visible slot", GetBase()->GetId(), GetEffectMask());
}
m_isNeedManyNegativeEffects = false;
if (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) // caster == target - 1 negative effect is enough for aura to be negative
m_isNeedManyNegativeEffects = false;
else if (caster)
m_isNeedManyNegativeEffects = caster->IsFriendlyTo(GetTarget());
m_flags |= (_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE) |
(GetBase()->GetCasterGUID() == GetTarget()->GetGUID() ? AFLAG_CASTER : AFLAG_NONE);
_InitFlags(caster, effMask);
}
void AuraApplication::_Remove()
@@ -118,20 +111,28 @@ void AuraApplication::_Remove()
}
}
bool AuraApplication::_CheckPositive(Unit * /*caster*/) const
void AuraApplication::_InitFlags(Unit * caster, uint8 effMask)
{
// mark as selfcasted if needed
m_flags |= (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_CASTER : AFLAG_NONE;
// Aura is positive when it is casted by friend and at least one aura is positive
// or when it is casted by enemy and at least one aura is negative
bool needManyNegEffects = false;
if (IsSelfcasted())
needManyNegEffects = false;
else if (caster)
needManyNegEffects = caster->IsFriendlyTo(GetTarget());
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if ((1<<i & GetEffectMask()))
if ((1<<i) & effMask)
{
if (m_isNeedManyNegativeEffects == IsPositiveEffect(GetBase()->GetId(), i))
return m_isNeedManyNegativeEffects;
if (needManyNegEffects == IsPositiveEffect(GetBase()->GetId(), i))
m_flags |= needManyNegEffects ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
}
}
return !m_isNeedManyNegativeEffects;
m_flags |= !needManyNegEffects ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
}
void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)
@@ -142,25 +143,20 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)
ASSERT((1<<effIndex) & m_effectsToApply);
sLog->outDebug("AuraApplication::_HandleEffect: %u, apply: %u: amount: %u", aurEff->GetAuraType(), apply, aurEff->GetAmount());
Unit * caster = GetBase()->GetCaster();
m_flags &= ~(AFLAG_POSITIVE | AFLAG_NEGATIVE);
if (apply)
{
ASSERT(!(m_flags & (1<<effIndex)));
m_flags |= 1<<effIndex;
m_flags |=_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
GetTarget()->_HandleAuraEffect(aurEff, true);
GetTarget()->_RegisterAuraEffect(aurEff, true);
aurEff->HandleEffect(this, AURA_EFFECT_HANDLE_REAL, true);
}
else
{
ASSERT(m_flags & (1<<effIndex));
m_flags &= ~(1<<effIndex);
m_flags |=_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
// remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
GetTarget()->_HandleAuraEffect(aurEff, false);
GetTarget()->_RegisterAuraEffect(aurEff, false);
aurEff->HandleEffect(this, AURA_EFFECT_HANDLE_REAL, false);
// Remove all triggered by aura spells vs unlimited duration
+2 -2
View File
@@ -49,12 +49,11 @@ class AuraApplication
uint8 m_effectsToApply; // Used only at spell hit to determine which effect should be applied
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
bool m_needClientUpdate:1;
bool m_isNeedManyNegativeEffects:1;
explicit AuraApplication(Unit * target, Unit * caster, Aura * base, uint8 effMask);
void _Remove();
private:
bool _CheckPositive(Unit * caster) const;
void _InitFlags(Unit * caster, uint8 effMask);
void _HandleEffect(uint8 effIndex, bool apply);
public:
@@ -66,6 +65,7 @@ class AuraApplication
uint8 GetEffectMask() const { return m_flags & (AFLAG_EFF_INDEX_0 | AFLAG_EFF_INDEX_1 | AFLAG_EFF_INDEX_2); }
bool HasEffect(uint8 effect) const { ASSERT(effect < MAX_SPELL_EFFECTS); return m_flags & (1<<effect); }
bool IsPositive() const { return m_flags & AFLAG_POSITIVE; }
bool IsSelfcasted() const { return m_flags & AFLAG_CASTER; }
uint8 GetEffectsToApply() const { return m_effectsToApply; }
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }