mirror of https://github.com/OpenTTD/OpenTTD
(svn r22702) [1.1] -Backport from trunk:
- Fix: Cost of adding an extra road type to a bridge or tunnel was undercalculated [FS#4680, FS#4681] (r22700, r22699) - Fix: Only insert cleared object tiles into _cleared_object_areas if clearing actually succeeds, else subsequential tests of the same tile will be skipped and considered successful [FS#4694] (r22698) - Fix: When building a house it could be built at the wrong place if multitile houses failed some tests (r22697)release/1.1
parent
a51531e410
commit
be65972895
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue