diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 820e3d1a1f..6e78dcd44e 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2326,9 +2326,9 @@ static void window_ride_construction_paint(rct_window* w, rct_drawpixelinfo* dpi return; ride_id_t rideIndex; - int32_t trackType, trackDirection, liftHillAndAlternativeState; + int32_t trackType, trackDirection, liftHillAndInvertedState; if (window_ride_construction_update_state( - &trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, nullptr, nullptr, nullptr, nullptr)) + &trackType, &trackDirection, &rideIndex, &liftHillAndInvertedState, nullptr, nullptr, nullptr, nullptr)) return; // Draw track piece @@ -2339,7 +2339,7 @@ static void window_ride_construction_paint(rct_window* w, rct_drawpixelinfo* dpi if (clip_drawpixelinfo(&clipdpi, dpi, x, y, width, height)) { window_ride_construction_draw_track_piece( - w, &clipdpi, rideIndex, trackType, trackDirection, liftHillAndAlternativeState, width, height); + w, &clipdpi, rideIndex, trackType, trackDirection, liftHillAndInvertedState, width, height); } // Draw cost @@ -2356,8 +2356,8 @@ static void window_ride_construction_paint(rct_window* w, rct_drawpixelinfo* dpi } static void window_ride_construction_draw_track_piece( - rct_window* w, rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t unknown, - int32_t width, int32_t height) + rct_window* w, rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, + int32_t liftHillAndInvertedState, int32_t width, int32_t height) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -2389,11 +2389,8 @@ static void window_ride_construction_draw_track_piece( dpi->x += rotatedScreenCoords.x - width / 2; dpi->y += rotatedScreenCoords.y - height / 2 - 16; - uint32_t d = unknown << 16; - d |= rideIndex; - d |= trackType << 8; - sub_6CBCE2(dpi, rideIndex, trackType, trackDirection, d, { 4096, 4096 }, 1024); + sub_6CBCE2(dpi, rideIndex, trackType, trackDirection, liftHillAndInvertedState, { 4096, 4096 }, 1024); } static TileElement _tempTrackTileElement; @@ -2408,8 +2405,8 @@ static TileElement* _backupTileElementArrays[5]; * dh: trackType */ static void sub_6CBCE2( - rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t edx, CoordsXY originCoords, - int32_t originZ) + rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndInvertedState, + CoordsXY originCoords, int32_t originZ) { paint_session* session = paint_session_alloc(dpi, 0); trackDirection &= 3; @@ -2456,7 +2453,7 @@ static void sub_6CBCE2( // Set the temporary track element _tempTrackTileElement.SetType(TILE_ELEMENT_TYPE_TRACK); _tempTrackTileElement.SetDirection(trackDirection); - _tempTrackTileElement.AsTrack()->SetHasChain((edx & 0x10000) != 0); + _tempTrackTileElement.AsTrack()->SetHasChain((liftHillAndInvertedState & CONSTRUCTION_LIFT_HILL_SELECTED) != 0); _tempTrackTileElement.SetOccupiedQuadrants(quarterTile.GetBaseQuarterOccupied()); _tempTrackTileElement.SetLastForTile(true); _tempTrackTileElement.base_height = baseZ; @@ -2464,7 +2461,7 @@ static void sub_6CBCE2( _tempTrackTileElement.AsTrack()->SetTrackType(trackType); _tempTrackTileElement.AsTrack()->SetSequenceIndex(trackBlock->index); _tempTrackTileElement.AsTrack()->SetHasCableLift(false); - _tempTrackTileElement.AsTrack()->SetInverted((edx & 0x20000) != 0); + _tempTrackTileElement.AsTrack()->SetInverted((liftHillAndInvertedState & CONSTRUCTION_INVERTED_TRACK_SELECTED) != 0); _tempTrackTileElement.AsTrack()->SetColourScheme(RIDE_COLOUR_SCHEME_MAIN); // Skipping seat rotation, should not be necessary for a temporary piece. _tempTrackTileElement.AsTrack()->SetRideIndex(rideIndex); diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 3cba7fc502..20400b6101 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -992,7 +992,8 @@ struct rct_ride_properties #define TURN_MASK_3_ELEMENTS 0x0700 #define TURN_MASK_4_PLUS_ELEMENTS 0xF800 -#define CONSTRUCTION_LIFT_HILL_SELECTED 1 +constexpr uint32_t CONSTRUCTION_LIFT_HILL_SELECTED = 1 << 0; +constexpr uint32_t CONSTRUCTION_INVERTED_TRACK_SELECTED = 1 << 1; extern const rct_ride_properties RideProperties[RIDE_TYPE_COUNT]; diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index da42d4e16e..fedbf073c7 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -237,7 +237,7 @@ static std::tuple window_ride_construction_update_state_get_track * @param[out] _trackType (dh) * @param[out] _trackDirection (bh) * @param[out] _rideIndex (dl) - * @param[out] _liftHillAndAlternativeState (liftHillAndAlternativeState) + * @param[out] _liftHillAndInvertedState (liftHillAndInvertedState) * @param[out] _x (ax) * @param[out] _y (cx) * @param[out] _z (di) @@ -245,12 +245,12 @@ static std::tuple window_ride_construction_update_state_get_track * @return (CF) */ bool window_ride_construction_update_state( - int32_t* _trackType, int32_t* _trackDirection, ride_id_t* _rideIndex, int32_t* _liftHillAndAlternativeState, int32_t* _x, + int32_t* _trackType, int32_t* _trackDirection, ride_id_t* _rideIndex, int32_t* _liftHillAndInvertedState, int32_t* _x, int32_t* _y, int32_t* _z, int32_t* _properties) { ride_id_t rideIndex; uint8_t trackType, trackDirection; - uint16_t z, x, y, liftHillAndAlternativeState, properties; + uint16_t z, x, y, liftHillAndInvertedState, properties; auto updated_element = window_ride_construction_update_state_get_track_element(); if (!std::get<0>(updated_element)) @@ -259,16 +259,16 @@ bool window_ride_construction_update_state( } trackType = std::get<1>(updated_element); - liftHillAndAlternativeState = 0; + liftHillAndInvertedState = 0; rideIndex = _currentRideIndex; if (_currentTrackLiftHill & CONSTRUCTION_LIFT_HILL_SELECTED) { - liftHillAndAlternativeState |= CONSTRUCTION_LIFT_HILL_SELECTED; + liftHillAndInvertedState |= CONSTRUCTION_LIFT_HILL_SELECTED; } if (_currentTrackAlternative & RIDE_TYPE_ALTERNATIVE_TRACK_TYPE) { - liftHillAndAlternativeState |= RIDE_TYPE_ALTERNATIVE_TRACK_TYPE; + liftHillAndInvertedState |= CONSTRUCTION_INVERTED_TRACK_SELECTED; } auto ride = get_ride(rideIndex); @@ -315,7 +315,7 @@ bool window_ride_construction_update_state( { trackType = (uint8_t)alternativeType; } - liftHillAndAlternativeState &= ~CONSTRUCTION_LIFT_HILL_SELECTED; + liftHillAndInvertedState &= ~CONSTRUCTION_LIFT_HILL_SELECTED; } } @@ -365,12 +365,12 @@ bool window_ride_construction_update_state( if (turnOffLiftHill && !gCheatsEnableChainLiftOnAllTrack) { - liftHillAndAlternativeState &= ~CONSTRUCTION_LIFT_HILL_SELECTED; + liftHillAndInvertedState &= ~CONSTRUCTION_LIFT_HILL_SELECTED; _currentTrackLiftHill &= ~CONSTRUCTION_LIFT_HILL_SELECTED; if (trackType == TRACK_ELEM_LEFT_CURVED_LIFT_HILL || trackType == TRACK_ELEM_RIGHT_CURVED_LIFT_HILL) { - liftHillAndAlternativeState |= CONSTRUCTION_LIFT_HILL_SELECTED; + liftHillAndInvertedState |= CONSTRUCTION_LIFT_HILL_SELECTED; } } @@ -389,8 +389,8 @@ bool window_ride_construction_update_state( *_trackDirection = trackDirection; if (_rideIndex != nullptr) *_rideIndex = rideIndex; - if (_liftHillAndAlternativeState != nullptr) - *_liftHillAndAlternativeState = liftHillAndAlternativeState; + if (_liftHillAndInvertedState != nullptr) + *_liftHillAndInvertedState = liftHillAndInvertedState; if (_x != nullptr) *_x = x; if (_y != nullptr)