summaryrefslogtreecommitdiff
path: root/src/road_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-01-31 20:28:36 +0000
committerfrosch <frosch@openttd.org>2010-01-31 20:28:36 +0000
commitcbbe311cea7d7f9ec1d2c28691ef1ae9fc9b3047 (patch)
treec1ac9736e19c9cb675fa6ea82bd3e0d9671cd629 /src/road_cmd.cpp
parent8e6096931abb8f5047d7cbec8138baecf947a058 (diff)
downloadopenttd-cbbe311cea7d7f9ec1d2c28691ef1ae9fc9b3047.tar.xz
(svn r18974) -Fix [FS#3578]: CMD_BUILD_ROAD missed CMD_AUTO. Also do not access tiles anymore after clearing them; that fails either in test or exec run.
Diffstat (limited to 'src/road_cmd.cpp')
-rw-r--r--src/road_cmd.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 5e66c6db3..653f54ab4 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -483,6 +483,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Slope tileh = GetTileSlope(tile, NULL);
+ bool tile_cleared = false; // Used to remember that the tile was cleared during test run
switch (GetTileType(tile)) {
case MP_ROAD:
switch (GetRoadTileType(tile)) {
@@ -601,6 +602,7 @@ do_clear:;
CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
cost.AddCost(ret);
+ tile_cleared = true;
} break;
}
@@ -615,7 +617,7 @@ do_clear:;
cost.AddCost(ret);
}
- if (IsTileType(tile, MP_ROAD)) {
+ if (!tile_cleared && IsTileType(tile, MP_ROAD)) {
/* Don't put the pieces that already exist */
pieces &= ComplementRoadBits(existing);
@@ -637,10 +639,10 @@ do_clear:;
}
}
- if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+ if (!tile_cleared && !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]);
- if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+ if (!tile_cleared && IsTileType(tile, MP_TUNNELBRIDGE)) {
/* Pay for *every* tile of the bridge or tunnel */
cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2);
}