Core/Movement: shield ChaseMovementGenerator against a potential crash

Since GenericMovementGenerator can be built with any MOTION_TYPE

(cherry picked from commit 98fd8d4c748942cc7d7acde97610b7b0688472de)
This commit is contained in:
ccrs
2021-09-29 00:01:23 +02:00
committed by Shauren
parent 4487933bd0
commit 6d9e544c20
@@ -31,7 +31,10 @@ static bool IsMutualChase(Unit* owner, Unit* target)
if (target->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE)
return false;
return (dynamic_cast<ChaseMovementGenerator const*>(target->GetMotionMaster()->GetCurrentMovementGenerator())->GetTarget() == owner);
if (ChaseMovementGenerator* movement = dynamic_cast<ChaseMovementGenerator*>(target->GetMotionMaster()->GetCurrentMovementGenerator()))
return movement->GetTarget() == owner;
return false;
}
static bool PositionOkay(Unit* owner, Unit* target, Optional<float> minDistance, Optional<float> maxDistance, Optional<ChaseAngle> angle)