Fix game freeze when trainers try to walk on sideway stairs (#8316)

This commit is contained in:
FosterProgramming 2025-11-22 07:11:22 +01:00 committed by GitHub
parent 65a5d1e7d8
commit 8ba99b09d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -522,6 +522,9 @@ static u8 GetTrainerApproachDistance(struct ObjectEvent *trainerObj)
PlayerGetDestCoords(&x, &y);
if (trainerObj->trainerType == TRAINER_TYPE_NORMAL) // can only see in one direction
{
// Disable trainer approach while moving diagonally (usually moving on sideway stairs)
if (trainerObj->facingDirection > DIR_EAST)
return 0;
approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->facingDirection - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y);
return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->facingDirection);
}