Fix rail platforms being left partially reserved after train crash
This commit is contained in:
@@ -6122,6 +6122,20 @@ static void SetSignalledBridgeTunnelGreenIfClear(TileIndex tile, TileIndex end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, VEH_TRAIN, nullptr, &TrainOnTileEnum)) return true;
|
||||||
|
}
|
||||||
|
for (TileIndex t = tile + delta; IsCompatibleTrainStationTile(t, tile); t += delta) {
|
||||||
|
if (HasVehicleOnPos(t, VEH_TRAIN, nullptr, &TrainOnTileEnum)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes/Clears the last wagon of a crashed train. It takes the engine of the
|
* 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
|
* train, then goes to the last wagon and deletes that. Each call to this function
|
||||||
@@ -6176,6 +6190,13 @@ static void DeleteLastWagon(Train *v)
|
|||||||
/* check if the wagon was on a road/rail-crossing */
|
/* check if the wagon was on a road/rail-crossing */
|
||||||
if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile);
|
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 */
|
/* Update signals */
|
||||||
if (IsTunnelBridgeWithSignalSimulation(tile)) {
|
if (IsTunnelBridgeWithSignalSimulation(tile)) {
|
||||||
TileIndex end = GetOtherTunnelBridgeEnd(tile);
|
TileIndex end = GetOtherTunnelBridgeEnd(tile);
|
||||||
|
Reference in New Issue
Block a user