summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-10 23:43:14 +0000
committerrubidium <rubidium@openttd.org>2010-11-10 23:43:14 +0000
commited18d02e9a18f52cff79bce4d01cbfe9faae2de4 (patch)
tree96aa45c14247e75526e67acafa2c14c46e2f9c83
parent65e6c9fd12b0ac3fc25934c14771412a6a5538bd (diff)
downloadopenttd-ed18d02e9a18f52cff79bce4d01cbfe9faae2de4.tar.xz
(svn r21142) -Codechange: replace magic bridge length constants with proper constants (uni657)
-rw-r--r--src/ai/api/ai_bridge.cpp2
-rw-r--r--src/bridge.h3
-rw-r--r--src/tunnelbridge_cmd.cpp6
3 files changed, 7 insertions, 4 deletions
diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp
index 79a4f84cb..30c1cee6c 100644
--- a/src/ai/api/ai_bridge.cpp
+++ b/src/ai/api/ai_bridge.cpp
@@ -152,7 +152,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
if (!IsValidBridge(bridge_id)) return -1;
uint max = ::GetBridgeSpec(bridge_id)->max_length;
- if (max >= 16 && _settings_game.construction.longbridges) max = 100;
+ if (max >= MAX_BRIDGE_LENGTH && _settings_game.construction.longbridges) max = MAX_BRIDGE_LENGTH_LONGBRIDGES;
return max + 2;
}
diff --git a/src/bridge.h b/src/bridge.h
index b0546669b..5f2c1db59 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -72,4 +72,7 @@ int CalcBridgeLenCostFactor(int x);
void ResetBridges();
+static const uint MAX_BRIDGE_LENGTH = 16; ///< Maximum length of the bridge
+static const uint MAX_BRIDGE_LENGTH_LONGBRIDGES = 100; ///< Maximum length of the bridge with longbridges enabled
+
#endif /* BRIDGE_H */
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 9bbef4bc9..1b89b7d16 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -173,7 +173,7 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
{
if (flags & DC_QUERY_COST) {
- if (bridge_len <= (_settings_game.construction.longbridges ? 100U : 16U)) return CommandCost();
+ if (bridge_len <= (_settings_game.construction.longbridges ? MAX_BRIDGE_LENGTH_LONGBRIDGES : MAX_BRIDGE_LENGTH)) return CommandCost();
return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
}
@@ -183,7 +183,7 @@ CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoC
if (b->avail_year > _cur_year) return CMD_ERROR;
uint max = b->max_length;
- if (max >= 16 && _settings_game.construction.longbridges) max = 100;
+ if (max >= MAX_BRIDGE_LENGTH && _settings_game.construction.longbridges) max = MAX_BRIDGE_LENGTH_LONGBRIDGES;
if (b->min_length > bridge_len) return CMD_ERROR;
if (bridge_len <= max) return CommandCost();
@@ -257,7 +257,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
CommandCost ret = CheckBridgeAvailability(bridge_type, bridge_len, flags);
if (ret.Failed()) return ret;
} else {
- if (bridge_len > (_settings_game.construction.longbridges ? 100U : 16U)) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
+ if (bridge_len > (_settings_game.construction.longbridges ? MAX_BRIDGE_LENGTH_LONGBRIDGES : MAX_BRIDGE_LENGTH)) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
}
uint z_start;