From 3443a97a283c2707676a5f1d6d88192ff366a329 Mon Sep 17 00:00:00 2001 From: zergtmn Date: Fri, 17 Jun 2011 22:06:12 +0600 Subject: [PATCH] [11633] Implement function Unit::HasAffectedAura --- src/game/Spell.cpp | 13 ++----------- src/game/SpellAuras.cpp | 12 +++++------- src/game/Unit.cpp | 23 ++++++++++++++++++----- src/game/Unit.h | 1 + src/shared/revision_nr.h | 2 +- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f4d925b6d..4161aa2a4 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4526,19 +4526,10 @@ SpellCastResult Spell::CheckCast(bool strict) } // only check at first call, Stealth auras are already removed at second call // for now, ignore triggered spells - if( strict && !m_IsTriggeredSpell) + if (strict && !m_IsTriggeredSpell) { - bool checkForm = true; // Ignore form req aura - Unit::AuraList const& ignore = m_caster->GetAurasByType(SPELL_AURA_MOD_IGNORE_SHAPESHIFT); - for(Unit::AuraList::const_iterator i = ignore.begin(); i != ignore.end(); ++i) - { - if (!(*i)->isAffectedOnSpell(m_spellInfo)) - continue; - checkForm = false; - break; - } - if (checkForm) + if (!m_caster->HasAffectedAura(SPELL_AURA_MOD_IGNORE_SHAPESHIFT, m_spellInfo)) { // Cannot be used in this stance/form SpellCastResult shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->GetShapeshiftForm()); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 57a97fc47..06dd74fb2 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -8282,17 +8282,15 @@ void Aura::HandleAuraSafeFall( bool Apply, bool Real ) bool Aura::IsCritFromAbilityAura(Unit* caster, uint32& damage) { - Unit::AuraList const& auras = caster->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT); - for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - if (!(*itr)->isAffectedOnSpell(GetSpellProto())) - continue; - if (!caster->IsSpellCrit(GetTarget(), GetSpellProto(), GetSpellSchoolMask(GetSpellProto()))) - break; + if (!caster->HasAffectedAura(SPELL_AURA_ABILITY_PERIODIC_CRIT, GetSpellProto())) + return false; + if (caster->IsSpellCrit(GetTarget(), GetSpellProto(), GetSpellSchoolMask(GetSpellProto()))) + { damage = caster->SpellCriticalDamageBonus(GetSpellProto(), damage, GetTarget()); return true; } + return false; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1e92106f1..888c43aa8 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -488,11 +488,6 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except) } } -bool Unit::HasAuraType(AuraType auraType) const -{ - return (!m_modAuras[auraType].empty()); -} - /* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ void Unit::RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage) { @@ -4919,6 +4914,24 @@ void Unit::_ApplyAllAuraMods() } } +bool Unit::HasAuraType(AuraType auraType) const +{ + return !GetAurasByType(auraType).empty(); +} + +bool Unit::HasAffectedAura(AuraType auraType, SpellEntry const* spellProto) const +{ + Unit::AuraList const& auras = GetAurasByType(auraType); + + for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + if ((*itr)->isAffectedOnSpell(spellProto)) + return true; + } + + return false; +} + Aura* Unit::GetAura(uint32 spellId, SpellEffectIndex effindex) { SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); diff --git a/src/game/Unit.h b/src/game/Unit.h index 4a6e7b818..b299e19f0 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1411,6 +1411,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject } bool HasAuraType(AuraType auraType) const; + bool HasAffectedAura(AuraType auraType, SpellEntry const* spellProto) const; bool HasAura(uint32 spellId, SpellEffectIndex effIndex) const; bool HasAura(uint32 spellId) const { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 693154126..f0eeef85c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11632" + #define REVISION_NR "11633" #endif // __REVISION_NR_H__