diff options
author | peter1138 <peter1138@openttd.org> | 2019-04-06 07:46:15 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-05-01 21:36:27 +0200 |
commit | c02ef3e4564b7b54d49f0827d2d7625cbc38f335 (patch) | |
tree | 1c0ee62b6ce55124b247daaafa42300bfaa932e7 /src/bridge_gui.cpp | |
parent | 21edf67f89c60351d5a0d84625455aa296b6b950 (diff) | |
download | openttd-c02ef3e4564b7b54d49f0827d2d7625cbc38f335.tar.xz |
Feature: Add NotRoadTypes (NRT)
Diffstat (limited to 'src/bridge_gui.cpp')
-rw-r--r-- | src/bridge_gui.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index b11290ae4..710c591ca 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -13,6 +13,7 @@ #include "error.h" #include "command_func.h" #include "rail.h" +#include "road.h" #include "strings_func.h" #include "window_func.h" #include "sound_func.h" @@ -403,11 +404,25 @@ 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; + case TRANSPORT_ROAD: { /* 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); + RoadType road_rt = INVALID_ROADTYPE; + RoadType tram_rt = INVALID_ROADTYPE; + if (IsBridgeTile(start)) { + road_rt = GetRoadTypeRoad(start); + tram_rt = GetRoadTypeTram(start); + } + if (RoadTypeIsRoad((RoadType)road_rail_type)) { + road_rt = (RoadType)road_rail_type; + } else { + tram_rt = (RoadType)road_rail_type; + } + + if (road_rt != INVALID_ROADTYPE) infra_cost += (bridge_len + 2) * 2 * RoadBuildCost(road_rt); + if (tram_rt != INVALID_ROADTYPE) infra_cost += (bridge_len + 2) * 2 * RoadBuildCost(tram_rt); + break; + } case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break; default: break; } |