From a6885ea464b0e75308568d69e4edff6aa897edac Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 16 Sep 2018 17:24:49 +0200 Subject: [PATCH] Replace C-style functions for getting direction --- src/openrct2/paint/tile_element/Paint.Path.cpp | 2 +- src/openrct2/peep/Peep.cpp | 2 +- src/openrct2/world/Footpath.cpp | 13 ++++++------- src/openrct2/world/Footpath.h | 2 -- src/openrct2/world/MapAnimation.cpp | 2 +- src/openrct2/world/TileElement.h | 5 ++++- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 3aabde25bb..a51765d3be 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -409,7 +409,7 @@ static void sub_6A4101( return; } - uint8_t direction = footpath_element_get_direction(tile_element); + uint8_t direction = tile_element->AsPath()->GetQueueBannerDirection(); // Draw ride sign session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; if (tile_element->AsPath()->IsSloped()) diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index ed9b00bc90..d5d2ab6f8b 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2929,7 +2929,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti uint8_t stationNum = (tile_element->properties.path.additions & 0x70) >> 4; if ((tile_element->properties.path.type & (1 << 3)) // Queue has the ride sign on it - && (footpath_element_get_direction(tile_element) + && (tile_element->AsPath()->GetQueueBannerDirection() == ((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking ) { diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 1a33c55d86..809e0b544a 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1701,8 +1701,7 @@ void footpath_chain_ride_queue( if (lastPathElement->AsPath()->IsQueue()) { lastPathElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER; - lastPathElement->type &= 0x3F; // Clear the ride sign direction - footpath_element_set_direction(lastPathElement, lastPathDirection); // set the ride sign direction + lastPathElement->AsPath()->SetQueueBannerDirection(lastPathDirection); // set the ride sign direction map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, lastPathX, lastPathY, lastPathElement->base_height); } @@ -2058,15 +2057,15 @@ void PathElement::SetEntryIndex(uint8_t newEntryIndex) entryIndex |= (newEntryIndex << 4); } -uint8_t footpath_element_get_direction(const rct_tile_element* tileElement) +uint8_t PathElement::GetQueueBannerDirection() const { - return ((tileElement->type & FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK) >> 6); + return ((type & FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK) >> 6); } -void footpath_element_set_direction(rct_tile_element* tileElement, uint8_t direction) +void PathElement::SetQueueBannerDirection(uint8_t direction) { - tileElement->type &= ~FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK; - tileElement->type |= (direction << 6); + type &= ~FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK; + type |= (direction << 6); } /** diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 66410bd6c6..fee894aef7 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -155,8 +155,6 @@ bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position); int32_t footpath_is_connected_to_map_edge(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t flags); uint8_t footpath_element_get_slope_direction(const rct_tile_element* tileElement); -uint8_t footpath_element_get_direction(const rct_tile_element* tileElement); -void footpath_element_set_direction(rct_tile_element* tileElement, uint8_t direction); void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElement); int32_t entrance_get_directions(const rct_tile_element* tileElement); diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index bc0b7aa8a7..0a3a4294c3 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -148,7 +148,7 @@ static bool map_animation_invalidate_queue_banner(int32_t x, int32_t y, int32_t if (!tileElement->AsPath()->HasQueueBanner()) continue; - int32_t direction = (footpath_element_get_direction(tileElement) + get_current_rotation()) & 3; + int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + get_current_rotation()) & 3; if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST) { baseZ = tileElement->base_height * 8; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index b4dec9c650..df596fd230 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -201,7 +201,10 @@ public: uint8_t GetEntryIndex() const; rct_footpath_entry* GetEntry() const; void SetEntryIndex(uint8_t newIndex); - + + uint8_t GetQueueBannerDirection() const; + void SetQueueBannerDirection(uint8_t direction); + bool IsSloped() const; void SetSloped(bool isSloped);