From f8a94c2e12dabef6b493abb438a2ac36be4c06fc Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 13 Aug 2022 18:36:33 +0200 Subject: [PATCH] Move two functions out of _legacy.cpp --- src/openrct2-ui/windows/RideConstruction.cpp | 97 ++++++++++++++++++++ src/openrct2/ride/Ride.h | 4 - src/openrct2/windows/_legacy.cpp | 95 ------------------- 3 files changed, 97 insertions(+), 99 deletions(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index bcaef9db70..dedaa9bca6 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -166,6 +166,8 @@ static constexpr const StringId RideConstructionSeatAngleRotationStrings[] = { STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_450, STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_495, }; +static void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type); + static int32_t RideGetAlternativeType(Ride* ride) { return (_currentTrackAlternative & RIDE_TYPE_ALTERNATIVE_TRACK_TYPE) ? ride->GetRideTypeDescriptor().AlternateType @@ -2753,6 +2755,28 @@ static void CloseConstructWindowOnCompletion(Ride* ride) } } +static void window_ride_construction_do_entrance_exit_check() +{ + auto w = window_find_by_class(WC_RIDE_CONSTRUCTION); + auto ride = get_ride(_currentRideIndex); + if (w == nullptr || ride == nullptr) + { + return; + } + + if (_rideConstructionState == RideConstructionState::State0) + { + w = window_find_by_class(WC_RIDE_CONSTRUCTION); + if (w != nullptr) + { + if (!ride_are_all_possible_entrances_and_exits_built(ride).Successful) + { + window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE); + } + } + } +} + static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) @@ -4465,3 +4489,76 @@ void window_ride_construction_keyboard_shortcut_demolish_current() window_event_mouse_up_call(w, WIDX_DEMOLISH); } + +static void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type) +{ + if (gGotoStartPlacementMode) + { + _currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP); + _rideConstructionState = RideConstructionState::Front; + _currentTrackSelectionFlags = 0; + _currentTrackPieceDirection = piecePos.direction & 3; + auto savedCurrentTrackCurve = _currentTrackCurve; + int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd; + int32_t savedCurrentTrackSlopeEnd = _currentTrackSlopeEnd; + int32_t savedPreviousTrackBankEnd = _previousTrackBankEnd; + int32_t savedCurrentTrackBankEnd = _currentTrackBankEnd; + int32_t savedCurrentTrackAlternative = _currentTrackAlternative; + int32_t savedCurrentTrackLiftHill = _currentTrackLiftHill; + ride_construction_set_default_next_piece(); + window_ride_construction_update_active_elements(); + auto ride = get_ride(_currentRideIndex); + if (!ride_try_get_origin_element(ride, nullptr)) + { + ride_initialise_construction_window(ride); + _currentTrackPieceDirection = piecePos.direction & 3; + if (!(savedCurrentTrackCurve & RideConstructionSpecialPieceSelected)) + { + _currentTrackCurve = savedCurrentTrackCurve; + _previousTrackSlopeEnd = savedPreviousTrackSlopeEnd; + _currentTrackSlopeEnd = savedCurrentTrackSlopeEnd; + _previousTrackBankEnd = savedPreviousTrackBankEnd; + _currentTrackBankEnd = savedCurrentTrackBankEnd; + _currentTrackAlternative = savedCurrentTrackAlternative; + _currentTrackLiftHill = savedCurrentTrackLiftHill; + window_ride_construction_update_active_elements(); + } + } + } + else + { + if (_rideConstructionState2 == RideConstructionState::Selected + || _rideConstructionState2 == RideConstructionState::Front) + { + if (type == TrackElemType::MiddleStation || type == TrackElemType::BeginStation) + { + type = TrackElemType::EndStation; + } + } + if (_rideConstructionState2 == RideConstructionState::Back) + { + if (type == TrackElemType::MiddleStation) + { + type = TrackElemType::BeginStation; + } + } + if (network_get_mode() == NETWORK_MODE_CLIENT) + { + // rideConstructionState needs to be set again to the proper value, this only affects the client + _rideConstructionState = RideConstructionState::Selected; + } + _currentTrackBegin = piecePos; + _currentTrackPieceDirection = piecePos.direction; + _currentTrackPieceType = type; + _currentTrackSelectionFlags = 0; + if (_rideConstructionState2 == RideConstructionState::Front) + { + ride_select_next_section(); + } + else if (_rideConstructionState2 == RideConstructionState::Back) + { + ride_select_previous_section(); + } + window_ride_construction_update_active_elements(); + } +} diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 7f311f6f17..a8f7b45d9f 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1075,15 +1075,11 @@ void UpdateGhostTrackAndArrow(); void ride_reset_all_names(); -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); Vehicle* ride_get_broken_vehicle(const Ride* ride); -void window_ride_construction_do_entrance_exit_check(); - money16 ride_get_price(const Ride* ride); TileElement* get_station_platform(const CoordsXYRangedZ& coords); diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index e1dd2ea19a..3d6e9e54b2 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -390,101 +390,6 @@ bool window_ride_construction_update_state( return false; } -void window_ride_construction_do_entrance_exit_check() -{ - auto w = window_find_by_class(WC_RIDE_CONSTRUCTION); - auto ride = get_ride(_currentRideIndex); - if (w == nullptr || ride == nullptr) - { - return; - } - - if (_rideConstructionState == RideConstructionState::State0) - { - w = window_find_by_class(WC_RIDE_CONSTRUCTION); - if (w != nullptr) - { - if (!ride_are_all_possible_entrances_and_exits_built(ride).Successful) - { - window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE); - } - } - } -} - -void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type) -{ - if (gGotoStartPlacementMode) - { - _currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP); - _rideConstructionState = RideConstructionState::Front; - _currentTrackSelectionFlags = 0; - _currentTrackPieceDirection = piecePos.direction & 3; - auto savedCurrentTrackCurve = _currentTrackCurve; - int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd; - int32_t savedCurrentTrackSlopeEnd = _currentTrackSlopeEnd; - int32_t savedPreviousTrackBankEnd = _previousTrackBankEnd; - int32_t savedCurrentTrackBankEnd = _currentTrackBankEnd; - int32_t savedCurrentTrackAlternative = _currentTrackAlternative; - int32_t savedCurrentTrackLiftHill = _currentTrackLiftHill; - ride_construction_set_default_next_piece(); - window_ride_construction_update_active_elements(); - auto ride = get_ride(_currentRideIndex); - if (!ride_try_get_origin_element(ride, nullptr)) - { - ride_initialise_construction_window(ride); - _currentTrackPieceDirection = piecePos.direction & 3; - if (!(savedCurrentTrackCurve & RideConstructionSpecialPieceSelected)) - { - _currentTrackCurve = savedCurrentTrackCurve; - _previousTrackSlopeEnd = savedPreviousTrackSlopeEnd; - _currentTrackSlopeEnd = savedCurrentTrackSlopeEnd; - _previousTrackBankEnd = savedPreviousTrackBankEnd; - _currentTrackBankEnd = savedCurrentTrackBankEnd; - _currentTrackAlternative = savedCurrentTrackAlternative; - _currentTrackLiftHill = savedCurrentTrackLiftHill; - window_ride_construction_update_active_elements(); - } - } - } - else - { - if (_rideConstructionState2 == RideConstructionState::Selected - || _rideConstructionState2 == RideConstructionState::Front) - { - if (type == TrackElemType::MiddleStation || type == TrackElemType::BeginStation) - { - type = TrackElemType::EndStation; - } - } - if (_rideConstructionState2 == RideConstructionState::Back) - { - if (type == TrackElemType::MiddleStation) - { - type = TrackElemType::BeginStation; - } - } - if (network_get_mode() == NETWORK_MODE_CLIENT) - { - // rideConstructionState needs to be set again to the proper value, this only affects the client - _rideConstructionState = RideConstructionState::Selected; - } - _currentTrackBegin = piecePos; - _currentTrackPieceDirection = piecePos.direction; - _currentTrackPieceType = type; - _currentTrackSelectionFlags = 0; - if (_rideConstructionState2 == RideConstructionState::Front) - { - ride_select_next_section(); - } - else if (_rideConstructionState2 == RideConstructionState::Back) - { - ride_select_previous_section(); - } - window_ride_construction_update_active_elements(); - } -} - /** * * rct2: 0x006C84CE