mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[9388] Implement max cast chain length for triggered spells.
* New config option MaxSpellCastsInChain ( 0 is disabled old way work ) * Check added for prevent stack overflow crashes in case infinity triggered casts sequences with more useful error output instead crash. * Default config steeing in 10 casts expected to allow all possible in game proper cast chains.
This commit is contained in:
parent
574f396b0d
commit
58d188f21a
7 changed files with 45 additions and 1 deletions
|
|
@ -2522,6 +2522,19 @@ void Spell::cast(bool skipCheck)
|
|||
{
|
||||
SetExecutedCurrently(true);
|
||||
|
||||
if (!m_caster->CheckAndIncreaseCastCounter())
|
||||
{
|
||||
if (m_triggeredByAuraSpell)
|
||||
sLog.outError("Spell %u triggered by aura spell %u too deep in cast chain for cast. Cast not allowed for prevent overflow stack crash.");
|
||||
else
|
||||
sLog.outError("Spell %u too deep in cast chain for cast. Cast not allowed for prevent overflow stack crash.");
|
||||
|
||||
SendCastResult(SPELL_FAILED_ERROR);
|
||||
finish(false);
|
||||
SetExecutedCurrently(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// update pointers base at GUIDs to prevent access to non-existed already object
|
||||
UpdatePointers();
|
||||
|
||||
|
|
@ -2529,6 +2542,7 @@ void Spell::cast(bool skipCheck)
|
|||
if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID())
|
||||
{
|
||||
cancel();
|
||||
m_caster->DecreaseCastCounter();
|
||||
SetExecutedCurrently(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2541,6 +2555,7 @@ void Spell::cast(bool skipCheck)
|
|||
{
|
||||
SendCastResult(castResult);
|
||||
finish(false);
|
||||
m_caster->DecreaseCastCounter();
|
||||
SetExecutedCurrently(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2553,6 +2568,7 @@ void Spell::cast(bool skipCheck)
|
|||
{
|
||||
SendCastResult(castResult);
|
||||
finish(false);
|
||||
m_caster->DecreaseCastCounter();
|
||||
SetExecutedCurrently(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2667,6 +2683,7 @@ void Spell::cast(bool skipCheck)
|
|||
|
||||
if(m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in FillTargetMap
|
||||
{
|
||||
m_caster->DecreaseCastCounter();
|
||||
SetExecutedCurrently(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2699,6 +2716,7 @@ void Spell::cast(bool skipCheck)
|
|||
handle_immediate();
|
||||
}
|
||||
|
||||
m_caster->DecreaseCastCounter();
|
||||
SetExecutedCurrently(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue