160 * including the exit tile. Requires that this is a Tunnel tile */ |
161 * including the exit tile. Requires that this is a Tunnel tile */ |
161 static uint NPFTunnelCost(AyStarNode* current) |
162 static uint NPFTunnelCost(AyStarNode* current) |
162 { |
163 { |
163 DiagDirection exitdir = TrackdirToExitdir((Trackdir)current->direction); |
164 DiagDirection exitdir = TrackdirToExitdir((Trackdir)current->direction); |
164 TileIndex tile = current->tile; |
165 TileIndex tile = current->tile; |
165 if ((DiagDirection)GB(_m[tile].m5, 0, 2) == ReverseDiagDir(exitdir)) { |
166 if (GetTunnelDirection(tile) == ReverseDiagDir(exitdir)) { |
166 /* We just popped out if this tunnel, since were |
167 /* We just popped out if this tunnel, since were |
167 * facing the tunnel exit */ |
168 * facing the tunnel exit */ |
168 FindLengthOfTunnelResult flotr; |
169 FindLengthOfTunnelResult flotr; |
169 flotr = FindLengthOfTunnel(tile, ReverseDiagDir(exitdir)); |
170 flotr = FindLengthOfTunnel(tile, ReverseDiagDir(exitdir)); |
170 return flotr.length * NPF_TILE_LENGTH; |
171 return flotr.length * NPF_TILE_LENGTH; |
517 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
518 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
518 |
519 |
519 /* Find dest tile */ |
520 /* Find dest tile */ |
520 if (IsTileType(src_tile, MP_TUNNELBRIDGE) && |
521 if (IsTileType(src_tile, MP_TUNNELBRIDGE) && |
521 GB(_m[src_tile].m5, 4, 4) == 0 && |
522 GB(_m[src_tile].m5, 4, 4) == 0 && |
522 (DiagDirection)GB(_m[src_tile].m5, 0, 2) == src_exitdir) { |
523 GetTunnelDirection(src_tile) == src_exitdir) { |
523 /* This is a tunnel. We know this tunnel is our type, |
524 /* This is a tunnel. We know this tunnel is our type, |
524 * otherwise we wouldn't have got here. It is also facing us, |
525 * otherwise we wouldn't have got here. It is also facing us, |
525 * so we should skip it's body */ |
526 * so we should skip it's body */ |
526 flotr = FindLengthOfTunnel(src_tile, src_exitdir); |
527 flotr = FindLengthOfTunnel(src_tile, src_exitdir); |
527 dst_tile = flotr.tile; |
528 dst_tile = flotr.tile; |