Skip to content

Commit

Permalink
Fix #6875: Depot building cost does not include foundation build cost (
Browse files Browse the repository at this point in the history
  • Loading branch information
JGRennison authored and michicc committed Aug 14, 2018
1 parent d839526 commit df92a05
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bin/ai/regression/tst_regression/result.txt
Expand Up @@ -7253,7 +7253,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): false IsBuoyTile(): false
IsLockTile(): false IsLockTile(): false
IsCanalTile(): false IsCanalTile(): false
GetBankBalance(): 479851 GetBankBalance(): 479664
BuildWaterDepot(): true BuildWaterDepot(): true
BuildDock(): true BuildDock(): true
BuildBuoy(): true BuildBuoy(): true
Expand All @@ -7266,7 +7266,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): true IsBuoyTile(): true
IsLockTile(): true IsLockTile(): true
IsCanalTile(): true IsCanalTile(): true
GetBankBalance(): 465257 GetBankBalance(): 465070


--AIWaypointList(BUOY)-- --AIWaypointList(BUOY)--
Count(): 1 Count(): 1
Expand All @@ -7285,7 +7285,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): false IsBuoyTile(): false
IsLockTile(): false IsLockTile(): false
IsCanalTile(): false IsCanalTile(): false
GetBankBalance(): 459862 GetBankBalance(): 459675
BuildWaterDepot(): true BuildWaterDepot(): true
BuildDock(): true BuildDock(): true


Expand Down
14 changes: 8 additions & 6 deletions src/rail_cmd.cpp
Expand Up @@ -967,21 +967,23 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u


DiagDirection dir = Extract<DiagDirection, 0, 2>(p2); DiagDirection dir = Extract<DiagDirection, 0, 2>(p2);


CommandCost cost(EXPENSES_CONSTRUCTION);

/* Prohibit construction if /* Prohibit construction if
* The tile is non-flat AND * The tile is non-flat AND
* 1) build-on-slopes is disabled * 1) build-on-slopes is disabled
* 2) the tile is steep i.e. spans two height levels * 2) the tile is steep i.e. spans two height levels
* 3) the exit points in the wrong direction * 3) the exit points in the wrong direction
*/ */


if (tileh != SLOPE_FLAT && ( if (tileh != SLOPE_FLAT) {
!_settings_game.construction.build_on_slopes || if (!_settings_game.construction.build_on_slopes || !CanBuildDepotByTileh(dir, tileh)) {
!CanBuildDepotByTileh(dir, tileh) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
)) { }
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 (cost.Failed()) return cost;


if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
Expand Down
14 changes: 8 additions & 6 deletions src/road_cmd.cpp
Expand Up @@ -1017,15 +1017,17 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui


if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;


CommandCost cost(EXPENSES_CONSTRUCTION);

Slope tileh = GetTileSlope(tile); Slope tileh = GetTileSlope(tile);
if (tileh != SLOPE_FLAT && ( if (tileh != SLOPE_FLAT) {
!_settings_game.construction.build_on_slopes || if (!_settings_game.construction.build_on_slopes || !CanBuildDepotByTileh(dir, tileh)) {
!CanBuildDepotByTileh(dir, tileh) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
)) { }
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 (cost.Failed()) return cost;


if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
Expand Down

0 comments on commit df92a05

Please sign in to comment.