diff --git a/src/openrct2/actions/BannerRemoveAction.cpp b/src/openrct2/actions/BannerRemoveAction.cpp index 8d2c246ae0..202e8f6747 100644 --- a/src/openrct2/actions/BannerRemoveAction.cpp +++ b/src/openrct2/actions/BannerRemoveAction.cpp @@ -115,7 +115,7 @@ GameActions::Result::Ptr BannerRemoveAction::Execute() const res->Cost = -((bannerEntry->banner.price * 3) / 4); } - tile_element_remove_banner_entry(reinterpret_cast(bannerElement)); + reinterpret_cast(bannerElement)->RemoveBannerEntry(); map_invalidate_tile_zoom1({ _loc, _loc.z, _loc.z + 32 }); bannerElement->Remove(); diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.cpp b/src/openrct2/actions/LargeSceneryRemoveAction.cpp index b59f88b49c..d538176206 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.cpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.cpp @@ -136,7 +136,7 @@ GameActions::Result::Ptr LargeSceneryRemoveAction::Execute() const return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } - tile_element_remove_banner_entry(tileElement); + tileElement->RemoveBannerEntry(); rct_scenery_entry* scenery_entry = tileElement->AsLargeScenery()->GetEntry(); diff --git a/src/openrct2/actions/WallRemoveAction.cpp b/src/openrct2/actions/WallRemoveAction.cpp index 518cbd4b0d..9ac0f598c4 100644 --- a/src/openrct2/actions/WallRemoveAction.cpp +++ b/src/openrct2/actions/WallRemoveAction.cpp @@ -84,7 +84,7 @@ GameActions::Result::Ptr WallRemoveAction::Execute() const res->Position.y = _loc.y + 16; res->Position.z = tile_element_height(res->Position); - tile_element_remove_banner_entry(wallElement); + wallElement->RemoveBannerEntry(); map_invalidate_tile_zoom1({ _loc, wallElement->GetBaseZ(), (wallElement->GetBaseZ()) + 72 }); tile_element_remove(wallElement); diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index af09e64db2..9fdcfc5cd6 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -175,7 +175,7 @@ TileElement* banner_get_tile_element(BannerIndex bannerIndex) { do { - if (tile_element_get_banner_index(tileElement) == bannerIndex) + if (tileElement->GetBannerIndex() == bannerIndex) { return tileElement; } diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 03e5374092..4bbdfc907c 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -86,43 +86,43 @@ bool tile_element_is_underground(TileElement* tileElement) return true; } -BannerIndex tile_element_get_banner_index(TileElement* tileElement) +BannerIndex TileElement::GetBannerIndex() const { rct_scenery_entry* sceneryEntry; - switch (tileElement->GetType()) + switch (GetType()) { case TILE_ELEMENT_TYPE_LARGE_SCENERY: - sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); + sceneryEntry = AsLargeScenery()->GetEntry(); if (sceneryEntry == nullptr || sceneryEntry->large_scenery.scrolling_mode == SCROLLING_MODE_NONE) return BANNER_INDEX_NULL; - return tileElement->AsLargeScenery()->GetBannerIndex(); + return AsLargeScenery()->GetBannerIndex(); case TILE_ELEMENT_TYPE_WALL: - sceneryEntry = tileElement->AsWall()->GetEntry(); + sceneryEntry = AsWall()->GetEntry(); if (sceneryEntry == nullptr || sceneryEntry->wall.scrolling_mode == SCROLLING_MODE_NONE) return BANNER_INDEX_NULL; - return tileElement->AsWall()->GetBannerIndex(); + return AsWall()->GetBannerIndex(); case TILE_ELEMENT_TYPE_BANNER: - return tileElement->AsBanner()->GetIndex(); + return AsBanner()->GetIndex(); default: return BANNER_INDEX_NULL; } } -void tile_element_set_banner_index(TileElement* tileElement, BannerIndex bannerIndex) +void TileElement::SetBannerIndex(BannerIndex bannerIndex) { - switch (tileElement->GetType()) + switch (GetType()) { case TILE_ELEMENT_TYPE_WALL: - tileElement->AsWall()->SetBannerIndex(bannerIndex); + AsWall()->SetBannerIndex(bannerIndex); break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: - tileElement->AsLargeScenery()->SetBannerIndex(bannerIndex); + AsLargeScenery()->SetBannerIndex(bannerIndex); break; case TILE_ELEMENT_TYPE_BANNER: - tileElement->AsBanner()->SetIndex(bannerIndex); + AsBanner()->SetIndex(bannerIndex); break; default: log_error("Tried to set banner index on unsuitable tile element!"); @@ -130,9 +130,9 @@ void tile_element_set_banner_index(TileElement* tileElement, BannerIndex bannerI } } -void tile_element_remove_banner_entry(TileElement* tileElement) +void TileElement::RemoveBannerEntry() { - auto bannerIndex = tile_element_get_banner_index(tileElement); + auto bannerIndex = GetBannerIndex(); auto banner = GetBanner(bannerIndex); if (banner != nullptr) { diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 7cc9037652..9225352ccf 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -183,6 +183,10 @@ public: void ClearAs(uint8_t newType); ride_id_t GetRideIndex() const; + + void SetBannerIndex(BannerIndex newIndex); + void RemoveBannerEntry(); + BannerIndex GetBannerIndex() const; }; assert_struct_size(TileElement, 16); @@ -679,9 +683,4 @@ enum #define TILE_ELEMENT_COLOUR_MASK 0b00011111 -BannerIndex tile_element_get_banner_index(TileElement* tileElement); bool tile_element_is_underground(TileElement* tileElement); - -// ~Oli414: The banner functions should probably be part of banner. -void tile_element_set_banner_index(TileElement* tileElement, BannerIndex bannerIndex); -void tile_element_remove_banner_entry(TileElement* tileElement); diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 0534668975..21c00286ec 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -208,13 +208,13 @@ GameActionResultPtr tile_inspector_remove_element_at(const CoordsXY& loc, int16_ // Only delete the banner entry if there are no other parts of the large scenery to delete if (numLargeScenerySequences(loc, largeScenery) == 1) { - tile_element_remove_banner_entry(tileElement); + tileElement->RemoveBannerEntry(); } } else { // Removes any potential banners from the entry - tile_element_remove_banner_entry(tileElement); + tileElement->RemoveBannerEntry(); } tile_element_remove(tileElement); @@ -363,7 +363,7 @@ GameActionResultPtr tile_inspector_paste_element_at(const CoordsXY& loc, TileEle if (isExecuting) { // Check if the element to be pasted refers to a banner index - auto bannerIndex = tile_element_get_banner_index(&element); + auto bannerIndex = element.GetBannerIndex(); if (bannerIndex != BANNER_INDEX_NULL) { // The element to be pasted refers to a banner index - make a copy of it @@ -377,7 +377,7 @@ GameActionResultPtr tile_inspector_paste_element_at(const CoordsXY& loc, TileEle newBanner.position = tileLoc; // Use the new banner index - tile_element_set_banner_index(&element, newBannerIndex); + element.SetBannerIndex(newBannerIndex); } // The occupiedQuadrants will be automatically set when the element is copied over, so it's not necessary to set them diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index 57f134e6a7..e5471cca4b 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -37,7 +37,7 @@ void wall_remove_at(const CoordsXYRangedZ& wallPos) for (auto wallElement = map_get_wall_element_at(wallPos); wallElement != nullptr; wallElement = map_get_wall_element_at(wallPos)) { - tile_element_remove_banner_entry(reinterpret_cast(wallElement)); + reinterpret_cast(wallElement)->RemoveBannerEntry(); map_invalidate_tile_zoom1({ wallPos, wallElement->GetBaseZ(), wallElement->GetBaseZ() + 72 }); tile_element_remove(reinterpret_cast(wallElement)); } @@ -74,7 +74,7 @@ void wall_remove_intersecting_walls(const CoordsXYRangedZ& wallPos, Direction di if (direction != tileElement->GetDirection()) continue; - tile_element_remove_banner_entry(tileElement); + tileElement->RemoveBannerEntry(); map_invalidate_tile_zoom1({ wallPos, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 72 }); tile_element_remove(tileElement); tileElement--;