Mercurial > hg > openttd
comparison src/train_cmd.cpp @ 8073:ab953ea59f2e draft
(svn r11634) -Fix: update signals when deleting crashed train on a bridge, update even when train is rotated
author | smatz <smatz@openttd.org> |
---|---|
date | Sat, 15 Dec 2007 00:04:01 +0000 |
parents | 0cba7093ca14 |
children | 97d86b93edda |
comparison
equal
deleted
inserted
replaced
8072:0cba7093ca14 | 8073:ab953ea59f2e |
---|---|
3028 | 3028 |
3029 /** | 3029 /** |
3030 * Deletes/Clears the last wagon of a crashed train. It takes the engine of the | 3030 * Deletes/Clears the last wagon of a crashed train. It takes the engine of the |
3031 * train, then goes to the last wagon and deletes that. Each call to this function | 3031 * train, then goes to the last wagon and deletes that. Each call to this function |
3032 * will remove the last wagon of a crashed train. If this wagon was on a crossing, | 3032 * will remove the last wagon of a crashed train. If this wagon was on a crossing, |
3033 * or inside a tunnel, recalculate the signals as they might need updating | 3033 * or inside a tunnel/bridge, recalculate the signals as they might need updating |
3034 * @param v the Vehicle of which last wagon is to be removed | 3034 * @param v the Vehicle of which last wagon is to be removed |
3035 */ | 3035 */ |
3036 static void DeleteLastWagon(Vehicle *v) | 3036 static void DeleteLastWagon(Vehicle *v) |
3037 { | 3037 { |
3038 /* Go to the last wagon and delete the link pointing there | 3038 /* Go to the last wagon and delete the link pointing there |
3057 | 3057 |
3058 /* Check if the wagon was on a road/rail-crossing and disable it if no | 3058 /* Check if the wagon was on a road/rail-crossing and disable it if no |
3059 * others are on it */ | 3059 * others are on it */ |
3060 DisableTrainCrossing(v->tile); | 3060 DisableTrainCrossing(v->tile); |
3061 | 3061 |
3062 if ((v->u.rail.track == TRACK_BIT_WORMHOLE && v->vehstatus & VS_HIDDEN)) { // inside a tunnel | 3062 if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge |
3063 TileIndex endtile = GetOtherTunnelEnd(v->tile); | 3063 TileIndex endtile = IsTunnel(v->tile) ? GetOtherTunnelEnd(v->tile) : GetOtherBridgeEnd(v->tile); |
3064 | 3064 |
3065 if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel is busy (error returned) | 3065 if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy |
3066 | 3066 |
3067 switch (v->direction) { | 3067 DiagDirection dir = IsTunnel(v->tile) ? GetTunnelDirection(v->tile) : GetBridgeRampDirection(v->tile); |
3068 case 1: | 3068 |
3069 case 5: | 3069 /* v->direction is "random", so it cannot be used to determine the direction of the track */ |
3070 SetSignalsOnBothDir(v->tile, 0); | 3070 UpdateSignalsOnSegment(v->tile, dir); |
3071 SetSignalsOnBothDir(endtile, 0); | 3071 UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir)); |
3072 break; | |
3073 | |
3074 case 3: | |
3075 case 7: | |
3076 SetSignalsOnBothDir(v->tile, 1); | |
3077 SetSignalsOnBothDir(endtile, 1); | |
3078 break; | |
3079 | |
3080 default: | |
3081 break; | |
3082 } | |
3083 } | 3072 } |
3084 } | 3073 } |
3085 | 3074 |
3086 static void ChangeTrainDirRandomly(Vehicle *v) | 3075 static void ChangeTrainDirRandomly(Vehicle *v) |
3087 { | 3076 { |