Fix #11528: Don't auto-build past tunnelbridge ends (#11606)

pull/661/head
Charles Pigott 4 months ago committed by GitHub
parent 8d62a8f0f0
commit 59f6c199bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -886,9 +886,18 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI
if (ret.Failed()) return ret;
bool had_success = false;
bool under_tunnelbridge = false;
CommandCost last_error = CMD_ERROR;
for (;;) {
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);
/* Don't try to place rail between tunnelbridge ends */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
under_tunnelbridge = !under_tunnelbridge;
} else if (!under_tunnelbridge) {
if (remove) {
ret = Command<CMD_REMOVE_SINGLE_RAIL>::Do(flags, tile, TrackdirToTrack(trackdir));
} else {
ret = Command<CMD_BUILD_SINGLE_RAIL>::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals);
}
if (ret.Failed()) {
last_error = ret;
@ -903,6 +912,7 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI
had_success = true;
total_cost.AddCost(ret);
}
}
if (tile == end_tile) break;

@ -1007,9 +1007,14 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
bool had_bridge = false;
bool had_tunnel = false;
bool had_success = false;
bool under_tunnelbridge = false;
/* Start tile is the first tile clicked by the user. */
for (;;) {
/* Don't try to place road between tunnelbridge ends */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
under_tunnelbridge = !under_tunnelbridge;
} else if (!under_tunnelbridge) {
RoadBits bits = AxisToRoadBits(axis);
/* Determine which road parts should be built. */
@ -1052,6 +1057,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
cost.AddCost(ret);
}
}
}
if (tile == end_tile) break;

Loading…
Cancel
Save