diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 6a22a48ed4..314a75c3c6 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5248,12 +5248,14 @@ void rct_peep::UpdateWalking() } } - rct_tile_element * path_element = map_get_path_element_at(destination_x / 32, destination_y / 32, next_z); - if (path_element && path_element->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE) + // Check if vehicle is blocking the destination tile + auto curPos = TileCoordsXYZ(CoordsXYZ { x, y, z }); + auto dstPos = TileCoordsXYZ(CoordsXY { destination_x, destination_y }, next_z); + if (curPos.x != dstPos.x || curPos.y != dstPos.y) { - if (!(x >> 5 == destination_x >> 5 && - y >> 5 == destination_y >> 5)) + if (footpath_is_blocked_by_vehicle(dstPos)) { + // Wait for vehicle to pass return; } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 2a690fa4eb..cfef9775e6 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -2178,6 +2178,12 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) } while (!(tileElement++)->IsLastForTile()); } +bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position) +{ + auto pathElement = map_get_path_element_at(position.x, position.y, position.z); + return pathElement != nullptr && (pathElement->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE); +} + /** * * rct2: 0x006A7642 diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index d5ef69266a..6c3bc7dd90 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -149,6 +149,7 @@ void footpath_update_queue_chains(); bool fence_in_the_way(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction); void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, sint32 y, rct_tile_element * tileElement, sint32 direction); void footpath_update_path_wide_flags(sint32 x, sint32 y); +bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position); sint32 footpath_is_connected_to_map_edge(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags); bool footpath_element_is_sloped(const rct_tile_element * tileElement); diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 796d3c9791..80935e9462 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -84,6 +84,7 @@ struct TileCoordsXYZ { TileCoordsXYZ() = default; TileCoordsXYZ(sint32 x_, sint32 y_, sint32 z_) : x(x_), y(y_), z(z_) {} + explicit TileCoordsXYZ(CoordsXY c, sint32 z_) : x(c.x / 32), y(c.y / 32), z(z_) {} explicit TileCoordsXYZ(CoordsXYZ c) : x(c.x / 32), y(c.y / 32), z(c.z / 8) {} TileCoordsXYZ& operator+=(const TileCoordsXY rhs) {