Skip to content

Commit

Permalink
[9279] Move reapply spellmods code in own function.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Jan 31, 2010
1 parent 6b5f2b6 commit 18b246b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 39 deletions.
75 changes: 40 additions & 35 deletions src/game/SpellAuras.cpp
Expand Up @@ -1374,16 +1374,50 @@ void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode )
}
}

/*********************************************************/
/*** BASIC AURA FUNCTION ***/
/*********************************************************/
struct AuraHandleAddModifierHelper
struct ReapplyAffectedPassiveAurasHelper
{
explicit AuraHandleAddModifierHelper(Aura* _aura) : aura(_aura) {}
explicit ReapplyAffectedPassiveAurasHelper(Aura* _aura) : aura(_aura) {}
void operator()(Unit* unit) const { aura->ReapplyAffectedPassiveAuras(unit, true); }
Aura* aura;
};

void Aura::ReapplyAffectedPassiveAuras()
{
// not reapply spell mods with charges (use original value because processed and at remove)
if (m_spellProto->procCharges)
return;

// not reapply some spell mods ops (mostly speedup case)
switch (m_modifier.m_miscvalue)
{
case SPELLMOD_DURATION:
case SPELLMOD_CHARGES:
case SPELLMOD_NOT_LOSE_CASTING_TIME:
case SPELLMOD_CASTING_TIME:
case SPELLMOD_COOLDOWN:
case SPELLMOD_COST:
case SPELLMOD_ACTIVATION_TIME:
case SPELLMOD_CASTING_TIME_OLD:
return;
}

// reapply talents to own passive persistent auras
ReapplyAffectedPassiveAuras(m_target, true);

// re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods)
m_target->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this),true,false,false);

// re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
if (Group* group = ((Player*)m_target)->GetGroup())
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->getSource())
if (member != m_target && member->IsInMap(m_target))
ReapplyAffectedPassiveAuras(member, false);
}

/*********************************************************/
/*** BASIC AURA FUNCTION ***/
/*********************************************************/
void Aura::HandleAddModifier(bool apply, bool Real)
{
if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
Expand Down Expand Up @@ -1424,36 +1458,7 @@ void Aura::HandleAddModifier(bool apply, bool Real)

((Player*)m_target)->AddSpellMod(m_spellmod, apply);

// not reapply spell mods with charges (use original value because processed and at remove)
if (m_spellProto->procCharges)
return;

// not reapply some spell mods ops (mostly speedup case)
switch (m_modifier.m_miscvalue)
{
case SPELLMOD_DURATION:
case SPELLMOD_CHARGES:
case SPELLMOD_NOT_LOSE_CASTING_TIME:
case SPELLMOD_CASTING_TIME:
case SPELLMOD_COOLDOWN:
case SPELLMOD_COST:
case SPELLMOD_ACTIVATION_TIME:
case SPELLMOD_CASTING_TIME_OLD:
return;
}

// reapply talents to own passive persistent auras
ReapplyAffectedPassiveAuras(m_target, true);

// re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods)
m_target->CallForAllControlledUnits(AuraHandleAddModifierHelper(this),true,false,false);

// re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
if (Group* group = ((Player*)m_target)->GetGroup())
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->getSource())
if (member != m_target && member->IsInMap(m_target))
ReapplyAffectedPassiveAuras(member, false);
ReapplyAffectedPassiveAuras();
}

void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
Expand Down
8 changes: 5 additions & 3 deletions src/game/SpellAuras.h
Expand Up @@ -37,7 +37,7 @@ struct ProcTriggerSpell;
class Aura;

// internal helper
struct AuraHandleAddModifierHelper;
struct ReapplyAffectedPassiveAurasHelper;

typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
// Real == true at aura add/remove
Expand All @@ -55,7 +55,7 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);

class MANGOS_DLL_SPEC Aura
{
friend struct AuraHandleAddModifierHelper;
friend struct ReapplyAffectedPassiveAurasHelper;
friend Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem);

public:
Expand Down Expand Up @@ -93,6 +93,7 @@ class MANGOS_DLL_SPEC Aura
void HandleAuraFeatherFall(bool Apply, bool Real);
void HandleAuraHover(bool Apply, bool Real);
void HandleAddModifier(bool Apply, bool Real);

void HandleAddTargetTrigger(bool Apply, bool Real);
void HandleAuraModStun(bool Apply, bool Real);
void HandleModDamageDone(bool Apply, bool Real);
Expand Down Expand Up @@ -361,7 +362,7 @@ class MANGOS_DLL_SPEC Aura
void PeriodicDummyTick();

bool IsCritFromAbilityAura(Unit* caster, uint32& damage);
void ReapplyAffectedPassiveAuras(Unit* target, bool owner_mode);
void ReapplyAffectedPassiveAuras();

Modifier m_modifier;
SpellModifier *m_spellmod;
Expand Down Expand Up @@ -404,6 +405,7 @@ class MANGOS_DLL_SPEC Aura
private:
void CleanupTriggeredSpells();
bool IsNeedVisibleSlot(Unit const* caster) const; // helper for check req. visibility slot
void ReapplyAffectedPassiveAuras(Unit* target, bool owner_mode);
};

class MANGOS_DLL_SPEC AreaAura : public Aura
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9278"
#define REVISION_NR "9279"
#endif // __REVISION_NR_H__

0 comments on commit 18b246b

Please sign in to comment.