mirror of https://github.com/OpenTTD/OpenTTD
Merge 235c6e2c55
into f35fa6679b
commit
94c8ea1a30
|
@ -885,8 +885,21 @@ static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, Tile
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
bool had_success = false;
|
||||
bool first_tile = true;
|
||||
TileIndex wormhole_end = INVALID_TILE;
|
||||
CommandCost last_error = CMD_ERROR;
|
||||
for (;;) {
|
||||
/* Check if hopping bridge/tunnel (#11528). */
|
||||
if (wormhole_end == INVALID_TILE && IsDiagonalTrackdir(trackdir) && GetTileType(tile) == MP_TUNNELBRIDGE && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
||||
/* If the building direction is the same as the bridge/tunnel direction, skip building tracks until the bridge/tunnel ends. */
|
||||
if (GetTunnelBridgeDirection(tile) == TrackdirToExitdir(trackdir)) {
|
||||
wormhole_end = GetOtherTunnelBridgeEnd(tile);
|
||||
} else if (!first_tile && GetTunnelBridgeDirection(tile) == TrackdirToExitdir(ReverseTrackdir(trackdir))) {
|
||||
break; // Upon running into a bridge ramp from the underside, we should stop building tracks.
|
||||
}
|
||||
}
|
||||
|
||||
if (wormhole_end == INVALID_TILE) {
|
||||
ret = remove ? Command<CMD_REMOVE_SINGLE_RAIL>::Do(flags, tile, TrackdirToTrack(trackdir)) : Command<CMD_BUILD_SINGLE_RAIL>::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals);
|
||||
|
||||
if (ret.Failed()) {
|
||||
|
@ -902,13 +915,21 @@ static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, Tile
|
|||
had_success = true;
|
||||
total_cost.AddCost(ret.GetCost());
|
||||
}
|
||||
}
|
||||
|
||||
if (tile == end_tile) break;
|
||||
|
||||
/* Reset skip flag for the next tile after tunnel/bridge ending. */
|
||||
if (wormhole_end == tile) {
|
||||
wormhole_end = INVALID_TILE;
|
||||
}
|
||||
|
||||
tile += ToTileIndexDiff(_trackdelta[trackdir]);
|
||||
|
||||
/* toggle railbit for the non-diagonal tracks */
|
||||
if (!IsDiagonalTrackdir(trackdir)) ToggleBit(trackdir, 0);
|
||||
|
||||
first_tile = false;
|
||||
}
|
||||
|
||||
if (had_success) return total_cost;
|
||||
|
|
Loading…
Reference in New Issue