mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 12:03:07 +01:00
Refactor adjacency distance constant + loop fix
This commit is contained in:
committed by
Michael Steenbeek
parent
3b7ec7daa1
commit
35b9038807
@@ -8480,7 +8480,7 @@ static bool check_for_adjacent_station(sint32 x, sint32 y, sint32 z, uint8 direc
|
||||
bool found = false;
|
||||
sint32 adjX = x;
|
||||
sint32 adjY = y;
|
||||
for (int i = 0; i < ride_adjacent_station_max_distance; i++) {
|
||||
for (int i = 0; i <= RIDE_ADJACENCY_CHECK_DISTANCE; i++) {
|
||||
adjX += TileDirectionDelta[direction].x;
|
||||
adjY += TileDirectionDelta[direction].y;
|
||||
rct_map_element *stationElement = get_station_platform(adjX, adjY, z, 2);
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
#define RIDE_MEASUREMENT_MAX_ITEMS 4800
|
||||
#define MAX_RIDES 255
|
||||
#define RIDE_ID_NULL 255
|
||||
|
||||
static const uint8 ride_adjacent_station_max_distance = 5;
|
||||
#define RIDE_ADJACENCY_CHECK_DISTANCE 5
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
@@ -2424,18 +2424,21 @@ static bool vehicle_can_depart_synchronised(rct_vehicle *vehicle)
|
||||
// Reset the list of synchronised vehicles to empty.
|
||||
_lastSynchronisedVehicle = _synchronisedVehicles;
|
||||
|
||||
// Search for stations to sync in both directions from the current tile.
|
||||
/* Search for stations to sync in both directions from the current tile.
|
||||
* We allow for some space between stations, and every time a station
|
||||
* is found we allow for space between that and the next.
|
||||
*/
|
||||
|
||||
// First search direction.
|
||||
sint32 direction = (mapElement->type + 1) & 3;
|
||||
sint32 spaceBetween;
|
||||
sint32 maxCheckDistance = RIDE_ADJACENCY_CHECK_DISTANCE;
|
||||
|
||||
spaceBetween = ride_adjacent_station_max_distance;
|
||||
spaceBetween = maxCheckDistance;
|
||||
while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) {
|
||||
x += TileDirectionDelta[direction].x;
|
||||
y += TileDirectionDelta[direction].y;
|
||||
if (try_add_synchronised_station(x, y, z)) {
|
||||
spaceBetween = ride_adjacent_station_max_distance;
|
||||
spaceBetween = maxCheckDistance;
|
||||
continue;
|
||||
}
|
||||
if (spaceBetween-- == 0)
|
||||
@@ -2448,12 +2451,12 @@ static bool vehicle_can_depart_synchronised(rct_vehicle *vehicle)
|
||||
|
||||
// Other search direction.
|
||||
direction = (direction ^ 2) & 3;
|
||||
spaceBetween = ride_adjacent_station_max_distance;
|
||||
spaceBetween = maxCheckDistance;
|
||||
while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) {
|
||||
x += TileDirectionDelta[direction].x;
|
||||
y += TileDirectionDelta[direction].y;
|
||||
if (try_add_synchronised_station(x, y, z)) {
|
||||
spaceBetween = ride_adjacent_station_max_distance;
|
||||
spaceBetween = maxCheckDistance;
|
||||
continue;
|
||||
}
|
||||
if (spaceBetween-- == 0)
|
||||
|
||||
Reference in New Issue
Block a user