aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp2
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h2
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.cpp36
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.h4
4 files changed, 20 insertions, 24 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5d653cf6d47..1459ff2b8c3 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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);
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 3c9de3197ce..f3f9dc70882 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -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; }
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index e0b785529fa..aec536a74d1 100755
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -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
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 07fdde2e0a7..f6dd212d075 100755
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -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; }