summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-08-08 13:53:06 +0000
committersmatz <smatz@openttd.org>2008-08-08 13:53:06 +0000
commitb595d59497c4871a3746d566689cda419c7010cd (patch)
tree5c519da21959a4107d907d96855ca27b0019edb4 /src
parent5229e45363cdbb2dbf8ae303475714e48fe4c4a6 (diff)
downloadopenttd-b595d59497c4871a3746d566689cda419c7010cd.tar.xz
(svn r14022) -Fix (r13957) [YAPP]: Removing station tiles could produce stale reservations, too. (michi_cc)
Diffstat (limited to 'src')
-rw-r--r--src/station_cmd.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 68eec417f..5ba071c21 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1027,6 +1027,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
do {
byte layout = *layout_ptr++;
if (IsRailwayStationTile(tile) && GetRailwayStationReservation(tile)) {
+ /* Check for trains having a reservation for this tile. */
Vehicle *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile)));
if (v != NULL) {
FreeTrainTrackReservation(v);
@@ -1062,9 +1063,10 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
} while (--numtracks);
for (uint i = 0; i < affected_vehicles.Length(); ++i) {
+ /* Restore reservations of trains. */
Vehicle *v = affected_vehicles[i];
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), true);
- TryPathReserve(v, true);
+ TryPathReserve(v, true, true);
for (; v->Next() != NULL; v = v->Next()) ;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(v))), true);
}
@@ -1198,7 +1200,14 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1
if (GetRailwayStationReservation(tile2)) {
v = GetTrainForReservation(tile2, track);
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != NULL) {
+ /* Free train reservation. */
+ FreeTrainTrackReservation(v);
+ if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), false);
+ Vehicle *temp = v;
+ for (; temp->Next() != NULL; temp = temp->Next()) ;
+ if (IsRailwayStationTile(temp->tile)) SetRailwayStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(temp))), false);
+ }
}
DoClearSquare(tile2);
@@ -1215,7 +1224,13 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1
st->MarkTilesDirty(false);
UpdateStationSignCoord(st);
- if (v != NULL) TryPathReserve(v, true);
+ if (v != NULL) {
+ /* Restore station reservation. */
+ if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), true);
+ TryPathReserve(v, true, true);
+ for (; v->Next() != NULL; v = v->Next()) ;
+ if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(v))), true);
+ }
/* if we deleted the whole station, delete the train facility. */
if (st->train_tile == 0) {