1
0
Fork 0

Revert 4bd72e4a78, Fix #11528: Starting autorail dragging from existing track tiles resulted in adding non-continuous tracks.

pull/13968/head
Koen Bussemaker 2025-04-05 09:01:36 +02:00
parent 5e1dc081ee
commit 32e317bed7
2 changed files with 5 additions and 6 deletions

View File

@ -888,11 +888,10 @@ static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, Tile
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); 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 (!remove && ret.Failed() && ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) ret = CommandCost(); // Treat "already built" as success
if (ret.Failed()) { if (ret.Failed()) {
last_error = std::move(ret); last_error = std::move(ret);
if (!remove) { if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
if (fail_on_obstacle) return last_error; if (fail_on_obstacle) return last_error;
if (had_success) break; // Keep going if we haven't constructed any rail yet, skipping the start of the drag if (had_success) break; // Keep going if we haven't constructed any rail yet, skipping the start of the drag
} }

View File

@ -1020,12 +1020,12 @@ CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex
} }
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, TownID::Invalid()); CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, TownID::Invalid());
if (ret.Failed() && ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) ret = CommandCost(); // Treat "already built" as success
if (ret.Failed()) { if (ret.Failed()) {
last_error = std::move(ret); last_error = std::move(ret);
if (is_ai) return last_error; if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
if (had_success) break; // Keep going if we haven't constructed any road yet, skipping the start of the drag if (is_ai) return last_error;
if (had_success) break; // Keep going if we haven't constructed any road yet, skipping the start of the drag
}
} else { } else {
had_success = true; had_success = true;
/* Only pay for the upgrade on one side of the bridges and tunnels */ /* Only pay for the upgrade on one side of the bridges and tunnels */