From a6993bdb9f5bb596a074c7253ffedda66b00448f Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Mon, 25 Sep 2017 15:21:18 +0200 Subject: [PATCH] Introduce constant for max adjacency distance --- src/openrct2/ride/ride.h | 1 + src/openrct2/ride/vehicle.c | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/openrct2/ride/ride.h b/src/openrct2/ride/ride.h index e37a8c3d8f..1fdb162ff0 100644 --- a/src/openrct2/ride/ride.h +++ b/src/openrct2/ride/ride.h @@ -41,6 +41,7 @@ #define MAX_RIDES 255 #define RIDE_ID_NULL 255 +static const uint8 ride_adjacent_station_max_distance = 5; #pragma pack(push, 1) diff --git a/src/openrct2/ride/vehicle.c b/src/openrct2/ride/vehicle.c index 381ac54b3b..c54a66552b 100644 --- a/src/openrct2/ride/vehicle.c +++ b/src/openrct2/ride/vehicle.c @@ -2425,19 +2425,17 @@ static bool vehicle_can_depart_synchronised(rct_vehicle *vehicle) _lastSynchronisedVehicle = _synchronisedVehicles; // Search for stations to sync in both directions from the current tile. - - static const sint32 maxSearchDistance = 5; // How many tiles we are allowed to search // First search direction. sint32 direction = (mapElement->type + 1) & 3; sint32 spaceBetween; - spaceBetween = maxSearchDistance; + spaceBetween = ride_adjacent_station_max_distance; while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) { x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; if (try_add_synchronised_station(x, y, z)) { - spaceBetween = maxSearchDistance; + spaceBetween = ride_adjacent_station_max_distance; continue; } if (spaceBetween-- == 0) @@ -2450,12 +2448,12 @@ static bool vehicle_can_depart_synchronised(rct_vehicle *vehicle) // Other search direction. direction = (direction ^ 2) & 3; - spaceBetween = maxSearchDistance; + spaceBetween = ride_adjacent_station_max_distance; while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) { x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; if (try_add_synchronised_station(x, y, z)) { - spaceBetween = maxSearchDistance; + spaceBetween = ride_adjacent_station_max_distance; continue; } if (spaceBetween-- == 0)