summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-06-23 08:38:07 +0000
committerrubidium <rubidium@openttd.org>2008-06-23 08:38:07 +0000
commitd87b6c39377a21aacf4cc1554044eebf75ca5447 (patch)
tree1a2e268636bd1b5c36ffe7965e143b2f1695cfa3 /src
parent7772e9e68f076c4851248c9e945f14d878c659f0 (diff)
downloadopenttd-d87b6c39377a21aacf4cc1554044eebf75ca5447.tar.xz
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
Diffstat (limited to 'src')
-rw-r--r--src/bridge.h2
-rw-r--r--src/tunnelbridge_cmd.cpp13
2 files changed, 9 insertions, 6 deletions
diff --git a/src/bridge.h b/src/bridge.h
index af41be59f..648d54dde 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -44,7 +44,7 @@ static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
void DrawBridgeMiddle(const TileInfo *ti);
-bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len);
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0);
int CalcBridgeLenCostFactor(int x);
void ResetBridges();
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index ab05372be..5ceb36c44 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -160,15 +160,18 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
}
-bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len)
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags)
{
- const BridgeSpec *b = GetBridgeSpec(bridge_type);
- uint max; // max possible length of a bridge (with patch 100)
+ if (flags & DC_QUERY_COST) {
+ return bridge_len <= (_settings_game.construction.longbridges ? 100 : 16);
+ }
if (bridge_type >= MAX_BRIDGES) return false;
+
+ const BridgeSpec *b = GetBridgeSpec(bridge_type);
if (b->avail_year > _cur_year) return false;
- max = b->max_length;
+ uint max = b->max_length;
if (max >= 16 && _settings_game.construction.longbridges) max = 100;
return b->min_length <= bridge_len && bridge_len <= max;
@@ -255,7 +258,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
bridge_len = sx + sy - x - y - 1;
if (transport_type != TRANSPORT_WATER) {
/* set and test bridge length, availability */
- if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
+ if (!CheckBridge_Stuff(bridge_type, bridge_len, flags)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
}
/* retrieve landscape height and ensure it's on land */