From 381fa3645095b7691398529bfe4bb13dc4f6b3ae Mon Sep 17 00:00:00 2001 From: Koen Bussemaker Date: Fri, 30 Jun 2023 21:17:26 +0200 Subject: [PATCH] Change: Autorail / autoroad tools can start dragging from invalid tiles --- src/rail_cmd.cpp | 6 +++--- src/road_cmd.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 7e1ec01ee3..2e35c19b20 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -875,8 +875,8 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd * @param railtype railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building * @param track track-orientation * @param remove remove tracks? - * @param auto_remove_signals false = build up to an obstacle, true = fail if an obstacle is found (used for AIs), only used for building - * @param fail_on_obstacle false = error on signal in the way, true = auto remove signals when in the way, only used for building + * @param auto_remove_signals false = error on signal in the way, true = auto remove signals when in the way, only used for building + * @param fail_on_obstacle false = build starting from and up to an obstacle, true = fail if an obstacle is found (used for AIs) * @return the cost of this operation or an error */ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle) @@ -900,7 +900,7 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI last_error = ret; if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) { if (fail_on_obstacle) return last_error; - break; + if (had_success) break; // Keep going if we haven't constructed any rail yet, skipping the start of the drag } /* Ownership errors are more important. */ diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 3802f884e3..ed3fbdc392 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1034,7 +1034,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex last_error = ret; if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) { if (is_ai) return last_error; - break; + if (had_success) break; // Keep going if we haven't constructed any road yet, skipping the start of the drag } } else { had_success = true;