summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:55:08 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:55:08 +0000
commit753da05bc612002b3ea5eca8d17c883479016189 (patch)
tree9de1c30da5558dcc2ee3cbb3175aecf553951635 /src/tunnelbridge_cmd.cpp
parentbce6f7b41cda862b6405e506dacd9e57c3189d7e (diff)
downloadopenttd-753da05bc612002b3ea5eca8d17c883479016189.tar.xz
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 41af685ac..08588e4ed 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -630,8 +630,15 @@ static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
/* We first need to request values before calling DoClearSquare */
DiagDirection dir = GetTunnelBridgeDirection(tile);
+ Track track = DiagDirToDiagTrack(dir);
Owner owner = GetTileOwner(tile);
+ Vehicle *v = NULL;
+ if (GetTunnelBridgeReservation(tile)) {
+ v = GetTrainForReservation(tile, track);
+ if (v != NULL) FreeTrainTrackReservation(v);
+ }
+
DoClearSquare(tile);
DoClearSquare(endtile);
@@ -639,9 +646,10 @@ static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
AddSideToSignalBuffer(tile, ReverseDiagDir(dir), owner);
AddSideToSignalBuffer(endtile, dir, owner);
- Track track = DiagDirToDiagTrack(dir);
YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track);
+
+ if (v != NULL) TryPathReserve(v);
} else {
DoClearSquare(tile);
DoClearSquare(endtile);
@@ -689,6 +697,12 @@ static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
Owner owner = GetTileOwner(tile);
uint height = GetBridgeHeight(tile);
+ Vehicle *v = NULL;
+
+ if (rail && GetTunnelBridgeReservation(tile)) {
+ v = GetTrainForReservation(tile, DiagDirToDiagTrack(direction));
+ if (v != NULL) FreeTrainTrackReservation(v);
+ }
DoClearSquare(tile);
DoClearSquare(endtile);
@@ -710,6 +724,8 @@ static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
Track track = DiagDirToDiagTrack(direction);
YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track);
+
+ if (v != NULL) TryPathReserve(v, true);
}
}