From 2258652e8307a4c3acc343fad7d64ffc5bca3a12 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 21:49:58 +0100 Subject: [PATCH] Wrap direction in vehicle_update_motion_collision_detection --- src/ride/vehicle.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 3bddb023bd..8c7510af86 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -7101,9 +7101,10 @@ static bool vehicle_update_motion_collision_detection( if (direction < 0x14) continue; - assert(((4 + vehicle->sprite_direction) >> 3) < countof(duck_move_offset)); - uint32 next_x_diff = abs(x + duck_move_offset[(4 + vehicle->sprite_direction) >> 3].x - collideVehicle->x); - uint32 next_y_diff = abs(y + duck_move_offset[(4 + vehicle->sprite_direction) >> 3].y - collideVehicle->y); + uint32 offsetSpriteDirection = (vehicle->sprite_direction + 4) & 31; + uint32 offsetDirection = offsetSpriteDirection >> 3; + uint32 next_x_diff = abs(x + duck_move_offset[offsetDirection].x - collideVehicle->x); + uint32 next_y_diff = abs(y + duck_move_offset[offsetDirection].y - collideVehicle->y); if (next_x_diff + next_y_diff < x_diff + y_diff){ mayCollide = true;