summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_bridge.hpp2
-rw-r--r--src/ai/api/ai_changelog.hpp5
-rw-r--r--src/bridge_gui.cpp10
-rw-r--r--src/tunnelbridge_cmd.cpp13
4 files changed, 26 insertions, 4 deletions
diff --git a/src/ai/api/ai_bridge.hpp b/src/ai/api/ai_bridge.hpp
index e9daa27b4..19e6bbed1 100644
--- a/src/ai/api/ai_bridge.hpp
+++ b/src/ai/api/ai_bridge.hpp
@@ -86,7 +86,7 @@ public:
static int32 GetMaxSpeed(BridgeID bridge_id);
/**
- * Get the new cost of a bridge.
+ * Get the new cost of a bridge, excluding the road and/or rail.
* @param bridge_id The bridge to get the new cost of.
* @param length The length of the bridge.
* @pre IsValidBridge(bridge_id).
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp
index b8943a1da..c748066cd 100644
--- a/src/ai/api/ai_changelog.hpp
+++ b/src/ai/api/ai_changelog.hpp
@@ -27,8 +27,9 @@
* \li HasNext for all lists.
*
* Other changes:
- * \li AIRoad::BuildRoadStation now allows overbuilding
- * \li AIRoad::BuildDriveThroughRoadStation now allows overbuilding
+ * \li AIBridge::GetPrice now returns the price of the bridge without the cost for the rail or road.
+ * \li AIRoad::BuildRoadStation now allows overbuilding.
+ * \li AIRoad::BuildDriveThroughRoadStation now allows overbuilding.
* \li AIEngine::GetPower can be used for road vehicles.
* \li AIEngine::GetWeight can be used for road vehicles.
* \li AIEngine::GetMaxTractiveEffort can be used for road vehicles.
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index acdb95b5a..c11d7554f 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -14,6 +14,7 @@
#include "command_func.h"
#include "economy_func.h"
#include "bridge.h"
+#include "rail.h"
#include "strings_func.h"
#include "window_func.h"
#include "sound_func.h"
@@ -394,6 +395,13 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
bl = new GUIBridgeList();
+ Money infra_cost = 0;
+ switch (transport_type) {
+ case TRANSPORT_ROAD: infra_cost = (bridge_len + 2) * _price[PR_BUILD_ROAD] * 2; break;
+ case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break;
+ default: break;
+ }
+
/* loop for all bridgetypes */
for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
@@ -403,7 +411,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
item->spec = GetBridgeSpec(brd_type);
/* Add to terraforming & bulldozing costs the cost of the
* bridge itself (not computed with DC_QUERY_COST) */
- item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8);
+ item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8) + infra_cost;
}
}
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index a08410eb5..e706b27af 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -468,6 +468,12 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
if (!(flags & DC_QUERY_COST) || (c != NULL && c->is_ai)) {
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_RAIL: cost.AddCost(bridge_len * RailBuildCost(railtype)); break;
+ default: break;
+ }
+
if (c != NULL) bridge_len = CalcBridgeLenCostFactor(bridge_len);
if (transport_type != TRANSPORT_WATER) {
@@ -596,6 +602,13 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
cost.AddCost(_price[PR_BUILD_TUNNEL]);
cost.AddCost(ret);
+ /* Pay for the rail/road in the tunnel including entrances */
+ switch (transport_type) {
+ case TRANSPORT_ROAD: cost.AddCost((tiles + 2) * _price[PR_BUILD_ROAD] * 2); break;
+ case TRANSPORT_RAIL: cost.AddCost((tiles + 2) * RailBuildCost(railtype)); break;
+ default: break;
+ }
+
if (flags & DC_EXEC) {
if (transport_type == TRANSPORT_RAIL) {
MakeRailTunnel(start_tile, _current_company, direction, railtype);