mirror of https://github.com/OpenTTD/OpenTTD
(svn r1604) Fix: [ 1105112 ] Destroyed train locks crossings
parent
720b183017
commit
322bd934be
34
train_cmd.c
34
train_cmd.c
|
@ -968,6 +968,21 @@ static void *TestTrainOnCrossing(Vehicle *v, void *data)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DisableTrainCrossing(TileIndex tile)
|
||||||
|
{
|
||||||
|
/* Test if we have a rail/road-crossing */
|
||||||
|
if (IsTileType(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) {
|
||||||
|
_map5[tile] &= ~4;
|
||||||
|
MarkTileDirtyByTile(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ReverseTrainDirection(Vehicle *v)
|
static void ReverseTrainDirection(Vehicle *v)
|
||||||
{
|
{
|
||||||
int l = 0, r = -1;
|
int l = 0, r = -1;
|
||||||
|
@ -987,17 +1002,9 @@ static void ReverseTrainDirection(Vehicle *v)
|
||||||
}
|
}
|
||||||
/* Calculate next tile */
|
/* Calculate next tile */
|
||||||
tile += TileOffsByDir(t);
|
tile += TileOffsByDir(t);
|
||||||
/* Test if we have a rail/road-crossing */
|
|
||||||
if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
|
/* Check if the train left a rail/road-crossing */
|
||||||
/* Check if there is a train on the tile itself */
|
DisableTrainCrossing(tile);
|
||||||
if (VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL) {
|
|
||||||
/* If light is on, switch light off */
|
|
||||||
if (_map5[tile] & 4) {
|
|
||||||
_map5[tile] &= ~4;
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// count number of vehicles
|
// count number of vehicles
|
||||||
|
@ -2328,6 +2335,9 @@ static void DeleteLastWagon(Vehicle *v)
|
||||||
SetSignalsOnBothDir(v->tile, FIND_FIRST_BIT(t));
|
SetSignalsOnBothDir(v->tile, FIND_FIRST_BIT(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if the wagon was on a road/rail-crossing and disable it if no others are on it */
|
||||||
|
DisableTrainCrossing(v->tile);
|
||||||
|
|
||||||
if (v->u.rail.track == 0x40) {
|
if (v->u.rail.track == 0x40) {
|
||||||
int length;
|
int length;
|
||||||
TileIndex endtile = CheckTunnelBusy(v->tile, &length);
|
TileIndex endtile = CheckTunnelBusy(v->tile, &length);
|
||||||
|
@ -2389,7 +2399,7 @@ static void HandleCrashedTrain(Vehicle *v)
|
||||||
ChangeTrainDirRandomly(v);
|
ChangeTrainDirRandomly(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state >= 4440 && !(v->tick_counter&0x1F))
|
if (state >= 4440 && !(v->tick_counter&0x1F))
|
||||||
DeleteLastWagon(v);
|
DeleteLastWagon(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue