From d56a690ba432c3ef483ac7a8072266349f2bfc96 Mon Sep 17 00:00:00 2001 From: smatz Date: Sun, 16 Dec 2007 19:30:42 +0000 Subject: (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642 --- src/npf.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/npf.cpp') diff --git a/src/npf.cpp b/src/npf.cpp index 696484e03..15120dc4e 100644 --- a/src/npf.cpp +++ b/src/npf.cpp @@ -481,8 +481,7 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter break; case MP_TUNNELBRIDGE: - if ((IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) || - (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL)) { + if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) { return IsTileOwner(tile, owner); } break; @@ -534,14 +533,11 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); /* Find dest tile */ - if (IsTunnelTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) { - /* This is a tunnel. We know this tunnel is our type, + if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(src_tile) == src_exitdir) { + /* This is a tunnel/bridge. We know this tunnel/bridge is our type, * otherwise we wouldn't have got here. It is also facing us, * so we should skip it's body */ - dst_tile = GetOtherTunnelEnd(src_tile); - override_dst_check = true; - } else if (IsBridgeTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) { - dst_tile = GetOtherBridgeEnd(src_tile); + dst_tile = IsTunnel(src_tile) ? GetOtherTunnelEnd(src_tile) : GetOtherBridgeEnd(src_tile); override_dst_check = true; } else if (type != TRANSPORT_WATER && (IsStandardRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) { /* This is a road station (non drive-through) or a train or road depot. We can enter and exit @@ -590,14 +586,9 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) /* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note * 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 (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return; - } else { - if (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return; - } - } + if (!override_dst_check && IsTileType(dst_tile, MP_TUNNELBRIDGE) && + GetTunnelBridgeDirection(dst_tile) != src_exitdir) { + return; } /* check correct rail type (mono, maglev, etc) */ -- cgit v1.2.3-54-g00ecf