summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-21 16:17:27 +0000
committertruelight <truelight@openttd.org>2004-12-21 16:17:27 +0000
commitb4aa5e7572de091965adf7d554bcf70d84ac587c (patch)
tree668abca308dd924835107f7e3febb7017b622f4f /train_cmd.c
parent63611e19f5696a5e7ddd5923c1952e6e9d231e86 (diff)
downloadopenttd-b4aa5e7572de091965adf7d554bcf70d84ac587c.tar.xz
(svn r1200) -Fix: Fixed bug pointed out by Tron: when a train is on the
road/rail-crossing, and you let an other train drive towards it, reverse it, the lights no longer go off.
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 626398585..c33de2d8d 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -955,6 +955,15 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
}
}
+/* Check if the vehicle is a train and is on the tile we are testing */
+static void *TestTrainOnCrossing(Vehicle *v, void *data)
+{
+ if (v->tile != *(const TileIndex*)data || v->type != VEH_Train)
+ return NULL;
+
+ return v;
+}
+
static void ReverseTrainDirection(Vehicle *v)
{
int l = 0, r = -1;
@@ -974,10 +983,15 @@ static void ReverseTrainDirection(Vehicle *v)
}
/* Calculate next tile */
tile += _tileoffs_by_dir[t];
+ /* Test if we have a rail/road-crossing */
if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
- if (_map5[tile] & 4) {
- _map5[tile] &= ~4;
- MarkTileDirtyByTile(tile);
+ /* Check if there is a train on the tile itself */
+ if (VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL) {
+ /* If light is on, switch light off */
+ if (_map5[tile] & 4) {
+ _map5[tile] &= ~4;
+ MarkTileDirtyByTile(tile);
+ }
}
}
}