417 } |
417 } |
418 } |
418 } |
419 |
419 |
420 if (flags & DC_EXEC && railtype != INVALID_RAILTYPE) { |
420 if (flags & DC_EXEC && railtype != INVALID_RAILTYPE) { |
421 Track track = AxisToTrack(direction); |
421 Track track = AxisToTrack(direction); |
422 UpdateSignalsOnSegment(tile_start, INVALID_DIAGDIR); |
422 UpdateSignalsOnSegment(tile_start, INVALID_DIAGDIR, _current_player); |
423 YapfNotifyTrackLayoutChange(tile_start, track); |
423 YapfNotifyTrackLayoutChange(tile_start, track); |
424 } |
424 } |
425 |
425 |
426 /* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST) |
426 /* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST) |
427 * It's unnecessary to execute this command every time for every bridge. So it is done only |
427 * It's unnecessary to execute this command every time for every bridge. So it is done only |
547 |
547 |
548 if (flags & DC_EXEC) { |
548 if (flags & DC_EXEC) { |
549 if (GB(p1, 9, 1) == TRANSPORT_RAIL) { |
549 if (GB(p1, 9, 1) == TRANSPORT_RAIL) { |
550 MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
550 MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
551 MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
551 MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
552 UpdateSignalsOnSegment(start_tile, INVALID_DIAGDIR); |
552 UpdateSignalsOnSegment(start_tile, INVALID_DIAGDIR, _current_player); |
553 YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction))); |
553 YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction))); |
554 } else { |
554 } else { |
555 MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3)); |
555 MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3)); |
556 MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3)); |
556 MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3)); |
557 } |
557 } |
601 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
601 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
602 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
602 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
603 } |
603 } |
604 |
604 |
605 if (flags & DC_EXEC) { |
605 if (flags & DC_EXEC) { |
606 /* We first need to request the direction before calling DoClearSquare |
606 if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) { |
607 * else the direction is always 0.. dah!! ;) */ |
607 /* We first need to request values before calling DoClearSquare */ |
608 DiagDirection dir = GetTunnelBridgeDirection(tile); |
608 DiagDirection dir = GetTunnelBridgeDirection(tile); |
609 bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL; |
609 Owner owner = GetTileOwner(tile); |
610 |
610 |
611 DoClearSquare(tile); |
611 DoClearSquare(tile); |
612 DoClearSquare(endtile); |
612 DoClearSquare(endtile); |
613 |
613 |
614 if (rail) { |
614 /* cannot use INVALID_DIAGDIR for signal update because the tunnel doesn't exist anymore */ |
615 UpdateSignalsOnSegment(tile, ReverseDiagDir(dir)); |
615 UpdateSignalsOnSegment(tile, ReverseDiagDir(dir), owner); |
616 UpdateSignalsOnSegment(endtile, dir); |
616 UpdateSignalsOnSegment(endtile, dir, owner); |
617 |
617 |
618 Track track = AxisToTrack(DiagDirToAxis(dir)); |
618 Track track = AxisToTrack(DiagDirToAxis(dir)); |
619 YapfNotifyTrackLayoutChange(tile, track); |
619 YapfNotifyTrackLayoutChange(tile, track); |
620 YapfNotifyTrackLayoutChange(endtile, track); |
620 YapfNotifyTrackLayoutChange(endtile, track); |
|
621 } else { |
|
622 DoClearSquare(tile); |
|
623 DoClearSquare(endtile); |
621 } |
624 } |
622 } |
625 } |
623 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
626 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
624 } |
627 } |
625 |
628 |
658 } |
661 } |
659 |
662 |
660 if (flags & DC_EXEC) { |
663 if (flags & DC_EXEC) { |
661 /* read this value before actual removal of bridge */ |
664 /* read this value before actual removal of bridge */ |
662 bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL; |
665 bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL; |
|
666 Owner owner = GetTileOwner(tile); |
663 |
667 |
664 DoClearSquare(tile); |
668 DoClearSquare(tile); |
665 DoClearSquare(endtile); |
669 DoClearSquare(endtile); |
666 for (TileIndex c = tile + delta; c != endtile; c += delta) { |
670 for (TileIndex c = tile + delta; c != endtile; c += delta) { |
667 ClearBridgeMiddle(c); |
671 ClearBridgeMiddle(c); |
668 MarkTileDirtyByTile(c); |
672 MarkTileDirtyByTile(c); |
669 } |
673 } |
670 |
674 |
671 if (rail) { |
675 if (rail) { |
672 UpdateSignalsOnSegment(tile, ReverseDiagDir(direction)); |
676 /* cannot use INVALID_DIAGDIR for signal update because the bridge doesn't exist anymore */ |
673 UpdateSignalsOnSegment(endtile, direction); |
677 UpdateSignalsOnSegment(tile, ReverseDiagDir(direction), owner); |
|
678 UpdateSignalsOnSegment(endtile, direction, owner); |
674 |
679 |
675 Track track = AxisToTrack(DiagDirToAxis(direction)); |
680 Track track = AxisToTrack(DiagDirToAxis(direction)); |
676 YapfNotifyTrackLayoutChange(tile, track); |
681 YapfNotifyTrackLayoutChange(tile, track); |
677 YapfNotifyTrackLayoutChange(endtile, track); |
682 YapfNotifyTrackLayoutChange(endtile, track); |
678 } |
683 } |