From 7c82daec25c6aa3f0b95e604bf4e318eede60c18 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sat, 2 May 2020 09:10:04 -0300 Subject: [PATCH] Use CoordsXYZD in window_ride_construction_mouseup_demolish_next_piece() --- src/openrct2-ui/windows/RideConstruction.cpp | 2 +- src/openrct2/ride/Ride.h | 2 +- src/openrct2/windows/_legacy.cpp | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 181d5b5bdd..816e84bf39 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -1958,7 +1958,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w) if (ride != nullptr) { _stationConstructed = ride->num_stations != 0; - window_ride_construction_mouseup_demolish_next_piece(newCoords->x, newCoords->y, newCoords->z, direction, type); + window_ride_construction_mouseup_demolish_next_piece({ *newCoords, static_cast(direction) }, type); } } }); diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 86da2f061b..5ce566c703 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1189,7 +1189,7 @@ void sub_6C94D8(); void ride_reset_all_names(); -void window_ride_construction_mouseup_demolish_next_piece(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t type); +void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type); uint32_t ride_customers_per_hour(const Ride* ride); uint32_t ride_customers_in_last_5_minutes(const Ride* ride); diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index 45d03dfa34..11ad2072a8 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -439,16 +439,15 @@ void window_ride_construction_do_station_check() } } -void window_ride_construction_mouseup_demolish_next_piece(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t type) +void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type) { if (gGotoStartPlacementMode) { - z &= 0xFFF0; - _currentTrackBegin.z = z; + _currentTrackBegin.z = piecePos.z & 0xFFF0; _rideConstructionState = RIDE_CONSTRUCTION_STATE_FRONT; _currentTrackSelectionFlags = 0; _rideConstructionArrowPulseTime = 0; - _currentTrackPieceDirection = direction & 3; + _currentTrackPieceDirection = piecePos.direction & 3; int32_t savedCurrentTrackCurve = _currentTrackCurve; int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd; int32_t savedCurrentTrackSlopeEnd = _currentTrackSlopeEnd; @@ -462,7 +461,7 @@ void window_ride_construction_mouseup_demolish_next_piece(int32_t x, int32_t y, if (!ride_try_get_origin_element(ride, nullptr)) { ride_initialise_construction_window(ride); - _currentTrackPieceDirection = direction & 3; + _currentTrackPieceDirection = piecePos.direction & 3; if (!(savedCurrentTrackCurve & RideConstructionSpecialPieceSelected)) { _currentTrackCurve = savedCurrentTrackCurve; @@ -498,10 +497,8 @@ void window_ride_construction_mouseup_demolish_next_piece(int32_t x, int32_t y, // rideConstructionState needs to be set again to the proper value, this only affects the client _rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED; } - _currentTrackBegin.x = x; - _currentTrackBegin.y = y; - _currentTrackBegin.z = z; - _currentTrackPieceDirection = direction; + _currentTrackBegin = piecePos; + _currentTrackPieceDirection = piecePos.direction; _currentTrackPieceType = type; _currentTrackSelectionFlags = 0; _rideConstructionArrowPulseTime = 0;