Change tile_element_get_ride_index() to method

This commit is contained in:
Gymnasiast 2020-10-27 21:59:55 +01:00
parent 92a5f1aa24
commit d58a8d1184
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
6 changed files with 12 additions and 12 deletions

View File

@ -296,7 +296,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor
return info;
}
ride = get_ride(tile_element_get_ride_index(tileElement));
ride = get_ride(tileElement->GetRideIndex());
if (ride == nullptr)
{
info.SpriteType = VIEWPORT_INTERACTION_ITEM_NONE;

View File

@ -1376,7 +1376,7 @@ static rct_window* window_ride_open_station(Ride* ride, StationIndex stationInde
rct_window* window_ride_open_track(TileElement* tileElement)
{
assert(tileElement != nullptr);
auto rideIndex = tile_element_get_ride_index(tileElement);
auto rideIndex = tileElement->GetRideIndex();
if (rideIndex != RIDE_ID_NULL)
{
auto ride = get_ride(rideIndex);

View File

@ -88,7 +88,7 @@ public:
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
continue;
if (tile_element_get_ride_index(tileElement) != _rideIndex)
if (tileElement->GetRideIndex() != _rideIndex)
continue;
if (tileElement->AsEntrance()->GetStationIndex() != _stationNum)
@ -148,7 +148,7 @@ public:
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
continue;
if (tile_element_get_ride_index(tileElement) != _rideIndex)
if (tileElement->GetRideIndex() != _rideIndex)
continue;
if (tileElement->AsEntrance()->GetStationIndex() != _stationNum)

View File

@ -1821,7 +1821,7 @@ bool ride_modify(CoordsXYE* input)
if (tileElement.element == nullptr)
return false;
auto rideIndex = tile_element_get_ride_index(tileElement.element);
auto rideIndex = tileElement.element->GetRideIndex();
auto ride = get_ride(rideIndex);
if (ride == nullptr)
{

View File

@ -141,16 +141,16 @@ void tile_element_remove_banner_entry(TileElement* tileElement)
}
}
uint8_t tile_element_get_ride_index(const TileElement* tileElement)
ride_id_t TileElement::GetRideIndex() const
{
switch (tileElement->GetType())
switch (GetType())
{
case TILE_ELEMENT_TYPE_TRACK:
return tileElement->AsTrack()->GetRideIndex();
return AsTrack()->GetRideIndex();
case TILE_ELEMENT_TYPE_ENTRANCE:
return tileElement->AsEntrance()->GetRideIndex();
return AsEntrance()->GetRideIndex();
case TILE_ELEMENT_TYPE_PATH:
return tileElement->AsPath()->GetRideIndex();
return AsPath()->GetRideIndex();
default:
return RIDE_ID_NULL;
}

View File

@ -181,6 +181,8 @@ public:
}
void ClearAs(uint8_t newType);
ride_id_t GetRideIndex() const;
};
assert_struct_size(TileElement, 16);
@ -683,5 +685,3 @@ 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);
uint8_t tile_element_get_ride_index(const TileElement* tileElement);