Fixed setting and unsetting of m_spellModTakingSpell
This commit is contained in:
1 parent
bba87cfeee
commit
ae4b91bcf6
5 files changed
+26
-43
No files matched your search
@@ -1220,18 +1220,6 @@ void Player::Update(uint32 p_time)
|
||||
m_nextMailDelivereTime = 0;
|
||||
}
|
||||
|
||||
// If this is set during update SetSpellModTakingSpell call is missing somewhere in the code
|
||||
// Having this would prevent more aura charges to be dropped, so let's crash
|
||||
//ASSERT (!m_spellModTakingSpell);
|
||||
if (m_spellModTakingSpell)
|
||||
{
|
||||
//TC_LOG_FATAL("entities.player", "Player has m_pad %u during update!", m_pad);
|
||||
//if (m_spellModTakingSpell)
|
||||
TC_LOG_FATAL("spells", "Player::Update: Player '%s' (%s) has m_spellModTakingSpell (SpellID: %u) during update!",
|
||||
GetName().c_str(), GetGUID().ToString().c_str(), m_spellModTakingSpell->m_spellInfo->Id);
|
||||
m_spellModTakingSpell = nullptr;
|
||||
}
|
||||
|
||||
// Update cinematic location, if 500ms have passed and we're doing a cinematic now.
|
||||
_cinematicMgr->m_cinematicDiff += p_time;
|
||||
if (_cinematicMgr->m_activeCinematicCameraId != 0 && GetMSTimeDiffToNow(_cinematicMgr->m_lastCinematicCheck) > CINEMATIC_UPDATEDIFF)
|
||||
@@ -21325,10 +21313,10 @@ void Player::ApplyModToSpell(SpellModifier* mod, Spell* spell)
|
||||
|
||||
void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
|
||||
{
|
||||
if (!spell || (m_spellModTakingSpell && m_spellModTakingSpell != spell))
|
||||
if (apply && m_spellModTakingSpell != nullptr)
|
||||
return;
|
||||
|
||||
if (apply && spell->getState() == SPELL_STATE_FINISHED)
|
||||
if (!apply && (!m_spellModTakingSpell || m_spellModTakingSpell != spell))
|
||||
return;
|
||||
|
||||
m_spellModTakingSpell = apply ? spell : nullptr;
|
||||
|
||||
@@ -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, ¶m1, ¶m2);
|
||||
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, ¶m1, ¶m2);
|
||||
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)
|
||||
|
||||
@@ -526,6 +526,7 @@ class TC_GAME_API Spell
|
||||
bool HasGlobalCooldown() const;
|
||||
void TriggerGlobalCooldown();
|
||||
void CancelGlobalCooldown();
|
||||
void _cast(bool skipCheck = false);
|
||||
|
||||
void SendLoot(ObjectGuid guid, LootType loottype);
|
||||
std::pair<float, float> GetMinMaxRange(bool strict) const;
|
||||
|
||||
@@ -3255,7 +3255,7 @@ uint32 SpellInfo::GetRecoveryTime() const
|
||||
return RecoveryTime > CategoryRecoveryTime ? RecoveryTime : CategoryRecoveryTime;
|
||||
}
|
||||
|
||||
int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const
|
||||
int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, Spell* spell) const
|
||||
{
|
||||
// Spell drain all exist power on cast (Only paladin lay of Hands)
|
||||
if (HasAttribute(SPELL_ATTR1_DRAIN_ALL_POWER))
|
||||
@@ -3332,7 +3332,7 @@ int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) c
|
||||
|
||||
// Apply cost mod by spell
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod<SPELLMOD_COST>(Id, powerCost);
|
||||
modOwner->ApplySpellMod<SPELLMOD_COST>(Id, powerCost, spell);
|
||||
|
||||
if (!caster->IsControlledByPlayer())
|
||||
{
|
||||
|
||||
@@ -538,17 +538,17 @@ class TC_GAME_API SpellInfo
|
||||
SpellSpecificType GetSpellSpecific() const;
|
||||
|
||||
float GetMinRange(bool positive = false) const;
|
||||
float GetMaxRange(bool positive = false, Unit* caster = NULL, Spell* spell = NULL) const;
|
||||
float GetMaxRange(bool positive = false, Unit* caster = nullptr, Spell* spell = nullptr) const;
|
||||
|
||||
int32 GetDuration() const;
|
||||
int32 GetMaxDuration() const;
|
||||
|
||||
uint32 GetMaxTicks() const;
|
||||
|
||||
uint32 CalcCastTime(uint8 level = 0, Spell* spell = NULL) const;
|
||||
uint32 CalcCastTime(uint8 level = 0, Spell* spell = nullptr) const;
|
||||
uint32 GetRecoveryTime() const;
|
||||
|
||||
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
|
||||
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, Spell* spell = nullptr) const;
|
||||
|
||||
bool IsRanked() const;
|
||||
uint8 GetRank() const;
|
||||
|
||||
Reference in new issue
Block a user