From 6bd732ce5a36a00a598c85da739e062f131c564f Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 17 Sep 2018 22:15:19 +0200 Subject: [PATCH] Move getting seat rotation to struct methods --- src/openrct2-ui/windows/RideConstruction.cpp | 2 +- src/openrct2/ride/Ride.cpp | 2 +- src/openrct2/ride/Track.cpp | 12 ++++++------ src/openrct2/ride/Track.h | 2 -- src/openrct2/ride/TrackDesignSave.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 6 +++--- src/openrct2/world/TileElement.h | 3 +++ 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 31680a2aab..6352e631c7 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2484,7 +2484,7 @@ void window_ride_construction_update_active_elements_impl() _selectedTrackType = tileElement->AsTrack()->GetTrackType(); if (track_element_has_speed_setting(tileElement->AsTrack()->GetTrackType())) _currentBrakeSpeed2 = tile_element_get_brake_booster_speed(tileElement); - _currentSeatRotationAngle = track_element_get_seat_rotation(tileElement); + _currentSeatRotationAngle = tileElement->AsTrack()->GetSeatRotation(); } } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index de6cb13389..4a0e628b70 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1398,7 +1398,7 @@ int32_t sub_6C683D( } if (flags & (1 << 5)) { - track_element_set_seat_rotation(tileElement, (uint8_t)(extra_params & 0xFF)); + tileElement->AsTrack()->SetSeatRotation((uint8_t)(extra_params & 0xFF)); } if (flags & (1 << 3)) diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index bf1aaa6cd3..17d275c3ee 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -1487,7 +1487,7 @@ static money32 track_place( } else { - track_element_set_seat_rotation(tileElement, seatRotation); + tileElement->AsTrack()->SetSeatRotation(seatRotation); } if (liftHillAndAlternativeState & RIDE_TYPE_ALTERNATIVE_TRACK_TYPE) @@ -2222,15 +2222,15 @@ bool track_element_has_speed_setting(uint8_t trackType) return trackType == TRACK_ELEM_BRAKES || trackType == TRACK_ELEM_BOOSTER; } -uint8_t track_element_get_seat_rotation(const rct_tile_element* tileElement) +uint8_t TrackElement::GetSeatRotation() const { - return tileElement->properties.track.colour >> 4; + return colour >> 4; } -void track_element_set_seat_rotation(rct_tile_element* tileElement, uint8_t seatRotation) +void TrackElement::SetSeatRotation(uint8_t newSeatRotation) { - tileElement->properties.track.colour &= 0x0F; - tileElement->properties.track.colour |= (seatRotation << 4); + colour &= 0x0F; + colour |= (newSeatRotation << 4); } uint8_t track_element_get_colour_scheme(const rct_tile_element* tileElement) diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 58e8f99f40..a72dba9995 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -566,8 +566,6 @@ void game_command_set_brakes_speed( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); bool track_element_is_booster(uint8_t rideType, uint8_t trackType); bool track_element_has_speed_setting(uint8_t trackType); -uint8_t track_element_get_seat_rotation(const rct_tile_element* tileElement); -void track_element_set_seat_rotation(rct_tile_element* tileElement, uint8_t seatRotation); uint8_t track_element_get_colour_scheme(const rct_tile_element* tileElement); void track_element_set_colour_scheme(rct_tile_element* tileElement, uint8_t colourScheme); int32_t tile_element_get_station(const rct_tile_element* tileElement); diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index d0a4761e2a..4b526ca14c 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -1052,7 +1052,7 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8_t rideIndex, rct_tra } else { - bh = track_element_get_seat_rotation(trackElement.element); + bh = trackElement.element->AsTrack()->GetSeatRotation(); } uint8_t flags = (trackElement.element->type & (1 << 7)) | bh; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 9e885364e4..02d8160953 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -8113,7 +8113,7 @@ loc_6DB41D: trackType = tileElement->AsTrack()->GetTrackType(); if (trackType != TRACK_ELEM_BRAKES) { - vehicle->target_seat_rotation = track_element_get_seat_rotation(tileElement); + vehicle->target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); } vehicle->track_direction = regs.bl & 3; vehicle->track_type |= trackType << 2; @@ -8531,7 +8531,7 @@ static bool vehicle_update_track_motion_backwards_get_new_track( trackType = tileElement->AsTrack()->GetTrackType(); if (trackType != TRACK_ELEM_BRAKES) { - vehicle->target_seat_rotation = track_element_get_seat_rotation(tileElement); + vehicle->target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); } direction &= 3; vehicle->track_type = trackType << 2; @@ -9155,7 +9155,7 @@ loc_6DCA9A: } vehicle->track_type = (tileElement->AsTrack()->GetTrackType() << 2) | (direction & 3); - vehicle->var_CF = track_element_get_seat_rotation(tileElement) << 1; + vehicle->var_CF = tileElement->AsTrack()->GetSeatRotation() << 1; // There are two bytes before the move info list regs.ax = vehicle_get_move_info_size(vehicle->var_CD, vehicle->track_type); diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index a41d4e0864..7370888c32 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -260,6 +260,9 @@ public: uint8_t GetSequenceIndex() const; void SetSequenceIndex(uint8_t newSequenceIndex); + uint8_t GetSeatRotation() const; + void SetSeatRotation(uint8_t newSeatRotation); + // Used in RCT1, will be reintroduced at some point. // (See https://github.com/OpenRCT2/OpenRCT2/issues/7059) uint8_t GetDoorAState() const;