(svn r2539) * Fix: Mixed up use of trackdirs and directions in GetTileRailType() causes NPF to not consider routes under bridges.
authormatthijs
Sat, 09 Jul 2005 13:45:21 +0000
changeset 2030 e8dc7fb0f728
parent 2029 4a678baaaae5
child 2031 6aa7f668a1b5
(svn r2539) * Fix: Mixed up use of trackdirs and directions in GetTileRailType() causes NPF to not consider routes under bridges.
rail.c
--- a/rail.c	Sat Jul 09 11:39:35 2005 +0000
+++ b/rail.c	Sat Jul 09 13:45:21 2005 +0000
@@ -109,6 +109,7 @@
 RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
 {
 	RailType type = INVALID_RAILTYPE;
+	DiagDirection exitdir = TrackdirToExitdir(trackdir);
 	switch (GetTileType(tile)) {
 		case MP_RAILWAY:
 			/* railway track */
@@ -129,10 +130,10 @@
 			/* railway bridge ending */
 			if ((_map5[tile] & 0xC6) == 0x80) type = _map3_lo[tile] & RAILTYPE_MASK;
 			/* on railway bridge */
-			if ((_map5[tile] & 0xC6) == 0xC0 && ((DiagDirection)(_map5[tile] & 0x1)) == (TrackdirToExitdir(trackdir) & 0x1))
+			if ((_map5[tile] & 0xC6) == 0xC0 && ((DiagDirection)(_map5[tile] & 0x1)) == (exitdir & 0x1))
 				type = (_map3_lo[tile] >> 4) & RAILTYPE_MASK;
 			/* under bridge (any type) */
-			if ((_map5[tile] & 0xC0) == 0xC0 && ((uint)_map5[tile] & 0x1) != (trackdir & 0x1))
+			if ((_map5[tile] & 0xC0) == 0xC0 && ((uint)_map5[tile] & 0x1) != (exitdir & 0x1))
 				type = _map3_lo[tile] & RAILTYPE_MASK;
 			break;
 		default: