summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-07-30 14:10:12 +0000
committerrubidium <rubidium@openttd.org>2011-07-30 14:10:12 +0000
commit7b418502ab8006a3879a85e4edff3138b2523b61 (patch)
tree7baeb71f3cb8ea5a98bb00936ed0edc1c18a9ba3
parentcfc2c5db42c988875ec169157bf977c934034196 (diff)
downloadopenttd-7b418502ab8006a3879a85e4edff3138b2523b61.tar.xz
(svn r22700) -Fix [FS#4680]: cost of changing bridge type is undercalculated when adding road types as well (based on patch by adf88)
-rw-r--r--src/bridge_gui.cpp6
-rw-r--r--src/tunnelbridge_cmd.cpp2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index de56fe064..9971951ca 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/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 51323f0c1..ec98fc1ce 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -474,7 +474,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;
}