[8435] More work in repally passives at spelmod apply/remove.

* Fixed infinity recursion at reapply spell mod aura by self triggering.
* Reapply pet/totems passives.
This commit is contained in:
VladimirMangos 2009-08-29 21:04:04 +04:00
parent d3fec0355c
commit a33ba233c7
3 changed files with 33 additions and 11 deletions

View file

@ -1249,6 +1249,26 @@ bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
return false;
}
void Aura::ReapplyAffectedPassiveAuras( Unit* target )
{
std::set<uint32> affectedPassives;
for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
// permanent passive
if (itr->second->IsPassive() && itr->second->IsPermanent() &&
// non deleted and not same aura (any with same spell id)
!itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
// only applied by self and affected by aura
itr->second->GetCasterGUID() == target->GetGUID() && isAffectedOnSpell(itr->second->GetSpellProto()))
affectedPassives.insert(itr->second->GetId());
for(std::set<uint32>::const_iterator set_itr = affectedPassives.begin(); set_itr != affectedPassives.end(); ++set_itr)
{
target->RemoveAurasDueToSpell(*set_itr);
target->CastSpell(m_target, *set_itr, true);
}
}
/*********************************************************/
/*** BASIC AURA FUNCTION ***/
/*********************************************************/
@ -1305,18 +1325,19 @@ void Aura::HandleAddModifier(bool apply, bool Real)
((Player*)m_target)->AddSpellMod(m_spellmod, apply);
// reaplly talents to own passive persistent auras
std::set<uint32> affectedPassives;
// reapply talents to own passive persistent auras
ReapplyAffectedPassiveAuras(m_target);
for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().begin(); itr != m_target->GetAuras().end(); ++itr)
if (itr->second->IsPassive() && itr->second->IsPermanent() &&
itr->second->GetCasterGUID() == m_target->GetGUID() && isAffectedOnSpell(itr->second->GetSpellProto()))
affectedPassives.insert(itr->second->GetId());
for(std::set<uint32>::const_iterator set_itr = affectedPassives.begin(); set_itr != affectedPassives.end(); ++set_itr)
// re-aplly talents and passives applied to pet (it affected by player spellmods)
if (m_target->GetTypeId() == TYPEID_PLAYER)
{
m_target->RemoveAurasDueToSpell(*set_itr);
m_target->CastSpell(m_target, *set_itr, true);
if(Pet* pet = m_target->GetPet())
ReapplyAffectedPassiveAuras(pet);
for(int i = 0; i < MAX_TOTEM; ++i)
if(m_target->m_TotemSlot[i])
if(Creature* totem = m_target->GetMap()->GetCreature(m_target->m_TotemSlot[i]))
ReapplyAffectedPassiveAuras(totem);
}
}
void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)

View file

@ -341,6 +341,7 @@ class MANGOS_DLL_SPEC Aura
void PeriodicDummyTick();
bool IsCritFromAbilityAura(Unit* caster, uint32& damage);
void ReapplyAffectedPassiveAuras(Unit* target);
Modifier m_modifier;
SpellModifier *m_spellmod;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8434"
#define REVISION_NR "8435"
#endif // __REVISION_NR_H__