summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-09-03 16:03:17 +0000
committertruelight <truelight@openttd.org>2004-09-03 16:03:17 +0000
commitb5a0840621d291ed384f2abac305a850bf1eeea3 (patch)
tree7a0169f437a2fcc2f4dadef7074fc80898ff3ca8
parent3b96ad994c43581918c3a5fa060f184d2c730f71 (diff)
downloadopenttd-b5a0840621d291ed384f2abac305a850bf1eeea3.tar.xz
(svn r149) -Fix: [997703] Junction after tunnel bug (blathijs)
-rw-r--r--pathfind.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pathfind.c b/pathfind.c
index 718268a5d..5a6ed2890 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -594,11 +594,17 @@ void NTPEnum(NewTrackPathFinder *tpf, uint tile, uint direction)
restart:
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) {
- if ( (uint)(_map5[tile] & 3) != direction || ((_map5[tile]>>1)&6) != tpf->tracktype)
+ /* This is a tunnel tile */
+ if ( (uint)(_map5[tile] & 3) != (direction ^ 2)) { /* ^ 2 is reversing the direction */
+ /* We are not just driving out of the tunnel */
+ if ( (uint)(_map5[tile] & 3) != direction || ((_map5[tile]>>1)&6) != tpf->tracktype)
+ /* We are not driving into the tunnel, or it
+ * is an invalid tunnel */
goto popnext;
- flotr = FindLengthOfTunnel(tile, direction, tpf->tracktype);
- si.cur_length += flotr.length;
- tile = flotr.tile;
+ flotr = FindLengthOfTunnel(tile, direction, tpf->tracktype);
+ si.cur_length += flotr.length;
+ tile = flotr.tile;
+ }
}
// remember the start tile so we know if we're in an inf loop.