1
0
Fork 0
pull/13861/merge
John Taylor 2025-04-04 10:54:13 +00:00 committed by GitHub
commit 94c8ea1a30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 12 deletions

View File

@ -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;