summaryrefslogtreecommitdiff
path: root/src/pathfind.cpp
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2007-06-26 20:15:33 +0000
committermatthijs <matthijs@openttd.org>2007-06-26 20:15:33 +0000
commit25f7e8c8a0bcf8face0838252dd97330c895047b (patch)
treeb6cfcef92135e365ce9a55a18ba4f4b7523538e5 /src/pathfind.cpp
parentf8a5b61f4e4a6304653db240be40c399c1ae46a6 (diff)
downloadopenttd-25f7e8c8a0bcf8face0838252dd97330c895047b.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/pathfind.cpp')
-rw-r--r--src/pathfind.cpp14
1 files changed, 11 insertions, 3 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 ||