From dde7a8270ac9e3e0b747d72fbe7597027664fa8b Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 23 Apr 2024 19:34:20 +0200 Subject: [PATCH] Only shift ride locations if they are not null --- src/openrct2/world/Map.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 316bcb2544..792ba5d38f 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2238,6 +2238,18 @@ MapRange ClampRangeWithinMap(const MapRange& range) return validRange; } +static inline void shiftIfNotNull(TileCoordsXY& coords, const TileCoordsXY& amount) +{ + if (!coords.IsNull()) + coords += amount; +} + +static inline void shiftIfNotNull(CoordsXY& coords, const CoordsXY& amount) +{ + if (!coords.IsNull()) + coords += amount; +} + void ShiftMap(const TileCoordsXY& amount) { if (amount.x == 0 && amount.y == 0) @@ -2392,17 +2404,17 @@ void ShiftMap(const TileCoordsXY& amount) auto& stations = ride.GetStations(); for (auto& station : stations) { - station.Start += amountToMove; - station.Entrance += amount; - station.Exit += amount; + shiftIfNotNull(station.Start, amountToMove); + shiftIfNotNull(station.Entrance, amount); + shiftIfNotNull(station.Exit, amount); } - ride.overall_view += amountToMove; - ride.boat_hire_return_position += amount; - ride.CurTestTrackLocation += amount; - ride.ChairliftBullwheelLocation[0] += amount; - ride.ChairliftBullwheelLocation[1] += amount; - ride.CableLiftLoc += amountToMove; + shiftIfNotNull(ride.overall_view, amountToMove); + shiftIfNotNull(ride.boat_hire_return_position, amount); + shiftIfNotNull(ride.CurTestTrackLocation, amount); + shiftIfNotNull(ride.ChairliftBullwheelLocation[0], amount); + shiftIfNotNull(ride.ChairliftBullwheelLocation[1], amount); + shiftIfNotNull(ride.CableLiftLoc, amountToMove); } // Banners