src/tunnelbridge_cmd.cpp
branch0.6
changeset 11130 488ecb9d3296
parent 9121 7d41612f5ba3
child 11152 b56fd5acecaf
--- a/src/tunnelbridge_cmd.cpp	Wed Jul 09 19:15:43 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp	Wed Jul 09 19:20:50 2008 +0000
@@ -152,15 +152,18 @@
 	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 <= (_patches.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 && _patches.longbridges) max = 100;
 
 	return b->min_length <= bridge_len && bridge_len <= max;
@@ -244,7 +247,7 @@
 
 	/* set and test bridge length, availability */
 	bridge_len = sx + sy - x - y - 1;
-	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 */
 	tile_start = TileXY(x, y);