[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:
VladimirMangos 2010-02-15 12:10:08 +03:00
parent 574f396b0d
commit 58d188f21a
7 changed files with 45 additions and 1 deletions

View file

@ -208,6 +208,8 @@ Unit::Unit()
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
m_currentSpells[i] = NULL;
m_castCounter = 0;
m_addDmgOnce = 0;
for(int i = 0; i < MAX_TOTEM; ++i)
@ -13435,3 +13437,14 @@ void Unit::CleanupDeletedAuras()
delete *itr;
m_deletedAuras.clear();
}
bool Unit::CheckAndIncreaseCastCounter()
{
uint32 maxCasts = sWorld.getConfig(CONFIG_MAX_SPELL_CASTS_IN_CHAIN);
if (maxCasts && m_castCounter >= maxCasts)
return false;
++m_castCounter;
return true;
}