summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-03-31 09:27:25 +0100
committerGitHub <noreply@github.com>2021-03-31 09:27:25 +0100
commit086c95718dcc69ae0a0f04c4c57f7a091c2099a0 (patch)
treea6f8ac90fb5857fc7af8139f105685c12a25ce86 /src/rail_cmd.cpp
parent50cd6e135eca53653aaa3fc86cebc2a749e76529 (diff)
downloadopenttd-086c95718dcc69ae0a0f04c4c57f7a091c2099a0.tar.xz
Fix #8803: Only auto-remove signals when rail can be built (#8904)
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 133f59643..a5e985c02 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -459,6 +459,10 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track);
if (ret.Failed()) return ret;
+ ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
+ if (ret.Failed()) return ret;
+ cost.AddCost(ret);
+
if (HasSignals(tile) && TracksOverlap(GetTrackBits(tile) | TrackToTrackBits(track))) {
/* If adding the new track causes any overlap, all signals must be removed first */
if (!auto_remove_signals) return_cmd_error(STR_ERROR_MUST_REMOVE_SIGNALS_FIRST);
@@ -472,10 +476,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
}
}
- ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
- if (ret.Failed()) return ret;
- cost.AddCost(ret);
-
/* If the rail types don't match, try to convert only if engines of
* the new rail type are not powered on the present rail type and engines of
* the present rail type are powered on the new rail type. */