mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Move tile element banner functions to methods
This commit is contained in:
committed by
GitHub
parent
b0e57c0ca9
commit
1b686816db
@@ -115,7 +115,7 @@ GameActions::Result::Ptr BannerRemoveAction::Execute() const
|
||||
res->Cost = -((bannerEntry->banner.price * 3) / 4);
|
||||
}
|
||||
|
||||
tile_element_remove_banner_entry(reinterpret_cast<TileElement*>(bannerElement));
|
||||
reinterpret_cast<TileElement*>(bannerElement)->RemoveBannerEntry();
|
||||
map_invalidate_tile_zoom1({ _loc, _loc.z, _loc.z + 32 });
|
||||
bannerElement->Remove();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<TileElement*>(wallElement));
|
||||
reinterpret_cast<TileElement*>(wallElement)->RemoveBannerEntry();
|
||||
map_invalidate_tile_zoom1({ wallPos, wallElement->GetBaseZ(), wallElement->GetBaseZ() + 72 });
|
||||
tile_element_remove(reinterpret_cast<TileElement*>(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--;
|
||||
|
||||
Reference in New Issue
Block a user