Fixed setting and unsetting of m_spellModTakingSpell

This commit is contained in:
xinef1 authored and roc13x committed 2017-05-04 04:32:26 +01:00
1 parent bba87cfeee
commit ae4b91bcf6
5 files changed
+26 -43

No files matched your search

+18 -24
View File
@@ -2980,12 +2980,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
}
LoadScripts();
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
// Fill cost data (do not use power for item casts)
m_powerCost = m_CastItem ? 0 : m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
m_powerCost = m_CastItem ? 0 : m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this);
// Set combo point requirement
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_playerMovingMe)
@@ -3009,11 +3005,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
triggeredByAura->GetBase()->SetDuration(0);
}
// cleanup after mod system
// triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
if (param1 || param2)
SendCastResult(result, &param1, &param2);
else
@@ -3030,10 +3021,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
{
if (!player->GetCommandStatus(CHEAT_CASTTIME))
{
player->SetSpellModTakingSpell(this, true);
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
m_casttime = m_spellInfo->CalcCastTime(player->getLevel(), this);
player->SetSpellModTakingSpell(this, false);
}
else
m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
@@ -3163,6 +3152,23 @@ void Spell::cancel()
}
void Spell::cast(bool skipCheck)
{
Player* modOwner = m_caster->GetSpellModOwner();
Spell* lastSpellMod = nullptr;
if (modOwner)
{
lastSpellMod = modOwner->m_spellModTakingSpell;
if (lastSpellMod)
modOwner->SetSpellModTakingSpell(lastSpellMod, false);
}
_cast(skipCheck);
if (lastSpellMod)
modOwner->SetSpellModTakingSpell(lastSpellMod, true);
}
void Spell::_cast(bool skipCheck)
{
// update pointers base at GUIDs to prevent access to non-existed already object
if (!UpdatePointers())
@@ -3220,8 +3226,6 @@ void Spell::cast(bool skipCheck)
SendCastResult(castResult, &param1, &param2);
SendInterrupted(0);
// cleanup after mod system
// triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
@@ -3245,8 +3249,6 @@ void Spell::cast(bool skipCheck)
SendCastResult(SPELL_FAILED_DONT_REPORT);
SendInterrupted(0);
// cleanup after mod system
// triggered spell pointer can be not removed in some cases
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
finish(false);
@@ -3272,8 +3274,6 @@ void Spell::cast(bool skipCheck)
{
SendInterrupted(0);
// cleanup after mod system
// triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
@@ -7255,13 +7255,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
}
}
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->SetSpellModTakingSpell(this, true);
targetInfo.crit = m_caster->IsSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType);
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->SetSpellModTakingSpell(this, false);
}
SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue)