pathfind.c
branchcustombridgeheads
changeset 5590 dc34c43fc3eb
parent 5573 afa6f92a71fd
child 5623 ef2a8a524a95
--- a/pathfind.c	Thu Dec 28 16:11:07 2006 +0000
+++ b/pathfind.c	Thu Dec 28 17:21:22 2006 +0000
@@ -258,27 +258,27 @@
 	RememberData rd;
 	TileIndex tile_org = tile;
 
-	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-		if (IsTunnel(tile)) {
-			if (GetTunnelDirection(tile) != direction ||
-					GetTunnelTransportType(tile) != tpf->tracktype) {
-				return;
-			}
-			tile = SkipToEndOfTunnel(tpf, tile, direction);
-		} else {
-			TileIndex tile_end;
-			if (GetBridgeRampDirection(tile) != direction ||
-					GetBridgeTransportType(tile) != tpf->tracktype) {
-				return;
-			}
-			//fprintf(stderr, "%s: Planning over bridge\n", __func__);
-			// TODO doesn't work - WHAT doesn't work?
-			TPFSetTileBit(tpf, tile, 14);
-			tile_end = GetOtherBridgeEnd(tile);
-			tpf->rd.cur_length += DistanceManhattan(tile, tile_end);
-			tile = tile_end;
-			TPFSetTileBit(tpf, tile, 14);
+	if (IsTileType(tile, MP_TUNNEL)) {
+		if (GetTunnelDirection(tile) != direction ||
+				GetTunnelTransportType(tile) != tpf->tracktype) {
+			return;
 		}
+		tile = SkipToEndOfTunnel(tpf, tile, direction);
+	}
+
+	if (IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) {
+		TileIndex tile_end;
+		if (GetBridgeRampDirection(tile) != direction ||
+				GetBridgeTransportType(tile) != tpf->tracktype) {
+			return;
+		}
+		//fprintf(stderr, "%s: Planning over bridge\n", __func__);
+		// TODO doesn't work - WHAT doesn't work?
+		TPFSetTileBit(tpf, tile, 14);
+		tile_end = GetOtherBridgeEnd(tile);
+		tpf->rd.cur_length += DistanceManhattan(tile, tile_end);
+		tile = tile_end;
+		TPFSetTileBit(tpf, tile, 14);
 	}
 	tile += TileOffsByDiagDir(direction);
 
@@ -287,8 +287,8 @@
 		// don't enter train depot from the back
 		if (IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == direction) return;
 
-		if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNELBRIDGE))
-			if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE))
+		if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNEL) || IsTileType(tile_org, MP_RAILWAY_BRIDGE))
+			if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNEL) || IsTileType(tile, MP_RAILWAY_BRIDGE))
 				if (GetTileOwner(tile_org) != GetTileOwner(tile)) return;
 	}
 
@@ -709,42 +709,42 @@
 start_at:
 		// If the tile is the entry tile of a tunnel, and we're not going out of the tunnel,
 		//   need to find the exit of the tunnel.
-		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
-			if (IsTunnel(tile)) {
-				if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
-					FindLengthOfTunnelResult flotr;
+		if (IsTileType(tile, MP_TUNNEL)) {
+			if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
+				FindLengthOfTunnelResult flotr;
 
-					/* We are not just driving out of the tunnel */
-					if (GetTunnelDirection(tile) != direction ||
-							GetTunnelTransportType(tile) != tpf->tracktype) {
-						// We are not driving into the tunnel, or it is an invalid tunnel
-						continue;
-					}
-					if (!HASBIT(tpf->railtypes, GetRailType(tile))) {
-						bits = 0;
-						break;
-					}
-					flotr = FindLengthOfTunnel(tile, direction);
-					si.cur_length += flotr.length * DIAG_FACTOR;
-					tile = flotr.tile;
-					// tile now points to the exit tile of the tunnel
+				/* We are not just driving out of the tunnel */
+				if (GetTunnelDirection(tile) != direction ||
+						GetTunnelTransportType(tile) != tpf->tracktype) {
+					// We are not driving into the tunnel, or it is an invalid tunnel
+					continue;
 				}
-			} else {
-				TileIndex tile_end;
-				if (GetBridgeRampDirection(tile) != ReverseDiagDir(direction)) {
-					// We are not just leaving the bridge
-					if (GetBridgeRampDirection(tile) != direction ||
-							GetBridgeTransportType(tile) != tpf->tracktype) {
-						// Not entering the bridge or not compatible
-						continue;
-					}
+				if (!HASBIT(tpf->railtypes, GetRailType(tile))) {
+					bits = 0;
+					break;
 				}
-				tile_end = GetOtherBridgeEnd(tile);
-				si.cur_length += DistanceManhattan(tile, tile_end) * DIAG_FACTOR;
-				tile = tile_end;
+				flotr = FindLengthOfTunnel(tile, direction);
+				si.cur_length += flotr.length * DIAG_FACTOR;
+				tile = flotr.tile;
+				// tile now points to the exit tile of the tunnel
 			}
 		}
 
+		if (IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) {
+			TileIndex tile_end;
+			if (GetBridgeRampDirection(tile) != ReverseDiagDir(direction)) {
+				// We are not just leaving the bridge
+				if (GetBridgeRampDirection(tile) != direction ||
+						GetBridgeTransportType(tile) != tpf->tracktype) {
+					// Not entering the bridge or not compatible
+					continue;
+				}
+			}
+			tile_end = GetOtherBridgeEnd(tile);
+			si.cur_length += DistanceManhattan(tile, tile_end) * DIAG_FACTOR;
+			tile = tile_end;
+		}
+
 		// This is a special loop used to go through
 		// a rail net and find the first intersection
 		tile_org = tile;