From ad569ce649b500ee74d7616acedefc74b6d0cd6b Mon Sep 17 00:00:00 2001 From: click Date: Sun, 1 Apr 2012 19:54:33 +0200 Subject: Core: Only clear motionmaster flags if the respective entity exists in world. Original patch by kewarr and Mrsmite, additional commenting by Machiavelli removing the pet-specific checks applied. Fixes #5400. --- src/server/game/Entities/Unit/Unit.cpp | 12 ++++++++++-- 1 file changed, 10 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 348335e1455..d71f8e8dfc3 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12776,8 +12776,16 @@ void Unit::setDeathState(DeathState s) // remove aurastates allowing special moves ClearAllReactives(); ClearDiminishings(); - GetMotionMaster()->Clear(false); - GetMotionMaster()->MoveIdle(); + if (IsInWorld()) + { + // Only clear MotionMaster for entities that exists in world + // Avoids crashes in the following conditions : + // * Using 'call pet' on dead pets + // * Using 'call stabled pet' + // * Logging in with dead pets + GetMotionMaster()->Clear(false); + GetMotionMaster()->MoveIdle(); + } StopMoving(); DisableSpline(); // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp -- cgit v1.2.3