mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-31 10:45:16 +01:00
Simplify MapGetTrackElementAtFromRideIsUnderground
This commit is contained in:
@@ -6380,8 +6380,8 @@ void Vehicle::UpdateLandscapeDoor() const
|
||||
}
|
||||
|
||||
const auto coords = CoordsXYZ{ x, y, TrackLocation.z }.ToTileStart();
|
||||
const auto [tileElement, isUnderground] = MapGetTrackElementAtFromRideIsUnderground(coords, ride);
|
||||
if (isUnderground && tileElement != nullptr)
|
||||
const auto tileElement = MapGetTrackElementBeforeSurfaceAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
AnimateLandscapeDoor<false>(coords, *tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
}
|
||||
@@ -6441,8 +6441,8 @@ void Vehicle::UpdateLandscapeDoorBackwards() const
|
||||
}
|
||||
|
||||
const auto coords = CoordsXYZ{ TrackLocation, TrackLocation.z };
|
||||
const auto [tileElement, isUnderground] = MapGetTrackElementAtFromRideIsUnderground(coords, ride);
|
||||
if (isUnderground && tileElement != nullptr)
|
||||
const auto tileElement = MapGetTrackElementBeforeSurfaceAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
AnimateLandscapeDoor<true>(coords, *tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
}
|
||||
|
||||
@@ -2096,23 +2096,16 @@ TileElement* MapGetTrackElementAtFromRide(const CoordsXYZ& trackPos, RideId ride
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the track element at x, y, z that is the given track type and sequence, and whether it is underground.
|
||||
* @param x x units, not tiles.
|
||||
* @param y y units, not tiles.
|
||||
* @param z Base height.
|
||||
*/
|
||||
std::pair<TileElement*, bool> MapGetTrackElementAtFromRideIsUnderground(const CoordsXYZ& trackPos, const RideId rideIndex)
|
||||
TileElement* MapGetTrackElementBeforeSurfaceAtFromRide(const CoordsXYZ& trackPos, const RideId rideIndex)
|
||||
{
|
||||
TileElement* tileElement = MapGetFirstElementAt(trackPos);
|
||||
if (tileElement == nullptr)
|
||||
return std::pair(nullptr, false);
|
||||
return nullptr;
|
||||
const auto trackTilePos = TileCoordsXYZ{ trackPos };
|
||||
bool isUnderground = true;
|
||||
do
|
||||
{
|
||||
if (tileElement->GetType() == TileElementType::Surface)
|
||||
isUnderground = false;
|
||||
return nullptr;
|
||||
if (tileElement->GetType() != TileElementType::Track)
|
||||
continue;
|
||||
if (tileElement->BaseHeight != trackTilePos.z)
|
||||
@@ -2120,10 +2113,10 @@ std::pair<TileElement*, bool> MapGetTrackElementAtFromRideIsUnderground(const Co
|
||||
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
|
||||
continue;
|
||||
|
||||
return std::pair(tileElement, isUnderground);
|
||||
return tileElement;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
return std::pair(nullptr, false);
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -247,7 +247,7 @@ TrackElement* MapGetTrackElementAtOfTypeSeq(const CoordsXYZD& location, OpenRCT2
|
||||
TileElement* MapGetTrackElementAtOfTypeFromRide(const CoordsXYZ& trackPos, OpenRCT2::TrackElemType trackType, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementAtFromRide(const CoordsXYZ& trackPos, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementAtWithDirectionFromRide(const CoordsXYZD& trackPos, RideId rideIndex);
|
||||
std::pair<TileElement*, bool> MapGetTrackElementAtFromRideIsUnderground(const CoordsXYZ& trackPos, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementBeforeSurfaceAtFromRide(const CoordsXYZ& trackPos, RideId rideIndex);
|
||||
|
||||
bool MapIsLocationAtEdge(const CoordsXY& loc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user