mirror of https://github.com/OpenTTD/OpenTTD
(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.release/0.4.5
parent
8ee37e7b47
commit
d8709b18c6
14
train_cmd.c
14
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)
|
static void ReverseTrainDirection(Vehicle *v)
|
||||||
{
|
{
|
||||||
int l = 0, r = -1;
|
int l = 0, r = -1;
|
||||||
|
@ -974,13 +983,18 @@ static void ReverseTrainDirection(Vehicle *v)
|
||||||
}
|
}
|
||||||
/* Calculate next tile */
|
/* Calculate next tile */
|
||||||
tile += _tileoffs_by_dir[t];
|
tile += _tileoffs_by_dir[t];
|
||||||
|
/* Test if we have a rail/road-crossing */
|
||||||
if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
|
if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
|
||||||
|
/* 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) {
|
if (_map5[tile] & 4) {
|
||||||
_map5[tile] &= ~4;
|
_map5[tile] &= ~4;
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// count number of vehicles
|
// count number of vehicles
|
||||||
u = v;
|
u = v;
|
||||||
|
|
Loading…
Reference in New Issue