diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 16 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 42 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.h | 6 |
5 files changed, 26 insertions, 43 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ccf4ac4d24c..dc94521c1bb 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1219,18 +1219,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_cinematicCamera && _cinematicMgr->m_activeCinematicCameraId && GetMSTimeDiffToNow(_cinematicMgr->m_lastCinematicCheck) > CINEMATIC_UPDATEDIFF) @@ -20899,10 +20887,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; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 90572f14a54..26f40b86c6b 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2885,12 +2885,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) @@ -2910,11 +2906,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 @@ -2931,10 +2922,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(this); - player->SetSpellModTakingSpell(this, false); } else m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled. @@ -3058,6 +3047,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()) { @@ -3114,8 +3120,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); @@ -3139,8 +3143,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); @@ -3166,8 +3168,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); @@ -7158,13 +7158,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) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index ed57e3aac6b..7cea09d5c21 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -520,6 +520,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; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index d5ce194e0d7..a5df6218e83 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -3110,7 +3110,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)) @@ -3172,7 +3172,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()) { diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 4739f888da4..71982eafaf5 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -494,17 +494,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(Spell* spell = NULL) const; + uint32 CalcCastTime(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; |