aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-07-28 17:13:48 +0200
committerjackpoz <giacomopoz@gmail.com>2019-07-28 17:13:48 +0200
commit9b292f436903e436bfdfdc61d40d2efffad35bca (patch)
treeec5dfd6a65dc332dd30eeadf16399a27e466fb7e
parentf7eeb4525f30eb06c68462232920f53e87007a54 (diff)
Core/Spells: Fix infinite loop
Fix an infinite loop caused by a mix of item 25498 and liquid damage
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp5
-rw-r--r--src/server/game/Spells/Spell.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index e864a17117d..b69b16b9f41 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3136,9 +3136,12 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional<LiquidData>
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;
}
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 5bd1505565c..073a15a047d 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3816,7 +3816,10 @@ void Spell::finish(bool ok)
if (spellInfo && spellInfo->SpellIconID == 2056)
{
TC_LOG_DEBUG("spells", "Statue %d is unsummoned in spell %d finish", unitCaster->GetGUID().GetCounter(), 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;
}
}