(svn r7737) [cbh] - Fix: signal updates are now propagated through cbh custombridgeheads
authorKUDr
Tue, 02 Jan 2007 02:06:48 +0000
branchcustombridgeheads
changeset 5631 932c1a268feb
parent 5630 abc40525bd50
child 5632 025c3b25f1fd
(svn r7737) [cbh] - Fix: signal updates are now propagated through cbh
pathfind.c
--- a/pathfind.c	Mon Jan 01 23:43:24 2007 +0000
+++ b/pathfind.c	Tue Jan 02 02:06:48 2007 +0000
@@ -257,6 +257,7 @@
 	int i;
 	RememberData rd;
 	TileIndex tile_org = tile;
+	bool is_bridge = false;
 
 	if (IsTileType(tile, MP_TUNNEL)) {
 		if (GetTunnelDirection(tile) != direction ||
@@ -266,10 +267,9 @@
 		tile = SkipToEndOfTunnel(tpf, tile, direction);
 	}
 
-	if (IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) {
+	if ((IsTileType(tile, MP_STREET_BRIDGE) || IsTileType(tile, MP_RAILWAY_BRIDGE)) && GetBridgeRampDirection(tile) == direction) {
 		TileIndex tile_end;
-		if (GetBridgeRampDirection(tile) != direction ||
-				GetBridgeTransportType(tile) != tpf->tracktype) {
+		if (GetBridgeTransportType(tile) != tpf->tracktype) {
 			return;
 		}
 		//fprintf(stderr, "%s: Planning over bridge\n", __func__);
@@ -279,8 +279,10 @@
 		tpf->rd.cur_length += DistanceManhattan(tile, tile_end);
 		tile = tile_end;
 		TPFSetTileBit(tpf, tile, 14);
+		is_bridge = true;
+	} else {
+		tile += TileOffsByDiagDir(direction);
 	}
-	tile += TileOffsByDiagDir(direction);
 
 	/* Check in case of rail if the owner is the same */
 	if (tpf->tracktype == TRANSPORT_RAIL) {
@@ -311,7 +313,7 @@
 	}
 
 	if (IsBridgeTile(tile)) {
-		if (GetBridgeRampDirection(tile) != direction ||
+		if ((!is_bridge && GetBridgeRampDirection(tile) == ReverseDiagDir(direction)) ||
 				GetBridgeTransportType(tile) != tpf->tracktype) {
 			return;
 		}
@@ -358,7 +360,8 @@
 		return;
 
 	direction = ReverseDiagDir(direction);
-	tile += TileOffsByDiagDir(direction);
+	//tile += TileOffsByDiagDir(direction);
+	tile = tile_org;
 
 	bits = GetTileTrackStatus(tile, tpf->tracktype);
 	bits |= (bits >> 8);