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 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(); Unit * target = aurApp->GetTarget();
if (apply) uint32 triggeredSpellId = m_spellProto->EffectTriggerSpell[m_effIndex];
{
Unit * caster = GetTriggeredSpellCaster(m_spellProto, GetCaster(), target);
if (!caster) if (mode & AURA_EFFECT_HANDLE_REAL)
return; {
// If amount avalible cast with basepoints (Crypt Fever for example) if (apply)
if (GetAmount()) {
caster->CastCustomSpell(target, m_spellProto->EffectTriggerSpell[m_effIndex], &m_amount, NULL, NULL, true, NULL, this); 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 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 void AuraEffect::HandleAuraOpenStable(AuraApplication const * aurApp, uint8 mode, bool apply) const
+9 -2
View File
@@ -427,7 +427,7 @@ uint32 CalculatePowerCost(SpellEntry const * spellInfo, Unit const * caster, Spe
return powerCost; return powerCost;
} }
Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target) bool IsSpellRequiringFocusedTarget(SpellEntry const * spellInfo)
{ {
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i) for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
{ {
@@ -437,8 +437,15 @@ Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_CHANNEL || SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_CHANNEL
|| SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET || SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_DEST_TARGET) || SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_DEST_TARGET)
return caster; return true;
} }
}
Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target)
{
if (IsSpellRequiringFocusedTarget(spellInfo))
return caster;
return target; return target;
} }
+1
View File
@@ -173,6 +173,7 @@ enum SpellLinkedType
SPELL_LINK_REMOVE = 0, SPELL_LINK_REMOVE = 0,
}; };
bool IsSpellRequiringFocusedTarget(SpellEntry const * spellInfo);
Unit * GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target); Unit * GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target);
SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo); SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo);
AuraState GetSpellAuraState(SpellEntry const * spellInfo); AuraState GetSpellAuraState(SpellEntry const * spellInfo);