summaryrefslogtreecommitdiff
path: root/src/bridge_gui.cpp
diff options
context:
space:
mode:
authorTrevorShelton <54145769+TrevorShelton@users.noreply.github.com>2020-06-28 04:53:56 -0700
committerGitHub <noreply@github.com>2020-06-28 12:53:56 +0100
commita4a9908a51a00277eae764148b33095ffbf0699d (patch)
tree473fad8fad7b0bcf879b32056e6a29b35c364099 /src/bridge_gui.cpp
parent63d20c029bd283e03a93d3ab93e1565ac427cdce (diff)
downloadopenttd-a4a9908a51a00277eae764148b33095ffbf0699d.tar.xz
Fix #8221: Missing specific error message for bridge too long (#8240)
Diffstat (limited to 'src/bridge_gui.cpp')
-rw-r--r--src/bridge_gui.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index f10b52f66..44cc99ba3 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -426,9 +426,12 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
default: break;
}
+ bool any_available = false;
+ CommandCost type_check;
/* loop for all bridgetypes */
for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
- if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
+ type_check = CheckBridgeAvailability(brd_type, bridge_len);
+ if (type_check.Succeeded()) {
/* bridge is accepted, add to list */
/*C++17: BuildBridgeData &item = */ bl->emplace_back();
BuildBridgeData &item = bl->back();
@@ -437,8 +440,14 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
/* 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) + infra_cost;
+ any_available = true;
}
}
+ /* give error cause if no bridges available here*/
+ if (!any_available)
+ {
+ errmsg = type_check.GetErrorMessage();
+ }
}
if (bl != nullptr && bl->size() != 0) {