mirror of https://github.com/OpenTTD/OpenTTD
Add: [Script] GSBaseStation::GetOwner
Added method for Game Scripts to retrieve the owner of a basestation.pull/13406/head
parent
ad3a34e9ef
commit
bb70dffe70
|
@ -28,6 +28,7 @@
|
||||||
* \li GSCargo::CC_POTABLE
|
* \li GSCargo::CC_POTABLE
|
||||||
* \li GSCargo::CC_NON_POTABLE
|
* \li GSCargo::CC_NON_POTABLE
|
||||||
* \li GSVehicleList_Waypoint
|
* \li GSVehicleList_Waypoint
|
||||||
|
* \li GSBaseStation::GetOwner
|
||||||
*
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||||
|
|
|
@ -28,6 +28,12 @@
|
||||||
return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || st->owner == OWNER_NONE);
|
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)
|
/* static */ std::optional<std::string> ScriptBaseStation::GetName(StationID station_id)
|
||||||
{
|
{
|
||||||
if (!IsValidBaseStation(station_id)) return std::nullopt;
|
if (!IsValidBaseStation(station_id)) return std::nullopt;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define SCRIPT_BASESTATION_HPP
|
#define SCRIPT_BASESTATION_HPP
|
||||||
|
|
||||||
#include "script_text.hpp"
|
#include "script_text.hpp"
|
||||||
|
#include "script_company.hpp"
|
||||||
#include "script_date.hpp"
|
#include "script_date.hpp"
|
||||||
#include "../../station_type.h"
|
#include "../../station_type.h"
|
||||||
|
|
||||||
|
@ -32,6 +33,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool IsValidBaseStation(StationID station_id);
|
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.
|
* Get the name of a basestation.
|
||||||
* @param station_id The basestation to get the name of.
|
* @param station_id The basestation to get the name of.
|
||||||
|
|
Loading…
Reference in New Issue