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:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user