diff options
author | matthijs <matthijs@openttd.org> | 2007-06-26 20:15:33 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2007-06-26 20:15:33 +0000 |
commit | a0a9a7f3cd058bc87e5511d2e02a9e8bafec3bf5 (patch) | |
tree | b6cfcef92135e365ce9a55a18ba4f4b7523538e5 /src | |
parent | a6da8c9519050c108da6d8b463ce281ca3e0d0f1 (diff) | |
download | openttd-a0a9a7f3cd058bc87e5511d2e02a9e8bafec3bf5.tar.xz |
(svn r10345) -Fix [FS#290]: Make OPF handle coming out of a tunnel as well as going into a tunnel, to support road vehicles looking back when finding a depot while in a tunnel.
-Fix [FS#290]: Make NPF look back when finding a depot for road vehicles.
Diffstat (limited to 'src')
-rw-r--r-- | src/pathfind.cpp | 14 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/pathfind.cpp b/src/pathfind.cpp index 541fccb3c..60a3ac798 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -331,11 +331,19 @@ static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection directi if (IsTileType(tile, MP_TUNNELBRIDGE)) { if (IsTunnel(tile)) { - if (GetTunnelDirection(tile) != direction || - GetTunnelTransportType(tile) != tpf->tracktype) { + if (GetTunnelTransportType(tile) != tpf->tracktype) { + return; + } + /* Only skip through the tunnel if heading inwards. We can + * be headed outwards if our starting position was in a + * tunnel and we're pathfinding backwards */ + if (GetTunnelDirection(tile) == direction) { + tile = SkipToEndOfTunnel(tpf, tile, direction); + } if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) { + /* We don't support moving through the sides of a tunnel + * entrance :-) */ return; } - tile = SkipToEndOfTunnel(tpf, tile, direction); } else { TileIndex tile_end; if (GetBridgeRampDirection(tile) != direction || diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index ce219bda6..3ca03686a 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -416,7 +416,7 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v) /* See where we are now */ Trackdir trackdir = GetVehicleTrackdir(v); - ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE); + ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, v->tile, ReverseTrackdir(trackdir), TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE, 0); if (ftd.best_bird_dist == 0) { return GetDepotByTile(ftd.node.tile); /* Target found */ } else { |