mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-17 02:12:13 +01:00
Fix 42fbcec76f: Fixed accidental changes to autorail/road AI behavior (#13968)
* Revert4bd72e4a78, Fix #11528: Starting autorail dragging from existing track tiles resulted in adding non-continuous tracks. * Fix4bd72e4a78: Fixed accidental changes to autorail/road AI behavior
This commit is contained in:
@@ -888,11 +888,11 @@ static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, Tile
|
||||
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);
|
||||
if (!remove && ret.Failed() && ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) ret = CommandCost(); // Treat "already built" as success
|
||||
if (!remove && !fail_on_obstacle && last_error.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success = true;
|
||||
|
||||
if (ret.Failed()) {
|
||||
last_error = std::move(ret);
|
||||
if (!remove) {
|
||||
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user