summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-02-02 22:27:03 +0000
committerterkhen <terkhen@openttd.org>2010-02-02 22:27:03 +0000
commit2798fdf082a5372d3e6a60556af24871618287c7 (patch)
treee1c6121f57b445719a26175e64c5b4f1a507bc22 /src/rail_cmd.cpp
parentb02a522038446757ba7de6fc81f9c9a6d03e3545 (diff)
downloadopenttd-2798fdf082a5372d3e6a60556af24871618287c7.tar.xz
(svn r18987) -Fix: [NoAI] Make building long rails fail for AIs if there is an obstacle in the way.
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 22e45c7b8..c9e2c3916 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -698,6 +698,7 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
* - p2 = (bit 7) - 0 = build, 1 = remove tracks
+ * - p2 = (bit 8) - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
* @param text unused
* @return the cost of this operation or an error
*/
@@ -721,7 +722,10 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL);
if (ret.Failed()) {
- if (_error_message != STR_ERROR_ALREADY_BUILT && !remove) break;
+ if (_error_message != STR_ERROR_ALREADY_BUILT && !remove) {
+ if (HasBit(p2, 8)) return CMD_ERROR;
+ break;
+ }
_error_message = INVALID_STRING_ID;
} else {
total_cost.AddCost(ret);