From 4c06f481214e526b3c0d21fdbe944d8d2c653e50 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 29 Jul 2019 10:50:42 +0200 Subject: [PATCH] Core/Spells: Fix an infinite loop caused by a mix of item 25498 and liquid damage (ported commit: 9b292f436903e436bfdfdc61d40d2efffad35bca) --- src/server/game/Entities/Unit/Unit.cpp | 6 ++++-- src/server/game/Spells/Spell.cpp | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index eccc62a95a..88219c7a5c 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3308,14 +3308,16 @@ 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); // Update mount capabilities when changing liquidstatus (enabling / disabling flight auras for example) if (player) player->UpdateMountCapabilities(); - - _lastLiquid = curLiquid; } } void Unit::DeMorph() diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f76b6cb700..fe9d29b23f 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3871,7 +3871,10 @@ void Spell::finish(bool ok) if (spellInfo && spellInfo->SpellIconID == 2056) { TC_LOG_DEBUG("spells", "Statue %d is unsummoned in spell %d finish", m_caster->GetGUID().GetCounter(), m_spellInfo->Id); - m_caster->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 (m_caster->getDeathState() != JUST_DIED) + m_caster->setDeathState(JUST_DIED); return; } }