Fix #9810: 'Rebuilding' a through road stop costs money (#9852)

This commit is contained in:
Chenshu Yu
2023-02-27 03:59:42 -05:00
committed by GitHub
parent 6fcc8727f5
commit eabb9db0bb
2 changed files with 121 additions and 11 deletions

View File

@@ -191,6 +191,21 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
if (distant_join && (!_settings_game.station.distant_join_stations || !Waypoint::IsValidID(station_to_join))) return CMD_ERROR;
TileArea new_location(start_tile, width, height);
/* only AddCost for non-existing waypoints */
CommandCost cost(EXPENSES_CONSTRUCTION);
bool success = false;
for (TileIndex cur_tile : new_location) {
if (!IsRailWaypointTile(cur_tile)) {
cost.AddCost(_price[PR_BUILD_WAYPOINT_RAIL]);
success = true;
}
}
if (!success) {
return_cmd_error(STR_ERROR_ALREADY_BUILT);
}
/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
StationID est = INVALID_STATION;
@@ -203,7 +218,6 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
}
Waypoint *wp = nullptr;
TileArea new_location(start_tile, width, height);
CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp);
if (ret.Failed()) return ret;
@@ -279,7 +293,7 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
DirtyCompanyInfrastructureWindows(wp->owner);
}
return CommandCost(EXPENSES_CONSTRUCTION, count * _price[PR_BUILD_WAYPOINT_RAIL]);
return cost;
}
/**