From a572efe4e476c27bacdb98327b84d13fa4065a5d Mon Sep 17 00:00:00 2001 From: kewarr Date: Mon, 5 Mar 2012 21:57:33 +0100 Subject: [PATCH] Core/Unit: Fix crash using call pet on dead pets. Fixes #5400 Thanks MrSmite --- src/server/game/Entities/Unit/Unit.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3411d285b1e51..191352b811552 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12700,8 +12700,18 @@ void Unit::setDeathState(DeathState s) // remove aurastates allowing special moves ClearAllReactives(); ClearDiminishings(); - GetMotionMaster()->Clear(false); - GetMotionMaster()->MoveIdle(); + + if (!isPet() || (isPet() && IsInWorld())) + { + // Only clear MotionMaster for non-pet entities OR if pet and in world + // Fixes crash when: + // * Using 'call pet' on dead pets + // * Using 'call stabled pet' + // * Logging in with dead pets + GetMotionMaster()->Clear(false); + GetMotionMaster()->MoveIdle(); + } + StopMoving(); // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp // do not why since in IncreaseMaxHealth currenthealth is checked