--- 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);