*Change way of aura removing-make it safer.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-04-07 20:27:34 +02:00
parent 51f53fdc0c
commit 26b856a513
5 changed files with 90 additions and 101 deletions
+1 -2
View File
@@ -6320,8 +6320,7 @@ void Player::DuelComplete(DuelCompleteType type)
++i; ++i;
} }
vAuras = GetAuras(); for(AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
for(AuraMap::iterator i = vAuras.begin(); i != vAuras.end();)
{ {
if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime)
{ {
+26 -36
View File
@@ -344,8 +344,8 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target), m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target),
m_timeCla(1000), m_removeMode(AURA_NO_REMOVE_MODE), m_AuraDRGroup(DIMINISHING_NONE), m_timeCla(1000), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_auraStateMask(0), m_updated(false), m_in_use(false) m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_auraStateMask(0), m_updated(false), m_isRemoved(false)
{ {
assert(target); assert(target);
@@ -462,19 +462,6 @@ m_target(parentAura->GetTarget())
m_effIndex = effIndex; m_effIndex = effIndex;
m_auraName = AuraType(m_spellProto->EffectApplyAuraName[m_effIndex]); m_auraName = AuraType(m_spellProto->EffectApplyAuraName[m_effIndex]);
/*if(currentBasePoints)
{
m_amount = *currentBasePoints;
m_currentBasePoints = m_amount - 1;
}
else
{
m_currentBasePoints = m_spellProto->EffectBasePoints[m_effIndex];
if(caster)
m_amount = caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, m_target);
else
m_amount = m_currentBasePoints + 1;
}*/
if(currentBasePoints) if(currentBasePoints)
m_currentBasePoints = *currentBasePoints; m_currentBasePoints = *currentBasePoints;
else else
@@ -637,12 +624,12 @@ void Aura::Update(uint32 diff)
if (caster->GetHealth()>manaPerSecond) if (caster->GetHealth()>manaPerSecond)
caster->ModifyHealth(-manaPerSecond); caster->ModifyHealth(-manaPerSecond);
else else
RemoveAura(); m_target->RemoveAura(this);
} }
else if (caster->GetPower(powertype)>=manaPerSecond) else if (caster->GetPower(powertype)>=manaPerSecond)
caster->ModifyPower(powertype,-manaPerSecond); caster->ModifyPower(powertype,-manaPerSecond);
else else
RemoveAura(); m_target->RemoveAura(this);
} }
} }
} }
@@ -654,7 +641,7 @@ void Aura::Update(uint32 diff)
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if(!caster) if(!caster)
{ {
RemoveAura(); m_target->RemoveAura(this);
return; return;
} }
// Get spell range // Get spell range
@@ -680,7 +667,7 @@ void Aura::Update(uint32 diff)
if(!caster->IsWithinDistInMap(m_target,radius)) if(!caster->IsWithinDistInMap(m_target,radius))
{ {
RemoveAura(); m_target->RemoveAura(this);
return; return;
} }
} }
@@ -796,7 +783,7 @@ void AreaAuraEffect::Update(uint32 diff)
caster->IsFriendlyTo(tmp_target) != needFriendly caster->IsFriendlyTo(tmp_target) != needFriendly
) )
{ {
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
else if (!caster->IsWithinDistInMap(tmp_target, m_radius)) else if (!caster->IsWithinDistInMap(tmp_target, m_radius))
{ {
@@ -804,10 +791,10 @@ void AreaAuraEffect::Update(uint32 diff)
{ {
m_removeTime -= diff; m_removeTime -= diff;
if (m_removeTime < 0) if (m_removeTime < 0)
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
else else
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
else else
{ {
@@ -816,17 +803,17 @@ void AreaAuraEffect::Update(uint32 diff)
if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
{ {
if(!tmp_target->IsInPartyWith(caster)) if(!tmp_target->IsInPartyWith(caster))
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
else if( m_areaAuraType == AREA_AURA_RAID) else if( m_areaAuraType == AREA_AURA_RAID)
{ {
if(!tmp_target->IsInRaidWith(caster)) if(!tmp_target->IsInRaidWith(caster))
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER ) else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
{ {
if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() ) if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
} }
} }
} }
@@ -854,22 +841,18 @@ void PersistentAreaAuraEffect::Update(uint32 diff)
remove = true; remove = true;
if(remove) if(remove)
GetParentAura()->RemoveAura(); m_target->RemoveAura(GetParentAura());
AuraEffect::Update(diff); AuraEffect::Update(diff);
} }
void AuraEffect::ApplyModifier(bool apply, bool Real) void AuraEffect::ApplyModifier(bool apply, bool Real)
{ {
AuraType aura = m_auraName; if (GetParentAura()->IsRemoved())
return;
bool inuse = GetParentAura()->IsInUse(); if(m_auraName<TOTAL_AURAS)
if (!inuse) (*this.*AuraHandler [m_auraName])(apply,Real);
GetParentAura()->SetInUse(true);
if(aura<TOTAL_AURAS)
(*this.*AuraHandler [aura])(apply,Real);
if (!inuse)
GetParentAura()->SetInUse(false);
} }
void AuraEffect::CleanupTriggeredSpells() void AuraEffect::CleanupTriggeredSpells()
@@ -1078,6 +1061,8 @@ void Aura::_AddAura()
bool Aura::SetPartAura(AuraEffect* aurEff, uint8 effIndex) bool Aura::SetPartAura(AuraEffect* aurEff, uint8 effIndex)
{ {
if (IsRemoved())
return false;
if (m_auraFlags & (1<<effIndex)) if (m_auraFlags & (1<<effIndex))
return false; return false;
m_auraFlags |= 1<<effIndex; m_auraFlags |= 1<<effIndex;
@@ -1138,6 +1123,11 @@ void Aura::_RemoveAura()
m_target->ApplyModFlag(UNIT_FIELD_AURASTATE, foundMask, false); m_target->ApplyModFlag(UNIT_FIELD_AURASTATE, foundMask, false);
} }
// since now aura cannot apply/remove it's modifiers
m_isRemoved = true;
// disable client server communication for removed aura
SetAuraSlot(MAX_AURAS);
// reset cooldown state for spells // reset cooldown state for spells
if(caster && caster->GetTypeId() == TYPEID_PLAYER) if(caster && caster->GetTypeId() == TYPEID_PLAYER)
{ {
@@ -4270,7 +4260,7 @@ void AuraEffect::HandlePeriodicTriggerSpell(bool apply, bool Real)
m_isPeriodic = apply; m_isPeriodic = apply;
if (m_spellProto->Id == 66 && !apply) if (m_spellProto->Id == 66 && !apply)
{ {
if (GetParentAura()->GetRemoveMode() && GetParentAura()->GetAuraDuration()<=0) if (GetParentAura()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
m_target->CastSpell(m_target, 32612, true, NULL, this); m_target->CastSpell(m_target, 32612, true, NULL, this);
} }
} }
@@ -5650,7 +5640,7 @@ void AuraEffect::PeriodicTick()
100; 100;
if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent ) if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent )
{ {
GetParentAura()->RemoveAura(); m_target->RemoveAurasDueToSpell(GetId());
return; return;
} }
break; break;
+2 -5
View File
@@ -92,17 +92,14 @@ class TRINITY_DLL_SPEC Aura
void SetNegative() { m_positive = false; } void SetNegative() { m_positive = false; }
void SetPositive() { m_positive = true; } void SetPositive() { m_positive = true; }
bool IsPermanent() const { return m_permanent; } bool IsPermanent() const { return m_permanent; }
void RemoveAura(AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT) { m_permanent = false; m_duration=0; m_removeMode = mode; }
bool IsPassive() const { return m_isPassive; } bool IsPassive() const { return m_isPassive; }
bool IsDeathPersistent() const { return m_isDeathPersist; } bool IsDeathPersistent() const { return m_isDeathPersist; }
bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; } bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; }
bool IsUpdated() const { return m_updated; } bool IsUpdated() const { return m_updated; }
bool IsRemoved() const { return m_isRemoved; }
void SetUpdated(bool val) { m_updated = val; } void SetUpdated(bool val) { m_updated = val; }
bool IsInUse() const { return m_in_use; }
void SetInUse(bool val) { m_in_use = val; }
bool IsPersistent() const; bool IsPersistent() const;
bool IsAreaAura() const; bool IsAreaAura() const;
bool IsAuraType(AuraType type) const; bool IsAuraType(AuraType type) const;
@@ -158,8 +155,8 @@ class TRINITY_DLL_SPEC Aura
bool m_isPassive:1; bool m_isPassive:1;
bool m_positive:1; bool m_positive:1;
bool m_permanent:1; bool m_permanent:1;
bool m_isRemoved:1;
bool m_updated:1; // Prevent remove aura by stack if set bool m_updated:1; // Prevent remove aura by stack if set
bool m_in_use:1;
bool m_isSingleTargetAura:1; // true if it's a single target spell and registered at caster - can change at spell steal for example bool m_isSingleTargetAura:1; // true if it's a single target spell and registered at caster - can change at spell steal for example
}; };
class TRINITY_DLL_SPEC AuraEffect class TRINITY_DLL_SPEC AuraEffect
+60 -56
View File
@@ -159,7 +159,6 @@ Unit::Unit()
for (int i = 0; i < MAX_MOVE_TYPE; ++i) for (int i = 0; i < MAX_MOVE_TYPE; ++i)
m_speed_rate[i] = 1.0f; m_speed_rate[i] = 1.0f;
m_removedAuras = 0;
m_charmInfo = NULL; m_charmInfo = NULL;
m_unit_movement_flags = 0; m_unit_movement_flags = 0;
m_reducedThreatPercent = 0; m_reducedThreatPercent = 0;
@@ -182,6 +181,14 @@ Unit::~Unit()
} }
} }
for (AuraList::iterator i = m_removedAuras.begin(); i != m_removedAuras.end();i = m_removedAuras.begin())
{
Aura * aur = *i;
sLog.outDebug("Aura %d is deleted from unit %d", aur->GetId(), GetGUIDLow());
m_removedAuras.pop_front();
delete (aur);
}
RemoveAllGameObjects(); RemoveAllGameObjects();
RemoveAllDynObjects(); RemoveAllDynObjects();
@@ -472,7 +479,10 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
++iter; ++iter;
if ((aur->GetSpellProto()->AuraInterruptFlags & flag) && (!except || aur->GetId() != except)) if ((aur->GetSpellProto()->AuraInterruptFlags & flag) && (!except || aur->GetId() != except))
{ {
uint32 removedAuras = m_removedAuras.size();
RemoveAura(aur); RemoveAura(aur);
if (removedAuras+1<m_removedAuras.size())
iter=m_interruptableAuras.begin();
} }
} }
@@ -513,7 +523,10 @@ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell)
++iter; ++iter;
if ((!spell || aur->GetId() != spell) && roll_chance_f(chance)) if ((!spell || aur->GetId() != spell) && roll_chance_f(chance))
{ {
uint32 removedAuras = m_removedAuras.size();
RemoveAura(aur); RemoveAura(aur);
if (removedAuras+1<m_ccAuras.size())
iter=m_interruptableAuras.begin();
} }
} }
} }
@@ -1659,7 +1672,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// victim's damage shield // victim's damage shield
std::set<AuraEffect*> alreadyDone; std::set<AuraEffect*> alreadyDone;
uint32 removedAuras = pVictim->m_removedAuras; uint32 removedAuras = pVictim->m_removedAuras.size();
AuraEffectList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); AuraEffectList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD);
for(AuraEffectList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next) for(AuraEffectList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next)
{ {
@@ -1688,9 +1701,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellProto), spellProto, true); pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellProto), spellProto, true);
if (pVictim->m_removedAuras > removedAuras) if (pVictim->m_removedAuras.size() > removedAuras)
{ {
removedAuras = pVictim->m_removedAuras; removedAuras = pVictim->m_removedAuras.size();
next = vDamageShields.begin(); next = vDamageShields.begin();
} }
} }
@@ -2083,7 +2096,10 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
++i; ++i;
if (auraeff->GetAmount()<=0) if (auraeff->GetAmount()<=0)
{ {
uint32 removedAuras = pVictim->m_removedAuras.size();
pVictim->RemoveAura(aura); pVictim->RemoveAura(aura);
if (removedAuras+1<pVictim->m_removedAuras.size())
i=vSchoolAbsorb.begin();
} }
} }
} }
@@ -3199,11 +3215,9 @@ void Unit::_UpdateSpells( uint32 time )
} }
// TODO: Find a better way to prevent crash when multiple auras are removed. // TODO: Find a better way to prevent crash when multiple auras are removed.
m_removedAuras = 0;
for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
if ((*i).second) if ((*i).second)
(*i).second->SetUpdated(false); (*i).second->SetUpdated(false);
for (AuraMap::iterator i = m_Auras.begin(), next; i != m_Auras.end(); i = next) for (AuraMap::iterator i = m_Auras.begin(), next; i != m_Auras.end(); i = next)
{ {
next = i; next = i;
@@ -3213,16 +3227,15 @@ void Unit::_UpdateSpells( uint32 time )
// prevent double update // prevent double update
if ((*i).second->IsUpdated()) if ((*i).second->IsUpdated())
continue; continue;
uint32 removedAuras = m_removedAuras.size();
(*i).second->SetUpdated(true); (*i).second->SetUpdated(true);
(*i).second->SetInUse(true);
(*i).second->Update( time ); (*i).second->Update( time );
(*i).second->SetInUse(false);
// several auras can be deleted due to update // several auras can be deleted due to update
if (m_removedAuras) if (removedAuras < m_removedAuras.size())
{ {
if (m_Auras.empty()) break; if (m_Auras.empty()) break;
next = m_Auras.begin(); next = m_Auras.begin();
m_removedAuras = 0; removedAuras = m_removedAuras.size();
} }
} }
} }
@@ -3246,6 +3259,14 @@ void Unit::_UpdateSpells( uint32 time )
} }
} }
for (AuraList::iterator i = m_removedAuras.begin(); i != m_removedAuras.end();i = m_removedAuras.begin())
{
Aura * aur = *i;
sLog.outDebug("Aura %d is deleted from unit %d", aur->GetId(), GetGUIDLow());
m_removedAuras.pop_front();
delete (aur);
}
if(!m_gameObj.empty()) if(!m_gameObj.empty())
{ {
std::list<GameObject*>::iterator ite1, dnext1; std::list<GameObject*>::iterator ite1, dnext1;
@@ -3799,7 +3820,6 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
{ {
next = i; next = i;
++next; ++next;
if ((*i).second->IsInUse()) continue;
SpellEntry const* i_spellProto = (*i).second->GetSpellProto(); SpellEntry const* i_spellProto = (*i).second->GetSpellProto();
@@ -3875,12 +3895,9 @@ void Unit::RemoveAura(uint32 spellId, uint64 caster ,AuraRemoveMode removeMode)
void Unit::RemoveAura(Aura * aur ,AuraRemoveMode mode) void Unit::RemoveAura(Aura * aur ,AuraRemoveMode mode)
{ {
if (aur->IsInUse()) // no need to remove
{ if (aur->IsRemoved())
if (!aur->GetRemoveMode())
aur->RemoveAura(mode);
return; return;
}
for(AuraMap::iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId());) for(AuraMap::iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId());)
{ {
if (aur == iter->second) if (aur == iter->second)
@@ -3897,7 +3914,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster ,AuraRemoveMode r
{ {
for(AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);) for(AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);)
{ {
if ((!caster || iter->second->GetCasterGUID()==caster) && (!iter->second->IsInUse() || !iter->second->GetRemoveMode())) if (!caster || iter->second->GetCasterGUID()==caster)
{ {
RemoveAura(iter, removeMode); RemoveAura(iter, removeMode);
iter = m_Auras.lower_bound(spellId); iter = m_Auras.lower_bound(spellId);
@@ -3976,9 +3993,9 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
// Unregister _before_ adding to stealer // Unregister _before_ adding to stealer
aur->UnregisterSingleCastAura(); aur->UnregisterSingleCastAura();
// strange but intended behaviour: Stolen single target auras won't be treated as single targeted // strange but intended behaviour: Stolen single target auras won't be treated as single targeted
new_aur->SetIsSingleTarget(false); new_aur->SetIsSingleTarget(false);
stealer->AddAura(new_aur);
RemoveAuraFromStack(iter, AURA_REMOVE_BY_ENEMY_SPELL); RemoveAuraFromStack(iter, AURA_REMOVE_BY_ENEMY_SPELL);
return; return;
} }
@@ -3991,7 +4008,7 @@ void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId)
{ {
for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);) for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);)
{ {
if ((!castItem || iter->second->GetCastItemGUID()==castItem->GetGUID()) && (!iter->second->IsInUse() || !iter->second->GetRemoveMode())) if (!castItem || iter->second->GetCastItemGUID()==castItem->GetGUID())
{ {
RemoveAura(iter); RemoveAura(iter);
iter = m_Auras.upper_bound(spellId); // overwrite by more appropriate iter = m_Auras.upper_bound(spellId); // overwrite by more appropriate
@@ -4010,7 +4027,10 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except
++iter; ++iter;
if (aur != except && (!casterGUID || aur->GetCasterGUID()==casterGUID)) if (aur != except && (!casterGUID || aur->GetCasterGUID()==casterGUID))
{ {
uint32 removedAuras = m_removedAuras.size();
RemoveAura(aur); RemoveAura(aur);
if (removedAuras+1<m_removedAuras.size())
iter=m_modAuras[auraType].begin();
} }
} }
} }
@@ -4024,7 +4044,10 @@ void Unit::RemoveAurasByTypeWithDispel(AuraType auraType, Spell * spell)
++iter; ++iter;
if (GetDispelChance(spell, aur->GetCaster(), aur->GetId())) if (GetDispelChance(spell, aur->GetCaster(), aur->GetId()))
{ {
uint32 removedAuras = m_removedAuras.size();
RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL); RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL);
if (removedAuras+1<m_removedAuras.size())
iter=m_modAuras[auraType].begin();
} }
} }
} }
@@ -4044,35 +4067,26 @@ void Unit::RemoveNotOwnSingleTargetAuras()
AuraList& scAuras = GetSingleCastAuras(); AuraList& scAuras = GetSingleCastAuras();
for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();) for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
{ {
if ((*iter)->GetTarget()!=this) Aura * aur=*iter;
++iter;
if (aur->GetTarget()!=this)
{ {
Aura * aur=*iter; uint32 removedAuras = m_removedAuras.size();
++iter;
aur->GetTarget()->RemoveAura(aur->GetId(),aur->GetCasterGUID()); aur->GetTarget()->RemoveAura(aur->GetId(),aur->GetCasterGUID());
if (removedAuras+1<m_removedAuras.size())
iter=scAuras.begin();
} }
else
++iter;
} }
} }
void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
{ {
Aura* Aur = i->second; Aura* Aur = i->second;
//aura can be during update when removing, set it to remove at next update
if (Aur->IsInUse())
{
if (!Aur->GetRemoveMode())
Aur->RemoveAura(mode);
i++;
return;
}
SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); SpellEntry const* AurSpellInfo = Aur->GetSpellProto();
// some ShapeshiftBoosts at remove trigger removing other auras including parent Shapeshift aura // some ShapeshiftBoosts at remove trigger removing other auras including parent Shapeshift aura
// remove aura from list before to prevent deleting it before // remove aura from list before to prevent deleting it before
m_Auras.erase(i); m_Auras.erase(i);
++m_removedAuras; // internal count used by unit update
Aur->UnregisterSingleCastAura(); Aur->UnregisterSingleCastAura();
@@ -4089,10 +4103,6 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
m_ccAuras.remove(Aur); m_ccAuras.remove(Aur);
} }
// Set remove mode if mode already not set
if (!Aur->GetRemoveMode())
Aur->SetRemoveMode(mode);
// Statue unsummoned at aura remove // Statue unsummoned at aura remove
Totem* statue = NULL; Totem* statue = NULL;
bool channeled = false; bool channeled = false;
@@ -4141,11 +4151,15 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
} }
} }
Aur->SetRemoveMode(mode);
sLog.outDebug("Aura %u now is remove mode %d", Aur->GetId(), mode); sLog.outDebug("Aura %u now is remove mode %d", Aur->GetId(), mode);
Aur->HandleEffects(false); Aur->HandleEffects(false);
Aur->_RemoveAura();
delete Aur; // set aura to be removed during unit::_updatespells
m_removedAuras.push_back(Aur);
Aur->_RemoveAura();
if(statue) if(statue)
statue->UnSummon(); statue->UnSummon();
@@ -11491,10 +11505,6 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
if (!parentAura) if (!parentAura)
continue; continue;
bool inuse = parentAura->IsInUse();
if (!inuse)
parentAura->SetInUse(true);
bool useCharges= parentAura->GetAuraCharges()>0; bool useCharges= parentAura->GetAuraCharges()>0;
bool takeCharges = false; bool takeCharges = false;
@@ -11627,19 +11637,11 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
} }
takeCharges=true; takeCharges=true;
} }
if (!inuse) // Remove charge (aura can be removed by triggers)
parentAura->SetInUse(false); if(useCharges && takeCharges)
if ( !parentAura->GetAuraDuration() && !(parentAura->IsPermanent() || (parentAura->IsPassive())) )
RemoveAura(parentAura);
else
{ {
// Remove charge (aura can be removed by triggers) if (parentAura->DropAuraCharge())
if(useCharges && takeCharges) RemoveAura(parentAura->GetId(),parentAura->GetCasterGUID());
{
if (parentAura->DropAuraCharge())
RemoveAura(parentAura->GetId(),parentAura->GetCasterGUID());
}
} }
} }
} }
@@ -13123,6 +13125,8 @@ void Unit::GetPartyMember(std::list<Unit*> &TagUnitMap, float radius)
void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply) void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
{ {
if (aureff->GetParentAura()->IsRemoved())
return;
if (apply) if (apply)
{ {
m_modAuras[aureff->GetAuraName()].push_back(aureff); m_modAuras[aureff->GetAuraName()].push_back(aureff);
+1 -2
View File
@@ -328,7 +328,6 @@ enum DamageTypeToSchool
enum AuraRemoveMode enum AuraRemoveMode
{ {
AURA_NO_REMOVE_MODE = 0,
AURA_REMOVE_BY_DEFAULT, AURA_REMOVE_BY_DEFAULT,
AURA_REMOVE_BY_STACK, // change stack, single aura remove, AURA_REMOVE_BY_STACK, // change stack, single aura remove,
AURA_REMOVE_BY_CANCEL, AURA_REMOVE_BY_CANCEL,
@@ -1576,12 +1575,12 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
std::list<GameObject*> m_gameObj; std::list<GameObject*> m_gameObj;
bool m_isSorted; bool m_isSorted;
uint32 m_transform; uint32 m_transform;
uint32 m_removedAuras;
AuraEffectList m_modAuras[TOTAL_AURAS]; AuraEffectList m_modAuras[TOTAL_AURAS];
AuraList m_scAuras; // casted singlecast auras AuraList m_scAuras; // casted singlecast auras
AuraList m_interruptableAuras; AuraList m_interruptableAuras;
AuraList m_ccAuras; AuraList m_ccAuras;
AuraList m_removedAuras;
uint32 m_interruptMask; uint32 m_interruptMask;
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]; float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END];