diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index de56fe0640..9971951ca6 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -420,7 +420,11 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo Money infra_cost = 0; switch (transport_type) { - case TRANSPORT_ROAD: infra_cost = (bridge_len + 2) * _price[PR_BUILD_ROAD] * 2; break; + case TRANSPORT_ROAD: + infra_cost = (bridge_len + 2) * _price[PR_BUILD_ROAD] * 2; + /* In case we add a new road type as well, we must be aware of those costs. */ + if (IsBridgeTile(start)) infra_cost *= CountBits(GetRoadTypes(start) | (RoadTypes)road_rail_type); + break; case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break; default: break; } diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index f01138aecf..336db846ab 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -425,10 +425,6 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) Object *o = Object::GetByTile(tile); TileArea ta = o->location; - ClearedObjectArea *cleared_area = _cleared_object_areas.Append(); - cleared_area->first_tile = tile; - cleared_area->area = ta; - CommandCost cost(EXPENSES_CONSTRUCTION, spec->GetClearCost() * ta.w * ta.h / 5); if (spec->flags & OBJECT_FLAG_CLEAR_INCOME) cost.MultiplyCost(-1); // They get an income! @@ -486,6 +482,10 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) break; } + ClearedObjectArea *cleared_area = _cleared_object_areas.Append(); + cleared_area->first_tile = tile; + cleared_area->area = ta; + if (flags & DC_EXEC) ReallyClearObjectTile(o); return cost; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 425d95c2e5..7284cd680b 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -662,12 +662,14 @@ do_clear:; if (ret.Failed()) return ret; } - cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]); - if (!need_to_clear && IsTileType(tile, MP_TUNNELBRIDGE)) { - /* Pay for *every* tile of the bridge or tunnel */ - cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); - } + uint num_pieces = (!need_to_clear && IsTileType(tile, MP_TUNNELBRIDGE)) ? + /* There are 2 pieces on *every* tile of the bridge or tunnel */ + 2 * (GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2) : + /* Count pieces */ + CountBits(pieces); + + cost.AddCost(num_pieces * _price[PR_BUILD_ROAD]); if (flags & DC_EXEC) { switch (GetTileType(tile)) { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 3ca3e3ddb9..1b3faa8c3a 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2125,8 +2125,16 @@ static bool BuildTownHouse(Town *t, TileIndex tile) } uint maxz = GetTileMaxZ(tile); + TileIndex baseTile = tile; while (probability_max > 0) { + /* Building a multitile building can change the location of tile. + * The building would still be built partially on that tile, but + * its nothern tile would be elsewere. However, if the callback + * fails we would be basing further work from the changed tile. + * So a next 1x1 tile building could be built on the wrong tile. */ + tile = baseTile; + uint r = RandomRange(probability_max); uint i; for (i = 0; i < num; i++) { diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 0f09b7bcc2..6e6f4bd25b 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -468,7 +468,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u bridge_len += 2; // begin and end tiles/ramps switch (transport_type) { - case TRANSPORT_ROAD: cost.AddCost(bridge_len * _price[PR_BUILD_ROAD] * 2); break; + case TRANSPORT_ROAD: cost.AddCost(bridge_len * _price[PR_BUILD_ROAD] * 2 * CountBits(roadtypes)); break; case TRANSPORT_RAIL: cost.AddCost(bridge_len * RailBuildCost(railtype)); break; default: break; }