From b1ab1b9f06edfb1f730e18146327cd75fd659691 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 21 Jan 2025 22:44:34 +0100 Subject: [PATCH] Change: [Script] rename BridgeID to BridgeType in the script API --- bin/ai/compat_0.7.nut | 3 ++ bin/ai/compat_1.0.nut | 3 ++ bin/ai/compat_1.1.nut | 3 ++ bin/ai/compat_1.10.nut | 3 ++ bin/ai/compat_1.11.nut | 3 ++ bin/ai/compat_1.2.nut | 3 ++ bin/ai/compat_1.3.nut | 3 ++ bin/ai/compat_1.4.nut | 3 ++ bin/ai/compat_1.5.nut | 3 ++ bin/ai/compat_1.6.nut | 3 ++ bin/ai/compat_1.7.nut | 3 ++ bin/ai/compat_1.8.nut | 3 ++ bin/ai/compat_1.9.nut | 3 ++ bin/ai/compat_12.nut | 3 ++ bin/ai/compat_13.nut | 3 ++ bin/ai/compat_14.nut | 3 ++ bin/game/compat_1.10.nut | 3 ++ bin/game/compat_1.11.nut | 3 ++ bin/game/compat_1.2.nut | 3 ++ bin/game/compat_1.3.nut | 3 ++ bin/game/compat_1.4.nut | 3 ++ bin/game/compat_1.5.nut | 3 ++ bin/game/compat_1.6.nut | 3 ++ bin/game/compat_1.7.nut | 3 ++ bin/game/compat_1.8.nut | 3 ++ bin/game/compat_1.9.nut | 3 ++ bin/game/compat_12.nut | 3 ++ bin/game/compat_13.nut | 3 ++ bin/game/compat_14.nut | 3 ++ regression/regression/main.nut | 6 ++-- regression/regression/result.txt | 6 ++-- src/script/api/ai_changelog.hpp | 3 ++ src/script/api/game_changelog.hpp | 3 ++ src/script/api/script_bridge.cpp | 48 +++++++++++++++---------------- src/script/api/script_bridge.hpp | 46 ++++++++++++++--------------- src/script/api/script_types.hpp | 4 +-- 36 files changed, 148 insertions(+), 55 deletions(-) diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut index 341b543bd3..0b2fa1f243 100644 --- a/bin/ai/compat_0.7.nut +++ b/bin/ai/compat_0.7.nut @@ -392,3 +392,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.0.nut b/bin/ai/compat_1.0.nut index 6b76f11534..bf3b8334e6 100644 --- a/bin/ai/compat_1.0.nut +++ b/bin/ai/compat_1.0.nut @@ -144,3 +144,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.1.nut b/bin/ai/compat_1.1.nut index 9c568a7006..456b054aba 100644 --- a/bin/ai/compat_1.1.nut +++ b/bin/ai/compat_1.1.nut @@ -81,3 +81,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.10.nut b/bin/ai/compat_1.10.nut index 44bc2542ce..9b82efdcb3 100644 --- a/bin/ai/compat_1.10.nut +++ b/bin/ai/compat_1.10.nut @@ -19,3 +19,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.11.nut b/bin/ai/compat_1.11.nut index 3d8370ffc6..1b6bc4da04 100644 --- a/bin/ai/compat_1.11.nut +++ b/bin/ai/compat_1.11.nut @@ -19,3 +19,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.2.nut b/bin/ai/compat_1.2.nut index fc52b04935..75ffd93d66 100644 --- a/bin/ai/compat_1.2.nut +++ b/bin/ai/compat_1.2.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.3.nut b/bin/ai/compat_1.3.nut index a06e98d2dd..5bc97c2cb2 100644 --- a/bin/ai/compat_1.3.nut +++ b/bin/ai/compat_1.3.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.4.nut b/bin/ai/compat_1.4.nut index 6de24bf80c..5700c6bfb8 100644 --- a/bin/ai/compat_1.4.nut +++ b/bin/ai/compat_1.4.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.5.nut b/bin/ai/compat_1.5.nut index 8ff5a39d15..88f4221b4e 100644 --- a/bin/ai/compat_1.5.nut +++ b/bin/ai/compat_1.5.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.6.nut b/bin/ai/compat_1.6.nut index 91744512a7..4ddb4c5bcb 100644 --- a/bin/ai/compat_1.6.nut +++ b/bin/ai/compat_1.6.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.7.nut b/bin/ai/compat_1.7.nut index 584a970f60..557f13bdc3 100644 --- a/bin/ai/compat_1.7.nut +++ b/bin/ai/compat_1.7.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.8.nut b/bin/ai/compat_1.8.nut index f57a0eab27..8e99a2c0c1 100644 --- a/bin/ai/compat_1.8.nut +++ b/bin/ai/compat_1.8.nut @@ -33,3 +33,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_1.9.nut b/bin/ai/compat_1.9.nut index 0dde6dc6da..8301ebb4b8 100644 --- a/bin/ai/compat_1.9.nut +++ b/bin/ai/compat_1.9.nut @@ -19,3 +19,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_12.nut b/bin/ai/compat_12.nut index d54895632f..3ac3c66cb7 100644 --- a/bin/ai/compat_12.nut +++ b/bin/ai/compat_12.nut @@ -19,3 +19,6 @@ AIRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_13.nut b/bin/ai/compat_13.nut index 5f808e38a0..42311e8001 100644 --- a/bin/ai/compat_13.nut +++ b/bin/ai/compat_13.nut @@ -6,3 +6,6 @@ */ AILog.Info("13 API compatibility in effect."); + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/ai/compat_14.nut b/bin/ai/compat_14.nut index 0588a2b7fa..a303139a69 100644 --- a/bin/ai/compat_14.nut +++ b/bin/ai/compat_14.nut @@ -6,3 +6,6 @@ */ AILog.Info("14 API compatibility in effect."); + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.10.nut b/bin/game/compat_1.10.nut index 2559ff0a9c..7275e766cc 100644 --- a/bin/game/compat_1.10.nut +++ b/bin/game/compat_1.10.nut @@ -26,3 +26,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.11.nut b/bin/game/compat_1.11.nut index eac9a05d36..4418407add 100644 --- a/bin/game/compat_1.11.nut +++ b/bin/game/compat_1.11.nut @@ -19,3 +19,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.2.nut b/bin/game/compat_1.2.nut index 66e2ca5d62..f3310040d6 100644 --- a/bin/game/compat_1.2.nut +++ b/bin/game/compat_1.2.nut @@ -48,3 +48,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.3.nut b/bin/game/compat_1.3.nut index 9986ea03e5..0ceeab1b95 100644 --- a/bin/game/compat_1.3.nut +++ b/bin/game/compat_1.3.nut @@ -48,3 +48,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.4.nut b/bin/game/compat_1.4.nut index b3ec5c45cb..737d28026d 100644 --- a/bin/game/compat_1.4.nut +++ b/bin/game/compat_1.4.nut @@ -40,3 +40,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.5.nut b/bin/game/compat_1.5.nut index 2d25d7acf0..556fc9e9ee 100644 --- a/bin/game/compat_1.5.nut +++ b/bin/game/compat_1.5.nut @@ -33,3 +33,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.6.nut b/bin/game/compat_1.6.nut index d205832209..b995dc74a6 100644 --- a/bin/game/compat_1.6.nut +++ b/bin/game/compat_1.6.nut @@ -33,3 +33,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.7.nut b/bin/game/compat_1.7.nut index 1108f41a7c..a8af116b8a 100644 --- a/bin/game/compat_1.7.nut +++ b/bin/game/compat_1.7.nut @@ -33,3 +33,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.8.nut b/bin/game/compat_1.8.nut index 139f91214b..be040c674d 100644 --- a/bin/game/compat_1.8.nut +++ b/bin/game/compat_1.8.nut @@ -33,3 +33,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_1.9.nut b/bin/game/compat_1.9.nut index 053e377d4c..48b1b8ff47 100644 --- a/bin/game/compat_1.9.nut +++ b/bin/game/compat_1.9.nut @@ -26,3 +26,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_12.nut b/bin/game/compat_12.nut index a11cd04a23..0c10894a77 100644 --- a/bin/game/compat_12.nut +++ b/bin/game/compat_12.nut @@ -19,3 +19,6 @@ GSRoad.HasRoadType <- function(tile, road_type) } return false; } + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_13.nut b/bin/game/compat_13.nut index 0ee9faf2bd..43b84786c3 100644 --- a/bin/game/compat_13.nut +++ b/bin/game/compat_13.nut @@ -6,3 +6,6 @@ */ GSLog.Info("13 API compatibility in effect."); + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/bin/game/compat_14.nut b/bin/game/compat_14.nut index 9a5f872147..3a1eef26c7 100644 --- a/bin/game/compat_14.nut +++ b/bin/game/compat_14.nut @@ -6,3 +6,6 @@ */ GSLog.Info("14 API compatibility in effect."); + +/* 15 renames GetBridgeID */ +AIBridge.GetBridgeID <- AIBridge.GetBridgeType; diff --git a/regression/regression/main.nut b/regression/regression/main.nut index f023f0f7d0..c0fe80ea4b 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -265,15 +265,15 @@ function Regression::Bridge() print(" Valid Bridges: " + j); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160)); - print(" GetBridgeID(): " + AIBridge.GetBridgeID(33160)); + print(" GetBridgeType(): " + AIBridge.GetBridgeType(33160)); print(" RemoveBridge(): " + AIBridge.RemoveBridge(33155)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160)); print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155)); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160)); - print(" GetBridgeID(): " + AIBridge.GetBridgeID(33160)); + print(" GetBridgeType(): " + AIBridge.GetBridgeType(33160)); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33155)); - print(" GetBridgeID(): " + AIBridge.GetBridgeID(33155)); + print(" GetBridgeType(): " + AIBridge.GetBridgeType(33155)); print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160)); print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); diff --git a/regression/regression/result.txt b/regression/regression/result.txt index 8611b2f8aa..f00c9e3813 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -1051,15 +1051,15 @@ ERROR: IsEnd() is invalid as Begin() is never called GetMinLength(): -1 Valid Bridges: 10 IsBridgeTile(): false - GetBridgeID(): -1 + GetBridgeType(): -1 RemoveBridge(): false GetLastErrorString(): ERR_PRECONDITION_FAILED GetOtherBridgeEnd(): -1 BuildBridge(): true IsBridgeTile(): true - GetBridgeID(): 5 + GetBridgeType(): 5 IsBridgeTile(): true - GetBridgeID(): 5 + GetBridgeType(): 5 GetOtherBridgeEnd(): 33155 BuildBridge(): false GetLastErrorString(): ERR_ALREADY_BUILT diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index ecc51d8072..111474d3de 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -22,6 +22,9 @@ * \li AIEventCompanyRenamed * \li AIEventPresidentRenamed * + * Other changes: + * \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType + * * \b 14.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 655cfac0b6..59ad146d29 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -22,6 +22,9 @@ * \li GSEventCompanyRenamed * \li GSEventPresidentRenamed * + * Other changes: + * \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType + * * \b 14.0 * * API additions: diff --git a/src/script/api/script_bridge.cpp b/src/script/api/script_bridge.cpp index 2dc3f6933c..34661d151f 100644 --- a/src/script/api/script_bridge.cpp +++ b/src/script/api/script_bridge.cpp @@ -21,9 +21,9 @@ #include "../../safeguards.h" -/* static */ bool ScriptBridge::IsValidBridge(BridgeID bridge_id) +/* static */ bool ScriptBridge::IsValidBridge(BridgeType bridge_type) { - return bridge_id < MAX_BRIDGES && ::GetBridgeSpec(bridge_id)->avail_year <= TimerGameCalendar::year; + return bridge_type < MAX_BRIDGES && ::GetBridgeSpec(bridge_type)->avail_year <= TimerGameCalendar::year; } /* static */ bool ScriptBridge::IsBridgeTile(TileIndex tile) @@ -32,10 +32,10 @@ return ::IsBridgeTile(tile); } -/* static */ BridgeID ScriptBridge::GetBridgeID(TileIndex tile) +/* static */ BridgeType ScriptBridge::GetBridgeType(TileIndex tile) { - if (!IsBridgeTile(tile)) return (BridgeID)-1; - return (BridgeID)::GetBridgeType(tile); + if (!IsBridgeTile(tile)) return (BridgeType)-1; + return (BridgeType)::GetBridgeType(tile); } /** @@ -70,7 +70,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance) NOT_REACHED(); } -/* static */ bool ScriptBridge::BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end) +/* static */ bool ScriptBridge::BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeType bridge_type, TileIndex start, TileIndex end) { EnforceDeityOrCompanyModeValid(false); EnforcePrecondition(false, start != end); @@ -85,11 +85,11 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance) case ScriptVehicle::VT_ROAD: ScriptObject::SetCallbackVariable(0, start.base()); ScriptObject::SetCallbackVariable(1, end.base()); - return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge1, end, start, TRANSPORT_ROAD, bridge_id, ScriptRoad::GetCurrentRoadType()); + return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge1, end, start, TRANSPORT_ROAD, bridge_type, ScriptRoad::GetCurrentRoadType()); case ScriptVehicle::VT_RAIL: - return ScriptObject::Command::Do(end, start, TRANSPORT_RAIL, bridge_id, ScriptRail::GetCurrentRailType()); + return ScriptObject::Command::Do(end, start, TRANSPORT_RAIL, bridge_type, ScriptRail::GetCurrentRailType()); case ScriptVehicle::VT_WATER: - return ScriptObject::Command::Do(end, start, TRANSPORT_WATER, bridge_id, 0); + return ScriptObject::Command::Do(end, start, TRANSPORT_WATER, bridge_type, 0); default: NOT_REACHED(); } } @@ -129,42 +129,42 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance) return ScriptObject::Command::Do(tile); } -/* static */ std::optional ScriptBridge::GetName(BridgeID bridge_id, ScriptVehicle::VehicleType vehicle_type) +/* static */ std::optional ScriptBridge::GetName(BridgeType bridge_type, ScriptVehicle::VehicleType vehicle_type) { EnforcePrecondition(std::nullopt, vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER); - if (!IsValidBridge(bridge_id)) return std::nullopt; + if (!IsValidBridge(bridge_type)) return std::nullopt; - return GetString(vehicle_type == ScriptVehicle::VT_WATER ? STR_LAI_BRIDGE_DESCRIPTION_AQUEDUCT : ::GetBridgeSpec(bridge_id)->transport_name[vehicle_type]); + return GetString(vehicle_type == ScriptVehicle::VT_WATER ? STR_LAI_BRIDGE_DESCRIPTION_AQUEDUCT : ::GetBridgeSpec(bridge_type)->transport_name[vehicle_type]); } -/* static */ SQInteger ScriptBridge::GetMaxSpeed(BridgeID bridge_id) +/* static */ SQInteger ScriptBridge::GetMaxSpeed(BridgeType bridge_type) { - if (!IsValidBridge(bridge_id)) return -1; + if (!IsValidBridge(bridge_type)) return -1; - return ::GetBridgeSpec(bridge_id)->speed; // km-ish/h + return ::GetBridgeSpec(bridge_type)->speed; // km-ish/h } -/* static */ Money ScriptBridge::GetPrice(BridgeID bridge_id, SQInteger length) +/* static */ Money ScriptBridge::GetPrice(BridgeType bridge_type, SQInteger length) { - if (!IsValidBridge(bridge_id)) return -1; + if (!IsValidBridge(bridge_type)) return -1; length = Clamp(length, 0, INT32_MAX); - return ::CalcBridgeLenCostFactor(length) * _price[PR_BUILD_BRIDGE] * ::GetBridgeSpec(bridge_id)->price >> 8; + return ::CalcBridgeLenCostFactor(length) * _price[PR_BUILD_BRIDGE] * ::GetBridgeSpec(bridge_type)->price >> 8; } -/* static */ SQInteger ScriptBridge::GetMaxLength(BridgeID bridge_id) +/* static */ SQInteger ScriptBridge::GetMaxLength(BridgeType bridge_type) { - if (!IsValidBridge(bridge_id)) return -1; + if (!IsValidBridge(bridge_type)) return -1; - return std::min(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2; + return std::min(::GetBridgeSpec(bridge_type)->max_length, _settings_game.construction.max_bridge_length) + 2; } -/* static */ SQInteger ScriptBridge::GetMinLength(BridgeID bridge_id) +/* static */ SQInteger ScriptBridge::GetMinLength(BridgeType bridge_type) { - if (!IsValidBridge(bridge_id)) return -1; + if (!IsValidBridge(bridge_type)) return -1; - return static_cast(::GetBridgeSpec(bridge_id)->min_length) + 2; + return static_cast(::GetBridgeSpec(bridge_type)->min_length) + 2; } /* static */ TileIndex ScriptBridge::GetOtherBridgeEnd(TileIndex tile) diff --git a/src/script/api/script_bridge.hpp b/src/script/api/script_bridge.hpp index 964341244a..1e8605c01d 100644 --- a/src/script/api/script_bridge.hpp +++ b/src/script/api/script_bridge.hpp @@ -42,10 +42,10 @@ public: /** * Checks whether the given bridge type is valid. - * @param bridge_id The bridge to check. + * @param bridge_type The bridge to check. * @return True if and only if the bridge type is valid. */ - static bool IsValidBridge(BridgeID bridge_id); + static bool IsValidBridge(BridgeType bridge_type); /** * Checks whether the given tile is actually a bridge start or end tile. @@ -56,59 +56,59 @@ public: static bool IsBridgeTile(TileIndex tile); /** - * Get the BridgeID of a bridge at a given tile. - * @param tile The tile to get the BridgeID from. + * Get the BridgeType of a bridge at a given tile. + * @param tile The tile to get the BridgeType from. * @pre IsBridgeTile(tile). - * @return The BridgeID from the bridge at tile 'tile'. + * @return The BridgeType from the bridge at tile 'tile'. */ - static BridgeID GetBridgeID(TileIndex tile); + static BridgeType GetBridgeType(TileIndex tile); /** * Get the name of a bridge. - * @param bridge_id The bridge to get the name of. + * @param bridge_type The bridge to get the name of. * @param vehicle_type The vehicle-type of bridge to get the name of. - * @pre IsValidBridge(bridge_id). + * @pre IsValidBridge(bridge_type). * @pre vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER * @return The name the bridge has. */ - static std::optional GetName(BridgeID bridge_id, ScriptVehicle::VehicleType vehicle_type); + static std::optional GetName(BridgeType bridge_type, ScriptVehicle::VehicleType vehicle_type); /** * Get the maximum speed of a bridge. - * @param bridge_id The bridge to get the maximum speed of. - * @pre IsValidBridge(bridge_id). + * @param bridge_type The bridge to get the maximum speed of. + * @pre IsValidBridge(bridge_type). * @return The maximum speed the bridge has. * @note The speed is in OpenTTD's internal speed unit. * This is mph / 1.6, which is roughly km/h. * To get km/h multiply this number by 1.00584. */ - static SQInteger GetMaxSpeed(BridgeID bridge_id); + static SQInteger GetMaxSpeed(BridgeType bridge_type); /** * 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 bridge_type The bridge to get the new cost of. * @param length The length of the bridge. * The value will be clamped to 0 .. MAX(int32_t). - * @pre IsValidBridge(bridge_id). + * @pre IsValidBridge(bridge_type). * @return The new cost the bridge has. */ - static Money GetPrice(BridgeID bridge_id, SQInteger length); + static Money GetPrice(BridgeType bridge_type, SQInteger length); /** * Get the maximum length of a bridge. - * @param bridge_id The bridge to get the maximum length of. - * @pre IsValidBridge(bridge_id). + * @param bridge_type The bridge to get the maximum length of. + * @pre IsValidBridge(bridge_type). * @returns The maximum length the bridge has. */ - static SQInteger GetMaxLength(BridgeID bridge_id); + static SQInteger GetMaxLength(BridgeType bridge_type); /** * Get the minimum length of a bridge. - * @param bridge_id The bridge to get the minimum length of. - * @pre IsValidBridge(bridge_id). + * @param bridge_type The bridge to get the minimum length of. + * @pre IsValidBridge(bridge_type). * @returns The minimum length the bridge has. */ - static SQInteger GetMinLength(BridgeID bridge_id); + static SQInteger GetMinLength(BridgeType bridge_type); /** * Internal function to help BuildBridge in case of road. @@ -128,7 +128,7 @@ public: * each end of the bridge, making it easier for you to connect it to your * network. * @param vehicle_type The vehicle-type of bridge to build. - * @param bridge_id The bridge-type to build. + * @param bridge_type The bridge-type to build. * @param start Where to start the bridge. * @param end Where to end the bridge. * @pre ScriptMap::IsValidTile(start). @@ -152,7 +152,7 @@ public: * @note No matter if the road pieces were build or not, if building the * bridge succeeded, this function returns true. */ - static bool BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end); + static bool BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeType bridge_type, TileIndex start, TileIndex end); /** * Removes a bridge, by executing it on either the start or end tile. diff --git a/src/script/api/script_types.hpp b/src/script/api/script_types.hpp index f020427fa2..417c4daacc 100644 --- a/src/script/api/script_types.hpp +++ b/src/script/api/script_types.hpp @@ -21,7 +21,7 @@ * acquired * released * reused - * #BridgeID bridge type + * #BridgeType bridge type * introduction \ref newgrf_changes "(1)" * never \ref newgrf_changes "(1)" * no \ref newgrf_changes "(1)" @@ -110,7 +110,7 @@ #include /* Define all types here, so they are added to the API docs. */ -typedef uint BridgeID; ///< The ID of a bridge type. +typedef uint BridgeType; ///< The ID of a bridge type. typedef uint8_t CargoID; ///< The ID of a cargo. typedef uint16_t EngineID; ///< The ID of an engine. typedef uint16_t GoalID; ///< The ID of a goal.