summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-06 19:39:20 +0100
committerPatric Stout <github@truebrain.nl>2021-01-08 12:02:25 +0100
commitebd9f26c152a400d55d52bad77ec97ea2f5788fe (patch)
treea5915baf5df523609d08185b9fa1182693e9ce7b /src/tunnelbridge_cmd.cpp
parentef6b17baf74119e5c1515482cd6feb837afbe90b (diff)
downloadopenttd-ebd9f26c152a400d55d52bad77ec97ea2f5788fe.tar.xz
Fix: replacing a bridge didn't charge for clearing last tile
It only considered the end-tile (or start-tile) for the bridge, instead of both. This is obvious in the rest of the code which constantly does "+ 2"; this being the only place that does a "+ 1".
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index e19b64c50..1ac747bc2 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -296,6 +296,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
} else {
if (bridge_len > _settings_game.construction.max_bridge_length) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
}
+ bridge_len += 2; // begin and end tiles/ramps
int z_start;
int z_end;
@@ -372,7 +373,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
return_cmd_error(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER);
}
- cost.AddCost((bridge_len + 1) * _price[PR_CLEAR_BRIDGE]); // The cost of clearing the current bridge.
+ cost.AddCost(bridge_len * _price[PR_CLEAR_BRIDGE]); // The cost of clearing the current bridge.
owner = GetTileOwner(tile_start);
/* If bridge belonged to bankrupt company, it has a new owner now */
@@ -497,7 +498,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
switch (transport_type) {
case TRANSPORT_RAIL:
/* Add to company infrastructure count if required. */
- if (is_new_owner && c != nullptr) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ if (is_new_owner && c != nullptr) c->infrastructure.rail[railtype] += bridge_len * TUNNELBRIDGE_TRACKBIT_FACTOR;
MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype);
MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype);
SetTunnelBridgeReservation(tile_start, pbs_reservation);
@@ -514,11 +515,11 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
/* Add all new road types to the company infrastructure counter. */
if (!hasroad && road_rt != INVALID_ROADTYPE) {
/* A full diagonal road tile has two road bits. */
- c->infrastructure.road[road_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ c->infrastructure.road[road_rt] += bridge_len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
}
if (!hastram && tram_rt != INVALID_ROADTYPE) {
/* A full diagonal road tile has two road bits. */
- c->infrastructure.road[tram_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ c->infrastructure.road[tram_rt] += bridge_len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
}
}
Owner owner_road = hasroad ? GetRoadOwner(tile_start, RTT_ROAD) : company;
@@ -529,7 +530,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
}
case TRANSPORT_WATER:
- if (is_new_owner && c != nullptr) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ if (is_new_owner && c != nullptr) c->infrastructure.water += bridge_len * TUNNELBRIDGE_TRACKBIT_FACTOR;
MakeAqueductBridgeRamp(tile_start, owner, dir);
MakeAqueductBridgeRamp(tile_end, owner, ReverseDiagDir(dir));
CheckForDockingTile(tile_start);
@@ -557,8 +558,6 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
* For (non-spectated) AI, Towns this has to be of course calculated. */
Company *c = Company::GetIfValid(company);
if (!(flags & DC_QUERY_COST) || (c != nullptr && c->is_ai && company != _local_company)) {
- bridge_len += 2; // begin and end tiles/ramps
-
switch (transport_type) {
case TRANSPORT_ROAD:
if (road_rt != INVALID_ROADTYPE) {