mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-22 15:11:54 +00:00
(svn r11366) -Fix [FS#1258]: road vehicles must not drive through eachother on bridges/in tunnels.
This commit is contained in:
parent
f486486dd8
commit
3a7c8cc88d
@ -884,25 +884,30 @@ static Vehicle* RoadVehFindCloseTo(Vehicle* v, int x, int y, Direction dir)
|
|||||||
{
|
{
|
||||||
RoadVehFindData rvf;
|
RoadVehFindData rvf;
|
||||||
Vehicle *u;
|
Vehicle *u;
|
||||||
|
Vehicle *front = v->First();
|
||||||
|
|
||||||
if (v->u.road.reverse_ctr != 0) return NULL;
|
if (front->u.road.reverse_ctr != 0) return NULL;
|
||||||
|
|
||||||
rvf.x = x;
|
rvf.x = x;
|
||||||
rvf.y = y;
|
rvf.y = y;
|
||||||
rvf.dir = dir;
|
rvf.dir = dir;
|
||||||
rvf.veh = v;
|
rvf.veh = v;
|
||||||
u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
|
if (front->u.road.state == RVSB_WORMHOLE) {
|
||||||
|
u = (Vehicle*)VehicleFromPos(v->tile, &rvf, EnumCheckRoadVehClose);
|
||||||
|
} else {
|
||||||
|
u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
|
||||||
|
}
|
||||||
|
|
||||||
/* This code protects a roadvehicle from being blocked for ever
|
/* This code protects a roadvehicle from being blocked for ever
|
||||||
* If more than 1480 / 74 days a road vehicle is blocked, it will
|
* If more than 1480 / 74 days a road vehicle is blocked, it will
|
||||||
* drive just through it. The ultimate backup-code of TTD.
|
* drive just through it. The ultimate backup-code of TTD.
|
||||||
* It can be disabled. */
|
* It can be disabled. */
|
||||||
if (u == NULL) {
|
if (u == NULL) {
|
||||||
v->u.road.blocked_ctr = 0;
|
front->u.road.blocked_ctr = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++v->u.road.blocked_ctr > 1480) return NULL;
|
if (++front->u.road.blocked_ctr > 1480) return NULL;
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user