Skip to content

Commit

Permalink
Core/Unit: Fix crash using call pet on dead pets.
Browse files Browse the repository at this point in the history
Fixes TrinityCore#5400

Thanks MrSmite
  • Loading branch information
kewarr committed Mar 5, 2012
1 parent f506674 commit a572efe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -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
Expand Down

0 comments on commit a572efe

Please sign in to comment.