*Try to fix the crash caused by aura update (only add two return after m_target->RemoveAura(this))

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-12 17:25:12 -05:00
parent 785dc69318
commit 772e0eb722
+30 -31
View File
@@ -607,29 +607,39 @@ void Aura::Update(uint32 diff)
m_duration -= diff; m_duration -= diff;
if (m_duration < 0) if (m_duration < 0)
m_duration = 0; m_duration = 0;
m_timeCla -= diff;
// all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
if(m_timeCla > 0)
m_timeCla -= diff;
if(m_timeCla <= 0) if(m_timeCla <= 0)
{ {
if(Unit* caster = GetCaster()) if(Unit* caster = GetCaster())
{ {
Powers powertype = Powers(m_spellProto->powerType); if(int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel())
int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel(); {
m_timeCla = 1000; m_timeCla = 1000;
if (manaPerSecond)
Powers powertype = Powers(m_spellProto->powerType);
if(powertype == POWER_HEALTH)
{ {
if(powertype==POWER_HEALTH) if (caster->GetHealth() > manaPerSecond)
{
if (caster->GetHealth()>manaPerSecond)
caster->ModifyHealth(-manaPerSecond); caster->ModifyHealth(-manaPerSecond);
else else
{
m_target->RemoveAura(this); m_target->RemoveAura(this);
return;
}
} }
else if (caster->GetPower(powertype)>=manaPerSecond)
caster->ModifyPower(powertype,-manaPerSecond);
else else
{
if (caster->GetPower(powertype) >= manaPerSecond)
caster->ModifyPower(powertype, -manaPerSecond);
else
{
m_target->RemoveAura(this); m_target->RemoveAura(this);
return;
}
}
} }
} }
} }
@@ -825,32 +835,21 @@ void AreaAuraEffect::Update(uint32 diff)
void PersistentAreaAuraEffect::Update(uint32 diff) void PersistentAreaAuraEffect::Update(uint32 diff)
{ {
bool remove = false; if(Unit *caster = GetCaster())
{
if(DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()))
{
if(m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
{
AuraEffect::Update(diff);
return;
}
}
}
// remove the aura if its caster or the dynamic object causing it was removed // remove the aura if its caster or the dynamic object causing it was removed
// or if the target moves too far from the dynamic object // or if the target moves too far from the dynamic object
Unit *caster = GetCaster();
if (caster)
{
DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
if (dynObj)
{
if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
remove = true;
}
else
remove = true;
}
else
remove = true;
if(remove)
{
m_target->RemoveAura(GetParentAura()); m_target->RemoveAura(GetParentAura());
return;
}
AuraEffect::Update(diff);
} }
void AuraEffect::ApplyModifier(bool apply, bool Real) void AuraEffect::ApplyModifier(bool apply, bool Real)