478 } |
478 } |
479 break; |
479 break; |
480 |
480 |
481 case MP_TUNNELBRIDGE: |
481 case MP_TUNNELBRIDGE: |
482 if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) || |
482 if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) || |
483 (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL)) { |
483 (IsBridge(tile) && ( |
|
484 ( |
|
485 IsBridgeRamp(tile) && |
|
486 GetBridgeTransportType(tile) == TRANSPORT_RAIL |
|
487 ) || ( |
|
488 IsBridgeMiddle(tile) && |
|
489 IsTransportUnderBridge(tile) && |
|
490 GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL && |
|
491 GetBridgeAxis(tile) != DiagDirToAxis(enterdir) |
|
492 ) |
|
493 ))) { |
484 return IsTileOwner(tile, owner); |
494 return IsTileOwner(tile, owner); |
485 } |
495 } |
486 break; |
496 break; |
487 |
497 |
488 default: |
498 default: |
522 DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir); |
532 DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir); |
523 TileIndex dst_tile = INVALID_TILE; |
533 TileIndex dst_tile = INVALID_TILE; |
524 int i; |
534 int i; |
525 TrackdirBits trackdirbits, ts; |
535 TrackdirBits trackdirbits, ts; |
526 TransportType type = aystar->user_data[NPF_TYPE]; |
536 TransportType type = aystar->user_data[NPF_TYPE]; |
527 bool override_dst_check = false; |
|
528 /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ |
537 /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ |
529 aystar->num_neighbours = 0; |
538 aystar->num_neighbours = 0; |
530 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
539 DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); |
531 |
540 |
532 /* Find dest tile */ |
541 /* Find dest tile */ |
533 if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) { |
542 if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) { |
534 /* This is a tunnel. We know this tunnel is our type, |
543 /* This is a tunnel. We know this tunnel is our type, |
535 * otherwise we wouldn't have got here. It is also facing us, |
544 * otherwise we wouldn't have got here. It is also facing us, |
536 * so we should skip it's body */ |
545 * so we should skip it's body */ |
537 dst_tile = GetOtherTunnelEnd(src_tile); |
546 dst_tile = GetOtherTunnelEnd(src_tile); |
538 override_dst_check = true; |
|
539 } else if (IsBridgeTile(src_tile) && GetBridgeRampDirection(src_tile) == src_exitdir) { |
|
540 dst_tile = GetOtherBridgeEnd(src_tile); |
|
541 override_dst_check = true; |
|
542 } else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) { |
547 } else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) { |
543 /* This is a road station or a train or road depot. We can enter and exit |
548 /* This is a road station or a train or road depot. We can enter and exit |
544 * those from one side only. Trackdirs don't support that (yet), so we'll |
549 * those from one side only. Trackdirs don't support that (yet), so we'll |
545 * do this here. */ |
550 * do this here. */ |
546 |
551 |
584 } |
589 } |
585 |
590 |
586 /* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note |
591 /* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note |
587 * that I can enter the tunnel from a tile below the tunnel entrance. This |
592 * that I can enter the tunnel from a tile below the tunnel entrance. This |
588 * solves the problem of vehicles wanting to drive off a tunnel entrance */ |
593 * solves the problem of vehicles wanting to drive off a tunnel entrance */ |
589 if (!override_dst_check) { |
594 if (IsTunnelTile(dst_tile) && GetTileZ(dst_tile) < GetTileZ(src_tile)) { |
590 if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) { |
595 return; |
591 if (IsTunnel(dst_tile)) { |
|
592 if (GetTunnelDirection(dst_tile) != src_exitdir) return; |
|
593 } else { |
|
594 if (GetBridgeRampDirection(dst_tile) != src_exitdir) return; |
|
595 } |
|
596 } |
|
597 } |
596 } |
598 |
597 |
599 /* check correct rail type (mono, maglev, etc) */ |
598 /* check correct rail type (mono, maglev, etc) */ |
600 if (type == TRANSPORT_RAIL) { |
599 if (type == TRANSPORT_RAIL) { |
601 RailType dst_type = GetTileRailType(dst_tile, src_trackdir); |
600 RailType dst_type = GetTileRailType(dst_tile, src_trackdir); |