From ee05438953580e846673b3be2fce47f2a9874cdb Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 16 Sep 2018 16:46:23 +0200 Subject: [PATCH] Replace C-style functions for checking path addition ghost status --- src/openrct2/paint/tile_element/Paint.Path.cpp | 2 +- src/openrct2/peep/Guest.cpp | 14 +++++++------- src/openrct2/peep/Staff.cpp | 4 ++-- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/world/Footpath.cpp | 18 ++++++++---------- src/openrct2/world/Footpath.h | 2 -- src/openrct2/world/Fountain.cpp | 2 +- src/openrct2/world/Scenery.cpp | 2 +- src/openrct2/world/TileElement.h | 3 +++ 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index ffda208efe..168993093f 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -817,7 +817,7 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element* imageFlags = SPRITE_ID_PALETTE_COLOUR_1(PALETTE_46); } - if (footpath_element_path_scenery_is_ghost(tile_element)) + if (tile_element->AsPath()->AdditionIsGhost()) { sceneryImageFlags = CONSTRUCTION_MARKER; } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 6caa694228..65e2cea215 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -641,7 +641,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) // Check if the footpath has a queue line TV monitor on it if (footpath_element_has_path_scenery(tileElement) - && !footpath_element_path_scenery_is_ghost(tileElement)) + && !tileElement->AsPath()->AdditionIsGhost()) { uint8_t pathSceneryIndex = footpath_element_get_path_scenery_index(tileElement); rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex); @@ -2726,7 +2726,7 @@ static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int1 { return PEEP_THOUGHT_TYPE_NONE; } - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) break; if (scenery->path_bit.flags @@ -5320,7 +5320,7 @@ void rct_peep::UpdateWalking() if (footpath_element_has_path_scenery(tileElement)) { - if (!footpath_element_path_scenery_is_ghost(tileElement)) + if (!tileElement->AsPath()->AdditionIsGhost()) { rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (sceneryEntry == nullptr) @@ -5772,7 +5772,7 @@ void rct_peep::UpdateUsingBin() return; } - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) { StateReset(); return; @@ -5930,7 +5930,7 @@ bool rct_peep::UpdateWalkingFindBench() if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) return false; - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) return false; int32_t edges = (tileElement->properties.path.edges & 0xF) ^ 0xF; @@ -6029,7 +6029,7 @@ bool rct_peep::UpdateWalkingFindBin() if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) return false; - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) return false; int32_t edges = (tileElement->properties.path.edges & 0xF) ^ 0xF; @@ -6126,7 +6126,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep) if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) return; - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) return; int32_t edges = tileElement->properties.path.edges & 0xF; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 03217490bf..0980ac8e0c 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1818,7 +1818,7 @@ void rct_peep::UpdateEmptyingBin() rct_scenery_entry* scenery_entry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tile_element)); if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->flags & (1 << 5) - || footpath_element_path_scenery_is_ghost(tile_element)) + || tile_element->AsPath()->AdditionIsGhost()) { StateReset(); return; @@ -2220,7 +2220,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep) if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) return 0; - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) return 0; uint8_t bin_positions = tileElement->properties.path.edges & 0xF; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 57a432060b..011357e4aa 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2511,7 +2511,7 @@ private: tileElement->AsPath()->SetIsQueue(true); } - footpath_scenery_set_is_ghost(tileElement, false); + tileElement->AsPath()->SetAdditionIsGhost(false); // Additions uint8_t additionType = footpath_element_get_path_scenery(tileElement); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 16fc19b1c7..3018998592 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -365,16 +365,16 @@ static money32 footpath_element_update( // There is nothing yet - check if we should place a ghost if (flags & GAME_COMMAND_FLAG_APPLY) - footpath_scenery_set_is_ghost(tileElement, true); + tileElement->AsPath()->SetAdditionIsGhost(true); } if (!(flags & GAME_COMMAND_FLAG_APPLY)) return gParkFlags & PARK_FLAGS_NO_MONEY ? 0 : gFootpathPrice; if ((pathItemType != 0 && !(flags & GAME_COMMAND_FLAG_GHOST)) - || (pathItemType == 0 && footpath_element_path_scenery_is_ghost(tileElement))) + || (pathItemType == 0 && tileElement->AsPath()->AdditionIsGhost())) { - footpath_scenery_set_is_ghost(tileElement, false); + tileElement->AsPath()->SetAdditionIsGhost(false); } footpath_element_set_path_scenery(tileElement, pathItemType); @@ -2025,18 +2025,16 @@ uint8_t footpath_element_get_path_scenery_index(const rct_tile_element* tileElem return footpath_element_get_path_scenery(tileElement) - 1; } -bool footpath_element_path_scenery_is_ghost(const rct_tile_element* tileElement) +bool PathElement::AdditionIsGhost() const { - return (tileElement->properties.path.additions & FOOTPATH_ADDITION_FLAG_IS_GHOST) != 0; + return (additions & FOOTPATH_ADDITION_FLAG_IS_GHOST) != 0; } -void footpath_scenery_set_is_ghost(rct_tile_element* tileElement, bool isGhost) +void PathElement::SetAdditionIsGhost(bool isGhost) { - // Remove ghost flag - tileElement->properties.path.additions &= ~FOOTPATH_ADDITION_FLAG_IS_GHOST; - // Set flag if it should be a ghost + additions &= ~FOOTPATH_ADDITION_FLAG_IS_GHOST; if (isGhost) - tileElement->properties.path.additions |= FOOTPATH_ADDITION_FLAG_IS_GHOST; + additions |= FOOTPATH_ADDITION_FLAG_IS_GHOST; } uint8_t footpath_element_get_type(const rct_tile_element* tileElement) diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 4c922ad778..25dcd5e6a2 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -163,8 +163,6 @@ bool footpath_element_has_path_scenery(const rct_tile_element* tileElement); uint8_t footpath_element_get_path_scenery(const rct_tile_element* tileElement); void footpath_element_set_path_scenery(rct_tile_element* tileElement, uint8_t pathSceneryType); uint8_t footpath_element_get_path_scenery_index(const rct_tile_element* tileElement); -bool footpath_element_path_scenery_is_ghost(const rct_tile_element* tileElement); -void footpath_scenery_set_is_ghost(rct_tile_element* tileElement, bool isGhost); 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/Fountain.cpp b/src/openrct2/world/Fountain.cpp index bc8422c4b3..357e197251 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -259,7 +259,7 @@ static bool is_jumping_fountain(int32_t type, int32_t x, int32_t y, int32_t z) continue; if (tileElement->base_height != z) continue; - if (footpath_element_path_scenery_is_ghost(tileElement)) + if (tileElement->AsPath()->AdditionIsGhost()) continue; if (!footpath_element_has_path_scenery(tileElement)) continue; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 697c8f201b..55ec2779e1 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -88,7 +88,7 @@ void scenery_update_tile(int32_t x, int32_t y) } else if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) { - if (footpath_element_has_path_scenery(tileElement) && !footpath_element_path_scenery_is_ghost(tileElement)) + if (footpath_element_has_path_scenery(tileElement) && !tileElement->AsPath()->AdditionIsGhost()) { rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (sceneryEntry != nullptr) diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 823aa89214..cc3bf86eba 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -207,6 +207,9 @@ public: void SetIsQueue(bool isQueue); bool HasQueueBanner() const; + bool AdditionIsGhost() const; + void SetAdditionIsGhost(bool isGhost); + uint8_t GetRCT1PathType() const; }; assert_struct_size(PathElement, 8);