mirror of https://github.com/OpenTTD/OpenTTD
Change: [Script] Move GSStation::GetOwner to GSBaseStation::GetOwner (#13406)
* Add: [Script] GSBaseStation::GetOwner Added method for Game Scripts to retrieve the owner of a basestation. * Cleanup: [Script] Remove ScriptStation::GetOwner Due to class inheritance, GSStation::GetOwner and GSWaypoint::GetOwner can both reach GetOwner defined at GSBaseStation.pull/14267/head
parent
467f832c2f
commit
5fef32bde7
|
@ -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
|
||||
|
|
|
@ -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<std::string> ScriptBaseStation::GetName(StationID station_id)
|
||||
{
|
||||
if (!IsValidBaseStation(station_id)) return std::nullopt;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue