From 1e3100d6642bd7b5345eb2ed6552192dc9682626 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 30 Nov 2009 10:58:15 +0300 Subject: [PATCH] [8894] Add missing and avoid redundent Aura::GetCaster calls. --- src/game/SpellAuras.cpp | 82 ++++++++++++++++++++++++---------------- src/shared/revision_nr.h | 2 +- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 1520731db..38f25756b 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2209,8 +2209,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if(!Real) return; - Unit* caster = GetCaster(); - // AT APPLY if(apply) { @@ -2218,12 +2216,13 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { case 1515: // Tame beast // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness - if( caster && m_target->CanHaveThreatList()) - m_target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto()); + if (m_target->CanHaveThreatList()) + if (Unit* caster = GetCaster()) + m_target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto()); return; case 13139: // net-o-matic // root to self part of (root_target->charge->root_self sequence - if(caster) + if (Unit* caster = GetCaster()) caster->CastSpell(caster, 13138, true, NULL, this); return; case 39850: // Rocket Blast @@ -2234,7 +2233,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) m_target->PlayDistanceSound(11965); return; case 46354: // Blood Elf Illusion - if(caster) + if (Unit* caster = GetCaster()) { switch(caster->getGender()) { @@ -2256,11 +2255,12 @@ void Aura::HandleAuraDummy(bool apply, bool Real) } // Earth Shield - if ( caster && GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000))) + if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000))) { // prevent double apply bonuses if(m_target->GetTypeId() != TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) - m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); + if (Unit* caster = GetCaster()) + m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); return; } } @@ -2278,8 +2278,12 @@ void Aura::HandleAuraDummy(bool apply, bool Real) return; } - if( (IsQuestTameSpell(GetId())) && caster && caster->isAlive() && m_target->isAlive()) + if (IsQuestTameSpell(GetId()) && m_target->isAlive()) { + Unit* caster = GetCaster(); + if (!caster || !caster->isAlive()) + return; + uint32 finalSpelId = 0; switch(GetId()) { @@ -2340,20 +2344,22 @@ void Aura::HandleAuraDummy(bool apply, bool Real) } } - if (caster && m_removeMode == AURA_REMOVE_BY_DEATH) + if (m_removeMode == AURA_REMOVE_BY_DEATH) { // Stop caster Arcane Missle chanelling on death if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000800))) { - caster->InterruptSpell(CURRENT_CHANNELED_SPELL); + if (Unit* caster = GetCaster()) + caster->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } // Stop caster Penance chanelling on death if (m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && (m_spellProto->SpellFamilyFlags2 & UI64LIT(0x00000080))) { - caster->InterruptSpell(CURRENT_CHANNELED_SPELL); + if (Unit* caster = GetCaster()) + caster->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } @@ -2376,14 +2382,15 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 24658: { uint32 spellId = 24659; - if (apply && caster) + if (apply) { - const SpellEntry *spell = sSpellStore.LookupEntry(spellId); - if (!spell) + SpellEntry const *spell = sSpellStore.LookupEntry(spellId); + Unit* caster = GetCaster(); + if (!spell || !caster) return; for (int i=0; i < spell->StackAmount; ++i) - caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); + caster->CastSpell(m_target, spellId, true, NULL, NULL, GetCasterGUID()); return; } m_target->RemoveAurasDueToSpell(spellId); @@ -2393,10 +2400,11 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 24661: { uint32 spellId = 24662; - if (apply && caster) + if (apply) { - const SpellEntry *spell = sSpellStore.LookupEntry(spellId); - if (!spell) + SpellEntry const* spell = sSpellStore.LookupEntry(spellId); + Unit* caster = GetCaster(); + if (!spell || !caster) return; for (int i=0; i < spell->StackAmount; ++i) caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); @@ -2408,6 +2416,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) //Summon Fire Elemental case 40133: { + Unit* caster = GetCaster(); if (!caster) return; @@ -2424,6 +2433,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) //Summon Earth Elemental case 40132 : { + Unit* caster = GetCaster(); if (!caster) return; @@ -2499,7 +2509,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) else { int32 bp0 = m_modifier.m_amount; - m_target->CastCustomSpell(caster,48210,&bp0,NULL,NULL,true); + + if (Unit* caster = GetCaster()) + m_target->CastCustomSpell(caster,48210,&bp0,NULL,NULL,true); } } break; @@ -2586,7 +2598,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { if ( apply ) { - if ( caster ) + if (Unit* caster = GetCaster()) // prevent double apply bonuses if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); @@ -2610,7 +2622,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) int32 amount = m_modifier.m_amount / m_stackAmount; m_target->CastCustomSpell(m_target, 33778, &amount, NULL, NULL, true, NULL, this, GetCasterGUID()); - if (caster) + if (Unit* caster = GetCaster()) { int32 returnmana = (GetSpellProto()->ManaCostPercentage * caster->GetCreateMana() / 100) * m_stackAmount / 2; caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID()); @@ -3269,9 +3281,7 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real) { if(Real && !apply) { - Unit* caster = GetCaster(); - Unit* victim = GetTarget(); - if(!caster || caster->GetTypeId() != TYPEID_PLAYER || !victim || m_removeMode != AURA_REMOVE_BY_DEATH) + if(m_removeMode != AURA_REMOVE_BY_DEATH) return; // Item amount if (m_modifier.m_amount <= 0) @@ -3281,6 +3291,11 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real) if(spellInfo->EffectItemType[m_effIndex] == 0) return; + Unit* victim = GetTarget(); + Unit* caster = GetCaster(); + if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + return; + // Soul Shard only from non-grey units if( spellInfo->EffectItemType[m_effIndex] == 6265 && (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) || @@ -4437,20 +4452,21 @@ void Aura::HandlePeriodicEnergize(bool apply, bool Real) { case 54833: // Glyph of Innervate (value%/2 of casters base mana) { - Unit* caster = GetCaster(); - m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * m_maxduration / m_periodicTimer)); + if (Unit* caster = GetCaster()) + m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * m_maxduration / m_periodicTimer)); break; } case 29166: // Innervate (value% of casters base mana) { - Unit* caster = GetCaster(); + if (Unit* caster = GetCaster()) + { + // Glyph of Innervate + if (caster->HasAura(54832)) + caster->CastSpell(caster,54833,true,NULL,this); - // Glyph of Innervate - if (caster && caster->HasAura(54832)) - caster->CastSpell(caster,54833,true,NULL,this); - - m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * m_maxduration / m_periodicTimer)); + m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * m_maxduration / m_periodicTimer)); + } break; } case 48391: // Owlkin Frenzy 2% base mana diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 89e75ae4a..7dc5e951e 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 "8893" + #define REVISION_NR "8894" #endif // __REVISION_NR_H__