Spin off MapLoc68BABCShouldContinue()

This commit is contained in:
Gymnasiast 2021-07-19 15:13:19 +02:00
parent 41e564d16c
commit f54b008ac3
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
1 changed files with 34 additions and 23 deletions

View File

@ -1302,6 +1302,39 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul
}
}
static bool MapLoc68BABCShouldContinue(
TileElement* tileElement, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, uint8_t flags, money32& price,
uint8_t crossingMode, bool canBuildCrossing)
{
if (clearFunc != nullptr)
{
if (!clearFunc(&tileElement, pos, flags, &price))
{
return true;
}
}
// Crossing mode 1: building track over path
if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_PATH
&& tileElement->GetBaseZ() == pos.baseZ && !tileElement->AsPath()->IsQueue() && !tileElement->AsPath()->IsSloped())
{
return true;
}
// Crossing mode 2: building path over track
else if (
crossingMode == 2 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK
&& tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat)
{
auto ride = get_ride(tileElement->AsTrack()->GetRideIndex());
if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS))
{
return true;
}
}
return false;
}
/**
*
* rct2: 0x0068B932
@ -1452,32 +1485,10 @@ std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructWithClearAt(
}
}
loc_68BABC:
if (clearFunc != nullptr)
{
if (!clearFunc(&tileElement, pos, flags, &res->Cost))
{
continue;
}
}
// Crossing mode 1: building track over path
if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_PATH
&& tileElement->GetBaseZ() == pos.baseZ && !tileElement->AsPath()->IsQueue()
&& !tileElement->AsPath()->IsSloped())
if (MapLoc68BABCShouldContinue(tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing))
{
continue;
}
// Crossing mode 2: building path over track
else if (
crossingMode == 2 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK
&& tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat)
{
auto ride = get_ride(tileElement->AsTrack()->GetRideIndex());
if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS))
{
continue;
}
}
if (tileElement != nullptr)
{