From e6e73b7b13ddc48f98f46d1af13a95b9cf67cccd Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 28 Jul 2019 17:13:48 +0200 Subject: Core/Spells: Fix infinite loop Fix an infinite loop caused by a mix of item 25498 and liquid damage (cherry picked from commit 9b292f436903e436bfdfdc61d40d2efffad35bca) --- src/server/game/Entities/Unit/Unit.cpp | 5 ++++- src/server/game/Spells/Spell.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b09d4e6f5d9..7aab5386818 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3007,9 +3007,12 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional if (_lastLiquid && _lastLiquid->SpellID) RemoveAurasDueToSpell(_lastLiquid->SpellID); Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); + + // Set _lastLiquid before casting liquid spell to avoid infinite loops + _lastLiquid = curLiquid; + if (curLiquid && curLiquid->SpellID && (!player || !player->IsGameMaster())) CastSpell(this, curLiquid->SpellID, true); - _lastLiquid = curLiquid; // mount capability depends on liquid state change UpdateMountCapability(); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4e70226bca0..a13a22044c9 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3953,7 +3953,10 @@ void Spell::finish(bool ok) if (spellInfo && spellInfo->IconFileDataId == 134230) { TC_LOG_DEBUG("spells", "Statue %s is unsummoned in spell %d finish", unitCaster->GetGUID().ToString().c_str(), m_spellInfo->Id); - unitCaster->setDeathState(JUST_DIED); + // Avoid infinite loops with setDeathState(JUST_DIED) being called over and over + // It might make sense to do this check in Unit::setDeathState() and all overloaded functions + if (unitCaster->getDeathState() != JUST_DIED) + unitCaster->setDeathState(JUST_DIED); return; } } -- cgit v1.2.3