mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Movement: Fix a potential crash on newly created pets. Closes #21791.
(cherry picked from commit 74defba5a7)
This commit is contained in:
@@ -8064,7 +8064,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype)
|
||||
|
||||
if (creature->HasUnitTypeMask(UNIT_MASK_MINION) && !creature->IsInCombat())
|
||||
{
|
||||
MovementGenerator* top = creature->GetMotionMaster()->top();
|
||||
MovementGenerator* top = creature->GetMotionMaster()->topOrNull();
|
||||
if (top && top->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)
|
||||
{
|
||||
Unit* followed = ASSERT_NOTNULL(dynamic_cast<AbstractFollower*>(top))->GetTarget();
|
||||
|
||||
@@ -144,6 +144,7 @@ class TC_GAME_API MotionMaster
|
||||
|
||||
bool empty() const { return (_top < 0); }
|
||||
int size() const { return _top + 1; }
|
||||
MovementGenerator* topOrNull() const { return empty() ? nullptr : top(); }
|
||||
MovementGenerator* top() const { ASSERT(!empty()); return _slot[_top]; }
|
||||
|
||||
void Initialize();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
static bool IsMutualChase(Unit* owner, Unit* target)
|
||||
{
|
||||
MovementGenerator const* gen = target->GetMotionMaster()->top();
|
||||
MovementGenerator const* gen = target->GetMotionMaster()->topOrNull();
|
||||
if (!gen || gen->GetMovementGeneratorType() != CHASE_MOTION_TYPE)
|
||||
return false;
|
||||
return (static_cast<ChaseMovementGenerator const*>(gen)->GetTarget() == owner);
|
||||
|
||||
Reference in New Issue
Block a user