477 } |
477 } |
478 break; |
478 break; |
479 |
479 |
480 case MP_TUNNELBRIDGE: |
480 case MP_TUNNELBRIDGE: |
481 if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) || |
481 if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) || |
482 (IsBridge(tile) && ( |
482 (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL)) { |
483 ( |
|
484 IsBridgeRamp(tile) && |
|
485 GetBridgeTransportType(tile) == TRANSPORT_RAIL |
|
486 ) || ( |
|
487 IsBridgeMiddle(tile) && |
|
488 IsTransportUnderBridge(tile) && |
|
489 GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL && |
|
490 GetBridgeAxis(tile) != DiagDirToAxis(enterdir) |
|
491 ) |
|
492 ))) { |
|
493 return IsTileOwner(tile, owner); |
483 return IsTileOwner(tile, owner); |
494 } |
484 } |
495 break; |
485 break; |
496 |
486 |
497 default: |
487 default: |
514 DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir); |
504 DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir); |
515 TileIndex dst_tile = INVALID_TILE; |
505 TileIndex dst_tile = INVALID_TILE; |
516 int i; |
506 int i; |
517 TrackdirBits trackdirbits, ts; |
507 TrackdirBits trackdirbits, ts; |
518 TransportType type = aystar->user_data[NPF_TYPE]; |
508 TransportType type = aystar->user_data[NPF_TYPE]; |
|
509 bool override_dst_check = false; |
519 /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ |
510 /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ |
520 aystar->num_neighbours = 0; |
511 aystar->num_neighbours = 0; |
521 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
512 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
522 |
513 |
523 /* Find dest tile */ |
514 /* Find dest tile */ |
524 if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) { |
515 if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) { |
525 /* This is a tunnel. We know this tunnel is our type, |
516 /* This is a tunnel. We know this tunnel is our type, |
526 * otherwise we wouldn't have got here. It is also facing us, |
517 * otherwise we wouldn't have got here. It is also facing us, |
527 * so we should skip it's body */ |
518 * so we should skip it's body */ |
528 dst_tile = GetOtherTunnelEnd(src_tile); |
519 dst_tile = GetOtherTunnelEnd(src_tile); |
|
520 override_dst_check = true; |
|
521 } else if (IsBridgeTile(src_tile) && GetBridgeRampDirection(src_tile) == src_exitdir) { |
|
522 dst_tile = GetOtherBridgeEnd(src_tile); |
|
523 override_dst_check = true; |
529 } else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) { |
524 } else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) { |
530 /* This is a road station or a train or road depot. We can enter and exit |
525 /* This is a road station or a train or road depot. We can enter and exit |
531 * those from one side only. Trackdirs don't support that (yet), so we'll |
526 * those from one side only. Trackdirs don't support that (yet), so we'll |
532 * do this here. */ |
527 * do this here. */ |
533 |
528 |
571 } |
566 } |
572 |
567 |
573 /* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note |
568 /* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note |
574 * that I can enter the tunnel from a tile below the tunnel entrance. This |
569 * that I can enter the tunnel from a tile below the tunnel entrance. This |
575 * solves the problem of vehicles wanting to drive off a tunnel entrance */ |
570 * solves the problem of vehicles wanting to drive off a tunnel entrance */ |
576 if (IsTunnelTile(dst_tile) && GetTileZ(dst_tile) < GetTileZ(src_tile)) { |
571 if (!override_dst_check) { |
577 return; |
572 if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) { |
|
573 if (IsTunnel(dst_tile)) { |
|
574 if (GetTunnelDirection(dst_tile) != src_exitdir) return; |
|
575 } else { |
|
576 if (GetBridgeRampDirection(dst_tile) != src_exitdir) return; |
|
577 } |
|
578 } |
578 } |
579 } |
579 |
580 |
580 /* check correct rail type (mono, maglev, etc) */ |
581 /* check correct rail type (mono, maglev, etc) */ |
581 if (type == TRANSPORT_RAIL) { |
582 if (type == TRANSPORT_RAIL) { |
582 RailType dst_type = GetTileRailType(dst_tile, src_trackdir); |
583 RailType dst_type = GetTileRailType(dst_tile, src_trackdir); |