1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Prevent land edge doors creating animations if not underground

This commit is contained in:
mix
2025-05-24 17:21:14 +01:00
parent 17d321103f
commit 0a63059580
3 changed files with 35 additions and 4 deletions

View File

@@ -6380,8 +6380,8 @@ void Vehicle::UpdateLandscapeDoor() const
}
const auto coords = CoordsXYZ{ x, y, TrackLocation.z }.ToTileStart();
auto* const tileElement = MapGetTrackElementAtFromRide(coords, ride);
if (tileElement != nullptr && tileElement->GetType() == TileElementType::Track)
const auto [tileElement, isUnderground] = MapGetTrackElementAtFromRideIsUnderground(coords, ride);
if (isUnderground && 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 };
auto* const tileElement = MapGetTrackElementAtFromRide(coords, ride);
if (tileElement != nullptr && tileElement->GetType() == TileElementType::Track)
const auto [tileElement, isUnderground] = MapGetTrackElementAtFromRideIsUnderground(coords, ride);
if (isUnderground && tileElement != nullptr)
{
AnimateLandscapeDoor<true>(coords, *tileElement->AsTrack(), next_vehicle_on_train.IsNull());
}

View File

@@ -2096,6 +2096,36 @@ 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* tileElement = MapGetFirstElementAt(trackPos);
if (tileElement == nullptr)
return std::pair(nullptr, false);
const auto trackTilePos = TileCoordsXYZ{ trackPos };
bool isUnderground = true;
do
{
if (tileElement->GetType() == TileElementType::Surface)
isUnderground = false;
if (tileElement->GetType() != TileElementType::Track)
continue;
if (tileElement->BaseHeight != trackTilePos.z)
continue;
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
continue;
return std::pair(tileElement, isUnderground);
} while (!(tileElement++)->IsLastForTile());
return std::pair(nullptr, false);
};
/**
* Gets the track element at x, y, z that is the given track type and sequence.
* @param x x units, not tiles.

View File

@@ -247,6 +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);
bool MapIsLocationAtEdge(const CoordsXY& loc);