npf.c
branchcustombridgeheads
changeset 5590 dc34c43fc3eb
parent 5573 afa6f92a71fd
child 5642 bfa6074e2833
--- a/npf.c	Thu Dec 28 16:11:07 2006 +0000
+++ b/npf.c	Thu Dec 28 17:21:22 2006 +0000
@@ -269,8 +269,12 @@
 
 	/* Determine base length */
 	switch (GetTileType(tile)) {
-		case MP_TUNNELBRIDGE:
-			cost = IsTunnel(tile) ? NPFTunnelCost(current) : NPFBridgeCost(current);
+		case MP_TUNNEL:
+			cost = NPFTunnelCost(current);
+			break;
+
+		case MP_STREET_BRIDGE:
+			cost = NPFBridgeCost(current);
 			break;
 
 		case MP_STREET:
@@ -310,8 +314,12 @@
 
 	/* Determine base length */
 	switch (GetTileType(tile)) {
-		case MP_TUNNELBRIDGE:
-			cost = IsTunnel(tile) ? NPFTunnelCost(current) : NPFBridgeCost(current);
+		case MP_TUNNEL:
+			cost = NPFTunnelCost(current);
+			break;
+
+		case MP_RAILWAY_BRIDGE:
+			cost = NPFBridgeCost(current);
 			break;
 
 		case MP_RAILWAY:
@@ -467,13 +475,13 @@
 			}
 			break;
 
-		case MP_TUNNELBRIDGE:
-			if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) ||
-					(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL)) {
-				return IsTileOwner(tile, owner);
-			}
+		case MP_TUNNEL:
+			if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) return IsTileOwner(tile, owner);
 			break;
 
+		case MP_RAILWAY_BRIDGE:
+			return IsTileOwner(tile, owner);
+
 		default:
 			break;
 	}
@@ -576,13 +584,10 @@
 	 * 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 (!override_dst_check) {
-		if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) {
-			if (IsTunnel(dst_tile)) {
-				if (GetTunnelDirection(dst_tile) != src_exitdir) return;
-			} else {
-				if (GetBridgeRampDirection(dst_tile) != src_exitdir) return;
-			}
-		}
+		if (IsTileType(dst_tile, MP_TUNNEL) && GetTunnelDirection(dst_tile) != src_exitdir) return;
+
+		if ((IsTileType(dst_tile, MP_STREET_BRIDGE) || IsTileType(dst_tile, MP_RAILWAY_BRIDGE)) &&
+				GetBridgeRampDirection(dst_tile) != src_exitdir) return;
 	}
 
 	/* check correct rail type (mono, maglev, etc) */