@@ -3550,6 +3550,20 @@ static Vehicle *CollectTrackbitsFromCras
return nullptr;
}
static bool IsRailStationPlatformOccupied(TileIndex tile)
{
TileIndexDiff delta = (GetRailStationAxis(tile) == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
for (TileIndex t = tile; IsCompatibleTrainStationTile(t, tile); t -= delta) {
if (HasVehicleOnPos(t, nullptr, &TrainOnTileEnum)) return true;
for (TileIndex t = tile + delta; IsCompatibleTrainStationTile(t, tile); t += delta) {
return false;
/**
* Deletes/Clears the last wagon of a crashed train. It takes the engine of the
* train, then goes to the last wagon and deletes that. Each call to this function
@@ -3608,6 +3622,13 @@ static void DeleteLastWagon(Train *v)
/* check if the wagon was on a road/rail-crossing */
if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile);
if (IsRailStationTile(tile)) {
bool occupied = IsRailStationPlatformOccupied(tile);
DiagDirection dir = AxisToDiagDir(GetRailStationAxis(tile));
SetRailStationPlatformReservation(tile, dir, occupied);
SetRailStationPlatformReservation(tile, ReverseDiagDir(dir), occupied);
/* Update signals */
if (IsTileType(tile, MP_TUNNELBRIDGE) || IsRailDepotTile(tile)) {
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
Status change: