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.
This commit is contained in:
click
2012-04-01 19:54:33 +02:00
parent 4e58efcfec
commit ad569ce649

View File

@@ -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