npf.c
changeset 3184 7405329343ce
parent 3179 774b1e6553a7
child 3234 986c30171e92
--- a/npf.c	Sun Mar 12 12:19:25 2006 +0000
+++ b/npf.c	Sun Mar 12 15:04:03 2006 +0000
@@ -260,11 +260,11 @@
 	/* Determine base length */
 	switch (GetTileType(tile)) {
 		case MP_TUNNELBRIDGE:
-			if (GB(_m[tile].m5, 4, 4) == 0) {
+			if (IsTunnel(tile)) {
 				cost = NPFTunnelCost(current);
-				break;
+			} else {
+				cost = NPF_TILE_LENGTH;
 			}
-			cost = NPF_TILE_LENGTH;
 			break;
 
 		case MP_STREET:
@@ -306,7 +306,7 @@
 	/* Determine base length */
 	switch (GetTileType(tile)) {
 		case MP_TUNNELBRIDGE:
-			if (GB(_m[tile].m5, 4, 4) == 0) {
+			if (IsTunnel(tile)) {
 				cost = NPFTunnelCost(current);
 				break;
 			}
@@ -483,7 +483,7 @@
 			}
 			/* if we were on a railway middle part, we are now at a railway bridge ending */
 #endif
-			if ((_m[tile].m5 & 0xFC) == 0 || /* railway tunnel */
+			if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) ||
 					(_m[tile].m5 & 0xC6) == 0x80 || /* railway bridge ending */
 					((_m[tile].m5 & 0xF8) == 0xE0 && GB(_m[tile].m5, 0, 1) != (enterdir & 0x1))) { /* railway under bridge */
 				return IsTileOwner(tile, owner);
@@ -517,9 +517,7 @@
 	DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
 
 	/* Find dest tile */
-	if (IsTileType(src_tile, MP_TUNNELBRIDGE) &&
-			GB(_m[src_tile].m5, 4, 4) == 0 &&
-			GetTunnelDirection(src_tile) == src_exitdir) {
+	if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) {
 		/* This is a tunnel. We know this tunnel is our type,
 		 * otherwise we wouldn't have got here. It is also facing us,
 		 * so we should skip it's body */
@@ -565,8 +563,7 @@
 	/* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note
 	 * that I can enter the tunnel from a tile below the tunnel entrance. This
 	 * solves the problem of vehicles wanting to drive off a tunnel entrance */
-	if (IsTileType(dst_tile, MP_TUNNELBRIDGE) && GB(_m[dst_tile].m5, 4, 4) == 0 &&
-			GetTileZ(dst_tile) < GetTileZ(src_tile)) {
+	if (IsTunnelTile(dst_tile) && GetTileZ(dst_tile) < GetTileZ(src_tile)) {
 		return;
 	}