Core/Auras: Prevent assertion fail due code in AuraEffect::HandleAuraLinked, also improve the sync between auras linked by this aura type.

This commit is contained in:
QAston
2011-05-29 15:49:32 +02:00
parent ab15d2526f
commit 3c93cccdb1
3 changed files with 37 additions and 16 deletions
@@ -6554,25 +6554,38 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mod
void AuraEffect::HandleAuraLinked(AuraApplication const * aurApp, uint8 mode, bool apply) const
{
if (!(mode & (AURA_EFFECT_HANDLE_REAL | AURA_EFFECT_HANDLE_REAPPLY)))
return;
Unit * target = aurApp->GetTarget();
if (apply)
{
Unit * caster = GetTriggeredSpellCaster(m_spellProto, GetCaster(), target);
uint32 triggeredSpellId = m_spellProto->EffectTriggerSpell[m_effIndex];
if (!caster)
return;
// If amount avalible cast with basepoints (Crypt Fever for example)
if (GetAmount())
caster->CastCustomSpell(target, m_spellProto->EffectTriggerSpell[m_effIndex], &m_amount, NULL, NULL, true, NULL, this);
if (mode & AURA_EFFECT_HANDLE_REAL)
{
if (apply)
{
Unit * caster = GetTriggeredSpellCaster(m_spellProto, GetCaster(), target);
if (!caster)
return;
// If amount avalible cast with basepoints (Crypt Fever for example)
if (GetAmount())
caster->CastCustomSpell(target, triggeredSpellId, &m_amount, NULL, NULL, true, NULL, this);
else
caster->CastSpell(target, triggeredSpellId, true, NULL, this);
}
else
caster->CastSpell(target, m_spellProto->EffectTriggerSpell[m_effIndex], true, NULL, this);
{
uint64 casterGUID = IsSpellRequiringFocusedTarget(GetSpellProto()) ? GetCasterGUID() : target->GetGUID();
target->RemoveAura(triggeredSpellId, casterGUID, 0, aurApp->GetRemoveMode());
}
}
else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply)
{
uint64 casterGUID = IsSpellRequiringFocusedTarget(GetSpellProto()) ? GetCasterGUID() : target->GetGUID();
// change the stack amount to be equal to stack amount of our aura
if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID))
triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount());
}
else
target->RemoveAura(m_spellProto->EffectTriggerSpell[m_effIndex], GetCasterGUID(), 0, AuraRemoveMode(aurApp->GetRemoveMode()));
}
void AuraEffect::HandleAuraOpenStable(AuraApplication const * aurApp, uint8 mode, bool apply) const