[10030] Add aura remove modes for expire and absorb shield break cases and use GetTarget()/GetSpellProto() instead of m_target/m_spellProto

This commit is contained in:
Laise 2010-06-05 09:11:27 +03:00
parent fc3e046348
commit f94175f90f
4 changed files with 1145 additions and 1053 deletions

File diff suppressed because it is too large Load diff

View file

@ -2132,7 +2132,7 @@ void Unit::CalculateAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolMask, D
{ {
if ((*i)->GetModifier()->m_amount<=0) if ((*i)->GetModifier()->m_amount<=0)
{ {
RemoveAurasDueToSpell((*i)->GetId()); RemoveAurasDueToSpell((*i)->GetId(), NULL, AURA_REMOVE_BY_SHIELD_BREAK);
i = vSchoolAbsorb.begin(); i = vSchoolAbsorb.begin();
} }
else else
@ -3312,7 +3312,7 @@ void Unit::_UpdateSpells( uint32 time )
if ((*i).second) if ((*i).second)
{ {
if ( !(*i).second->GetAuraDuration() && !((*i).second->IsPermanent() || ((*i).second->IsPassive())) ) if ( !(*i).second->GetAuraDuration() && !((*i).second->IsPermanent() || ((*i).second->IsPassive())) )
RemoveAura(i); RemoveAura(i, AURA_REMOVE_BY_EXPIRE);
else else
++i; ++i;
} }
@ -4139,14 +4139,14 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
return true; return true;
} }
void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except, AuraRemoveMode mode)
{ {
spellEffectPair spair = spellEffectPair(spellId, effindex); spellEffectPair spair = spellEffectPair(spellId, effindex);
for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);)
{ {
if(iter->second!=except) if(iter->second!=except)
{ {
RemoveAura(iter); RemoveAura(iter, mode);
iter = m_Auras.lower_bound(spair); iter = m_Auras.lower_bound(spair);
} }
else else
@ -4373,10 +4373,10 @@ void Unit::RemoveSingleAuraByCasterSpell(uint32 spellId, SpellEffectIndex effind
} }
void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except, AuraRemoveMode mode)
{ {
for (int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
RemoveAura(spellId,SpellEffectIndex(i),except); RemoveAura(spellId,SpellEffectIndex(i),except, mode);
} }
void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId)

View file

@ -341,6 +341,9 @@ enum AuraRemoveMode
AURA_REMOVE_BY_DISPEL, AURA_REMOVE_BY_DISPEL,
AURA_REMOVE_BY_DEATH, AURA_REMOVE_BY_DEATH,
AURA_REMOVE_BY_DELETE, // use for speedup and prevent unexpected effects at player logout/pet unsummon (must be used _only_ after save), delete. AURA_REMOVE_BY_DELETE, // use for speedup and prevent unexpected effects at player logout/pet unsummon (must be used _only_ after save), delete.
AURA_REMOVE_BY_SHIELD_BREAK, // when absorb shield is removed by damage
AURA_REMOVE_BY_EXPIRE, // at duration end
}; };
enum UnitMods enum UnitMods
@ -1483,10 +1486,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
// removing specific aura stack // removing specific aura stack
void RemoveAura(Aura* aura, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(Aura* aura, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL); void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
// removing specific aura stacks by diff reasons and selections // removing specific aura stacks by diff reasons and selections
void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId);
void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID); void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID);
void RemoveAurasByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID); void RemoveAurasByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10029" #define REVISION_NR "10030"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__