mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Fixed setting and unsetting of m_spellModTakingSpell (#19116)
- A problem when a different spell tries to overwrite existing ModTakingSpell should no longer happen
(cherrypicked from e261754c9c)
This commit is contained in:
@@ -1029,18 +1029,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)
|
||||
@@ -21907,10 +21895,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;
|
||||
|
||||
@@ -2878,13 +2878,9 @@ 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)
|
||||
if (!m_CastItem)
|
||||
m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask);
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
if (m_CastItem)
|
||||
m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this);
|
||||
|
||||
// Set combo point requirement
|
||||
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_playerMovingMe)
|
||||
@@ -2908,11 +2904,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
|
||||
@@ -2929,10 +2920,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.
|
||||
@@ -3057,6 +3046,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);
|
||||
@@ -7241,13 +7243,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)
|
||||
|
||||
@@ -704,6 +704,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;
|
||||
|
||||
@@ -3741,10 +3741,10 @@ uint32 SpellInfo::GetRecoveryTime() const
|
||||
return RecoveryTime > CategoryRecoveryTime ? RecoveryTime : CategoryRecoveryTime;
|
||||
}
|
||||
|
||||
std::vector<SpellPowerCost> SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const
|
||||
std::vector<SpellPowerCost> SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, Spell* spell) const
|
||||
{
|
||||
std::vector<SpellPowerCost> costs;
|
||||
auto collector = [this, caster, schoolMask, &costs](std::vector<SpellPowerEntry const*> const& powers)
|
||||
auto collector = [this, caster, schoolMask, spell, &costs](std::vector<SpellPowerEntry const*> const& powers)
|
||||
{
|
||||
costs.reserve(powers.size());
|
||||
int32 healthCost = 0;
|
||||
@@ -3861,9 +3861,9 @@ std::vector<SpellPowerCost> SpellInfo::CalcPowerCost(Unit const* caster, SpellSc
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
{
|
||||
if (power->OrderIndex == 0)
|
||||
modOwner->ApplySpellMod(Id, SPELLMOD_COST, powerCost);
|
||||
modOwner->ApplySpellMod(Id, SPELLMOD_COST, powerCost, spell);
|
||||
else if (power->OrderIndex == 1)
|
||||
modOwner->ApplySpellMod(Id, SPELLMOD_SPELL_COST2, powerCost);
|
||||
modOwner->ApplySpellMod(Id, SPELLMOD_SPELL_COST2, powerCost, spell);
|
||||
}
|
||||
|
||||
if (!caster->IsControlledByPlayer() && G3D::fuzzyEq(power->PowerCostPct, 0.0f) && SpellLevel)
|
||||
|
||||
@@ -630,7 +630,7 @@ 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 CalcDuration(Unit* caster = nullptr) const;
|
||||
int32 GetDuration() const;
|
||||
@@ -638,10 +638,10 @@ class TC_GAME_API SpellInfo
|
||||
|
||||
uint32 GetMaxTicks(uint32 difficulty) const;
|
||||
|
||||
uint32 CalcCastTime(uint8 level = 0, Spell* spell = NULL) const;
|
||||
uint32 CalcCastTime(uint8 level = 0, Spell* spell = nullptr) const;
|
||||
uint32 GetRecoveryTime() const;
|
||||
|
||||
std::vector<SpellPowerCost> CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
|
||||
std::vector<SpellPowerCost> CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, Spell* spell = nullptr) const;
|
||||
|
||||
float CalcProcPPM(Unit* caster, int32 itemLevel) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user