summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-21 16:02:14 +0000
committertruelight <truelight@openttd.org>2004-12-21 16:02:14 +0000
commit8ee37e7b4749f1a21ca90d97f462a14106e79f88 (patch)
treebd60a10d7bef73e4f35348da0e6b62882d69d762 /train_cmd.c
parent24853eb42c0c86b06bf9fcdefb226125ba24faa4 (diff)
downloadopenttd-8ee37e7b4749f1a21ca90d97f462a14106e79f88.tar.xz
(svn r1199) -Fix: [ 958098 ] No longer road/rail crossing signals hang when a train
is reversed at the wrong moment (Yeah, our longest open bug finally fixed :) :) :))
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/train_cmd.c b/train_cmd.c
index fdaeea335..626398585 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -963,6 +963,25 @@ static void ReverseTrainDirection(Vehicle *v)
if (IsTrainDepotTile(v->tile))
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+ /* Check if we were approaching a rail/road-crossing */
+ {
+ TileIndex tile = v->tile;
+ int t;
+ /* Determine the non-diagonal direction in which we will exit this tile */
+ t = v->direction >> 1;
+ if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[t]) {
+ t = (t - 1) & 3;
+ }
+ /* Calculate next tile */
+ tile += _tileoffs_by_dir[t];
+ if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
+ if (_map5[tile] & 4) {
+ _map5[tile] &= ~4;
+ MarkTileDirtyByTile(tile);
+ }
+ }
+ }
+
// count number of vehicles
u = v;
do r++; while ( (u = u->next) != NULL );