1
0
Fork 0

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

pull/11963/head
Charles Pigott 2024-02-03 10:18:10 +00:00 committed by GitHub
parent 8d62a8f0f0
commit 59f6c199bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 65 additions and 49 deletions

View File

@ -886,9 +886,18 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
bool had_success = false; bool had_success = false;
bool under_tunnelbridge = false;
CommandCost last_error = CMD_ERROR; CommandCost last_error = CMD_ERROR;
for (;;) { 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()) { if (ret.Failed()) {
last_error = ret; last_error = ret;
@ -903,6 +912,7 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI
had_success = true; had_success = true;
total_cost.AddCost(ret); total_cost.AddCost(ret);
} }
}
if (tile == end_tile) break; if (tile == end_tile) break;

View File

@ -1007,9 +1007,14 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
bool had_bridge = false; bool had_bridge = false;
bool had_tunnel = false; bool had_tunnel = false;
bool had_success = false; bool had_success = false;
bool under_tunnelbridge = false;
/* Start tile is the first tile clicked by the user. */ /* Start tile is the first tile clicked by the user. */
for (;;) { 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); RoadBits bits = AxisToRoadBits(axis);
/* Determine which road parts should be built. */ /* Determine which road parts should be built. */
@ -1052,6 +1057,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
cost.AddCost(ret); cost.AddCost(ret);
} }
} }
}
if (tile == end_tile) break; if (tile == end_tile) break;