mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use SQInteger for generic numbers in script_bridge
This commit is contained in:
parent
73561802cb
commit
58bf2f7176
|
@ -132,32 +132,34 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
|||
return GetString(vehicle_type == ScriptVehicle::VT_WATER ? STR_LAI_BRIDGE_DESCRIPTION_AQUEDUCT : ::GetBridgeSpec(bridge_id)->transport_name[vehicle_type]);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptBridge::GetMaxSpeed(BridgeID bridge_id)
|
||||
/* static */ SQInteger ScriptBridge::GetMaxSpeed(BridgeID bridge_id)
|
||||
{
|
||||
if (!IsValidBridge(bridge_id)) return -1;
|
||||
|
||||
return ::GetBridgeSpec(bridge_id)->speed; // km-ish/h
|
||||
}
|
||||
|
||||
/* static */ Money ScriptBridge::GetPrice(BridgeID bridge_id, uint length)
|
||||
/* static */ Money ScriptBridge::GetPrice(BridgeID bridge_id, SQInteger length)
|
||||
{
|
||||
if (!IsValidBridge(bridge_id)) return -1;
|
||||
|
||||
length = Clamp<SQInteger>(length, 0, INT32_MAX);
|
||||
|
||||
return ::CalcBridgeLenCostFactor(length) * _price[PR_BUILD_BRIDGE] * ::GetBridgeSpec(bridge_id)->price >> 8;
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptBridge::GetMaxLength(BridgeID bridge_id)
|
||||
/* static */ SQInteger ScriptBridge::GetMaxLength(BridgeID bridge_id)
|
||||
{
|
||||
if (!IsValidBridge(bridge_id)) return -1;
|
||||
|
||||
return std::min(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2;
|
||||
return std::min<SQInteger>(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2;
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptBridge::GetMinLength(BridgeID bridge_id)
|
||||
/* static */ SQInteger ScriptBridge::GetMinLength(BridgeID bridge_id)
|
||||
{
|
||||
if (!IsValidBridge(bridge_id)) return -1;
|
||||
|
||||
return ::GetBridgeSpec(bridge_id)->min_length + 2;
|
||||
return static_cast<SQInteger>(::GetBridgeSpec(bridge_id)->min_length) + 2;
|
||||
}
|
||||
|
||||
/* static */ TileIndex ScriptBridge::GetOtherBridgeEnd(TileIndex tile)
|
||||
|
|
|
@ -80,16 +80,17 @@ public:
|
|||
* This is mph / 1.6, which is roughly km/h.
|
||||
* To get km/h multiply this number by 1.00584.
|
||||
*/
|
||||
static int32 GetMaxSpeed(BridgeID bridge_id);
|
||||
static SQInteger GetMaxSpeed(BridgeID bridge_id);
|
||||
|
||||
/**
|
||||
* Get the new cost of a bridge, excluding the road and/or rail.
|
||||
* @param bridge_id The bridge to get the new cost of.
|
||||
* @param length The length of the bridge.
|
||||
* The value will be clamped to 0 .. MAX(int32).
|
||||
* @pre IsValidBridge(bridge_id).
|
||||
* @return The new cost the bridge has.
|
||||
*/
|
||||
static Money GetPrice(BridgeID bridge_id, uint length);
|
||||
static Money GetPrice(BridgeID bridge_id, SQInteger length);
|
||||
|
||||
/**
|
||||
* Get the maximum length of a bridge.
|
||||
|
@ -97,7 +98,7 @@ public:
|
|||
* @pre IsValidBridge(bridge_id).
|
||||
* @returns The maximum length the bridge has.
|
||||
*/
|
||||
static int32 GetMaxLength(BridgeID bridge_id);
|
||||
static SQInteger GetMaxLength(BridgeID bridge_id);
|
||||
|
||||
/**
|
||||
* Get the minimum length of a bridge.
|
||||
|
@ -105,7 +106,7 @@ public:
|
|||
* @pre IsValidBridge(bridge_id).
|
||||
* @returns The minimum length the bridge has.
|
||||
*/
|
||||
static int32 GetMinLength(BridgeID bridge_id);
|
||||
static SQInteger GetMinLength(BridgeID bridge_id);
|
||||
|
||||
/**
|
||||
* Internal function to help BuildBridge in case of road.
|
||||
|
|
Loading…
Reference in New Issue