From b9653770803986affd7ffd88796b20857acb18fa Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 18 Sep 2018 13:43:55 +0200 Subject: [PATCH] Move green light functions to struct methods --- src/openrct2/ride/Station.cpp | 6 +++--- src/openrct2/ride/Track.cpp | 29 ++++++++++++++-------------- src/openrct2/ride/Track.h | 2 -- src/openrct2/ride/TrackPaint.cpp | 4 ++-- src/openrct2/ride/thrill/GoKarts.cpp | 2 +- src/openrct2/world/TileElement.h | 3 +++ 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 79e88c3d5c..ec242b60b3 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -61,7 +61,7 @@ static void ride_update_station_blocksection(Ride* ride, int32_t stationIndex) ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) - || (tileElement != nullptr && tile_element_get_green_light(tileElement))) + || (tileElement != nullptr && tileElement->AsTrack()->HasGreenLight())) ride_invalidate_station_start(ride, stationIndex, false); } else @@ -71,7 +71,7 @@ static void ride_update_station_blocksection(Ride* ride, int32_t stationIndex) ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, true); } - else if (tileElement != nullptr && tile_element_get_green_light(tileElement)) + else if (tileElement != nullptr && tileElement->AsTrack()->HasGreenLight()) { ride_invalidate_station_start(ride, stationIndex, true); } @@ -298,7 +298,7 @@ static void ride_invalidate_station_start(Ride* ride, int32_t stationIndex, bool if (tileElement == nullptr) return; - tile_element_set_green_light(tileElement, greenLight); + tileElement->AsTrack()->SetHasGreenLight(greenLight); // Invalidate map tile map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 33e5ea0bb9..9108ed2f55 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -2201,20 +2201,6 @@ void TrackElement::SetSeatRotation(uint8_t newSeatRotation) colour |= (newSeatRotation << 4); } -bool tile_element_get_green_light(const rct_tile_element* tileElement) -{ - return (tileElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT) != 0; -} - -void tile_element_set_green_light(rct_tile_element* tileElement, bool greenLight) -{ - tileElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT; - if (greenLight) - { - tileElement->properties.track.sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT; - } -} - bool tile_element_is_taking_photo(const rct_tile_element* tileElement) { return (tileElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK) != 0; @@ -2353,3 +2339,18 @@ void TrackElement::SetBrakeBoosterSpeed(uint8_t speed) sequence &= ~0b11110000; sequence |= ((speed >> 1) << 4); } + +uint8_t TrackElement::HasGreenLight() const +{ + return (sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT) != 0; + +} + +void TrackElement::SetHasGreenLight(uint8_t greenLight) +{ + sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT; + if (greenLight) + { + sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT; + } +} diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 74c5833f72..69a9294453 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -559,8 +559,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); -bool tile_element_get_green_light(const rct_tile_element* tileElement); -void tile_element_set_green_light(rct_tile_element* tileElement, bool greenLight); bool tile_element_is_taking_photo(const rct_tile_element* tileElement); void tile_element_set_onride_photo_timeout(rct_tile_element* tileElement); void tile_element_decrement_onride_photo_timout(rct_tile_element* tileElement); diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 0dbfbe66cb..44e10d54fe 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -326,7 +326,7 @@ static void track_paint_util_draw_station_impl( LocationXY16 position = session->MapPosition; Ride* ride = get_ride(rideIndex); const rct_ride_entrance_definition* entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - const bool hasGreenLight = tile_element_get_green_light(tileElement); + const bool hasGreenLight = tileElement->AsTrack()->HasGreenLight(); bool hasFence; uint32_t imageId; @@ -531,7 +531,7 @@ void track_paint_util_draw_station_inverted( LocationXY16 position = session->MapPosition; Ride* ride = get_ride(rideIndex); const rct_ride_entrance_definition* entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - const bool hasGreenLight = tile_element_get_green_light(tileElement); + const bool hasGreenLight = tileElement->AsTrack()->HasGreenLight(); bool hasFence; uint32_t imageId; diff --git a/src/openrct2/ride/thrill/GoKarts.cpp b/src/openrct2/ride/thrill/GoKarts.cpp index c00609854f..542fdec9dd 100644 --- a/src/openrct2/ride/thrill/GoKarts.cpp +++ b/src/openrct2/ride/thrill/GoKarts.cpp @@ -408,7 +408,7 @@ static void paint_go_karts_station( if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION) { - const bool hasGreenLight = tile_element_get_green_light(tileElement); + const bool hasGreenLight = tileElement->AsTrack()->HasGreenLight(); switch (direction) { diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index c1e63a8f64..557d5d4bdb 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -281,6 +281,9 @@ public: uint8_t GetBrakeBoosterSpeed() const; void SetBrakeBoosterSpeed(uint8_t speed); + uint8_t HasGreenLight() const; + void SetHasGreenLight(uint8_t greenLight); + uint8_t GetSeatRotation() const; void SetSeatRotation(uint8_t newSeatRotation);