diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index ffb3578ebf..e57e873a14 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -28,6 +28,7 @@ * \li GSCargo::CC_POTABLE * \li GSCargo::CC_NON_POTABLE * \li GSVehicleList_Waypoint + * \li GSBaseStation::GetOwner * * Other changes: * \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType diff --git a/src/script/api/script_basestation.cpp b/src/script/api/script_basestation.cpp index 26a4ca9b45..e7bea4ec29 100644 --- a/src/script/api/script_basestation.cpp +++ b/src/script/api/script_basestation.cpp @@ -28,6 +28,12 @@ return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || st->owner == OWNER_NONE); } +/* static */ ScriptCompany::CompanyID ScriptBaseStation::GetOwner(StationID station_id) +{ + if (!IsValidBaseStation(station_id)) return ScriptCompany::COMPANY_INVALID; + return ScriptCompany::ToScriptCompanyID(::BaseStation::Get(station_id)->owner); +} + /* static */ std::optional ScriptBaseStation::GetName(StationID station_id) { if (!IsValidBaseStation(station_id)) return std::nullopt; diff --git a/src/script/api/script_basestation.hpp b/src/script/api/script_basestation.hpp index c46326cdfb..646bec13ab 100644 --- a/src/script/api/script_basestation.hpp +++ b/src/script/api/script_basestation.hpp @@ -11,6 +11,7 @@ #define SCRIPT_BASESTATION_HPP #include "script_text.hpp" +#include "script_company.hpp" #include "script_date.hpp" #include "../../station_type.h" @@ -32,6 +33,15 @@ public: */ static bool IsValidBaseStation(StationID station_id); + /** + * Get the owner of a basestation. + * @param station_id The basestation to get the owner of. + * @pre IsValidBaseStation(station_id). + * @return The owner the basestation has. + * @api -ai + */ + static ScriptCompany::CompanyID GetOwner(StationID station_id); + /** * Get the name of a basestation. * @param station_id The basestation to get the name of. diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index 551831d633..07100981c2 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -26,13 +26,6 @@ return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || st->owner == OWNER_NONE); } -/* static */ ScriptCompany::CompanyID ScriptStation::GetOwner(StationID station_id) -{ - if (!IsValidStation(station_id)) return ScriptCompany::COMPANY_INVALID; - - return ScriptCompany::ToScriptCompanyID(::Station::Get(station_id)->owner); -} - /* static */ StationID ScriptStation::GetStationID(TileIndex tile) { if (!::IsValidTile(tile) || !::IsTileType(tile, MP_STATION)) return StationID::Invalid(); diff --git a/src/script/api/script_station.hpp b/src/script/api/script_station.hpp index 0c43deef3c..32bd2827ed 100644 --- a/src/script/api/script_station.hpp +++ b/src/script/api/script_station.hpp @@ -59,15 +59,6 @@ public: */ static bool IsValidStation(StationID station_id); - /** - * Get the owner of a station. - * @param station_id The station to get the owner of. - * @pre IsValidStation(station_id). - * @return The owner the station has. - * @api -ai - */ - static ScriptCompany::CompanyID GetOwner(StationID station_id); - /** * Get the StationID of a tile, if there is a station. * @param tile The tile to find the stationID of