(svn r7744) [cbh] - Fix: signal update didn't work when new tunnel built (peter1138) custombridgeheads
authorKUDr
Tue, 02 Jan 2007 11:41:17 +0000
branchcustombridgeheads
changeset 5635 58d96074685e
parent 5634 3a01b04b9a8e
child 5636 2f3e7fb56cae
(svn r7744) [cbh] - Fix: signal update didn't work when new tunnel built (peter1138)
pathfind.c
--- a/pathfind.c	Tue Jan 02 10:12:36 2007 +0000
+++ b/pathfind.c	Tue Jan 02 11:41:17 2007 +0000
@@ -258,16 +258,15 @@
 	RememberData rd;
 	TileIndex tile_org = tile;
 	bool is_bridge = false;
+	bool is_tunnel = false;
 
-	if (IsTileType(tile, MP_TUNNEL)) {
-		if (GetTunnelDirection(tile) != direction ||
-				GetTunnelTransportType(tile) != tpf->tracktype) {
+	if (IsTileType(tile, MP_TUNNEL) && GetTunnelDirection(tile) == direction) {
+		if (GetTunnelTransportType(tile) != tpf->tracktype) {
 			return;
 		}
 		tile = SkipToEndOfTunnel(tpf, tile, direction);
-	}
-
-	if ((IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) && GetBridgeRampDirection(tile) == direction) {
+		is_tunnel = true;
+	} else if ((IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) && GetBridgeRampDirection(tile) == direction) {
 		TileIndex tile_end;
 		if (GetBridgeTransportType(tile) != tpf->tracktype) {
 			return;
@@ -306,7 +305,7 @@
 	/* Check if the new tile is a tunnel or bridge head and that the direction
 	 * and transport type match */
 	if (IsTunnelTile(tile)) {
-		if (GetTunnelDirection(tile) != direction ||
+		if ((!is_tunnel && GetTunnelDirection(tile) != direction) ||
 				GetTunnelTransportType(tile) != tpf->tracktype) {
 			return;
 		}