summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-10-31 22:13:41 +0000
committerrubidium <rubidium@openttd.org>2007-10-31 22:13:41 +0000
commit3a7c8cc88d0fb4b3135979a45effc1bf7ac51fad (patch)
treeb18e036b699038571c075e05de4f0c3232a9a96e
parentf486486dd81f2791942678c11f4e2926c2309ae2 (diff)
downloadopenttd-3a7c8cc88d0fb4b3135979a45effc1bf7ac51fad.tar.xz
(svn r11366) -Fix [FS#1258]: road vehicles must not drive through eachother on bridges/in tunnels.
-rw-r--r--src/roadveh_cmd.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index edb2c222a..542cd3f73 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -884,25 +884,30 @@ static Vehicle* RoadVehFindCloseTo(Vehicle* v, int x, int y, Direction dir)
{
RoadVehFindData rvf;
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.y = y;
rvf.dir = dir;
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
* If more than 1480 / 74 days a road vehicle is blocked, it will
* drive just through it. The ultimate backup-code of TTD.
* It can be disabled. */
if (u == NULL) {
- v->u.road.blocked_ctr = 0;
+ front->u.road.blocked_ctr = 0;
return NULL;
}
- if (++v->u.road.blocked_ctr > 1480) return NULL;
+ if (++front->u.road.blocked_ctr > 1480) return NULL;
return u;
}