diff options
author | smatz <smatz@openttd.org> | 2007-12-15 00:04:01 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2007-12-15 00:04:01 +0000 |
commit | 57a83e7c76f13ec1342aae89dc92dc10d9a4bd37 (patch) | |
tree | 287f86cadd9e1f7e3e0d8388fb05da8f6823336d /src/train_cmd.cpp | |
parent | d31506654cd28005f062c003cc36bbfd5ffd8fea (diff) | |
download | openttd-57a83e7c76f13ec1342aae89dc92dc10d9a4bd37.tar.xz |
(svn r11634) -Fix: update signals when deleting crashed train on a bridge, update even when train is rotated
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 401e9ab49..7c1f488cd 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3030,7 +3030,7 @@ reverse_train_direction: * 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 * will remove the last wagon of a crashed train. If this wagon was on a crossing, - * or inside a tunnel, recalculate the signals as they might need updating + * or inside a tunnel/bridge, recalculate the signals as they might need updating * @param v the Vehicle of which last wagon is to be removed */ static void DeleteLastWagon(Vehicle *v) @@ -3059,27 +3059,16 @@ static void DeleteLastWagon(Vehicle *v) * others are on it */ DisableTrainCrossing(v->tile); - if ((v->u.rail.track == TRACK_BIT_WORMHOLE && v->vehstatus & VS_HIDDEN)) { // inside a tunnel - TileIndex endtile = GetOtherTunnelEnd(v->tile); + if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge + TileIndex endtile = IsTunnel(v->tile) ? GetOtherTunnelEnd(v->tile) : GetOtherBridgeEnd(v->tile); - if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel is busy (error returned) + if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy - switch (v->direction) { - case 1: - case 5: - SetSignalsOnBothDir(v->tile, 0); - SetSignalsOnBothDir(endtile, 0); - break; - - case 3: - case 7: - SetSignalsOnBothDir(v->tile, 1); - SetSignalsOnBothDir(endtile, 1); - break; + DiagDirection dir = IsTunnel(v->tile) ? GetTunnelDirection(v->tile) : GetBridgeRampDirection(v->tile); - default: - break; - } + /* v->direction is "random", so it cannot be used to determine the direction of the track */ + UpdateSignalsOnSegment(v->tile, dir); + UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir)); } } |