diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2018-08-14 21:05:47 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2018-08-14 22:05:47 +0200 |
commit | df92a056dffd9fa2a765246da10442717f459c7f (patch) | |
tree | 96f4c19fad1278b0fe496cf88cedb3eaf63e9aa4 /src | |
parent | d839526365e66b0846366807e2e697358819751c (diff) | |
download | openttd-df92a056dffd9fa2a765246da10442717f459c7f.tar.xz |
Fix #6875: Depot building cost does not include foundation build cost (#6883)
Diffstat (limited to 'src')
-rw-r--r-- | src/rail_cmd.cpp | 14 | ||||
-rw-r--r-- | src/road_cmd.cpp | 14 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index d21c1468c..d5194e0c3 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -967,6 +967,8 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u DiagDirection dir = Extract<DiagDirection, 0, 2>(p2); + CommandCost cost(EXPENSES_CONSTRUCTION); + /* Prohibit construction if * The tile is non-flat AND * 1) build-on-slopes is disabled @@ -974,14 +976,14 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u * 3) the exit points in the wrong direction */ - if (tileh != SLOPE_FLAT && ( - !_settings_game.construction.build_on_slopes || - !CanBuildDepotByTileh(dir, tileh) - )) { - return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + if (tileh != SLOPE_FLAT) { + if (!_settings_game.construction.build_on_slopes || !CanBuildDepotByTileh(dir, tileh)) { + return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + } + cost.AddCost(_price[PR_BUILD_FOUNDATION]); } - CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)); if (cost.Failed()) return cost; if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 5e432a2e6..bdc8ce7f3 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1017,15 +1017,17 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; + CommandCost cost(EXPENSES_CONSTRUCTION); + Slope tileh = GetTileSlope(tile); - if (tileh != SLOPE_FLAT && ( - !_settings_game.construction.build_on_slopes || - !CanBuildDepotByTileh(dir, tileh) - )) { - return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + if (tileh != SLOPE_FLAT) { + if (!_settings_game.construction.build_on_slopes || !CanBuildDepotByTileh(dir, tileh)) { + return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + } + cost.AddCost(_price[PR_BUILD_FOUNDATION]); } - CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)); if (cost.Failed()) return cost; if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); |