mirror of https://github.com/OpenTTD/OpenTTD
Add: [Script] GSWaypoint::GetOwner
Added method for Game Scripts to retrieve the owner of a waypoint.pull/13405/head
parent
56b1e9df1f
commit
425a75b769
|
@ -21,6 +21,7 @@
|
||||||
* \li GSEventVehicleCrashed::GetVictims
|
* \li GSEventVehicleCrashed::GetVictims
|
||||||
* \li GSEventCompanyRenamed
|
* \li GSEventCompanyRenamed
|
||||||
* \li GSEventPresidentRenamed
|
* \li GSEventPresidentRenamed
|
||||||
|
* \li GSWaypoint::GetOwner
|
||||||
*
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||||
|
|
|
@ -22,6 +22,13 @@
|
||||||
return wp != nullptr && (wp->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || wp->owner == OWNER_NONE);
|
return wp != nullptr && (wp->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || wp->owner == OWNER_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ ScriptCompany::CompanyID ScriptWaypoint::GetOwner(StationID waypoint_id)
|
||||||
|
{
|
||||||
|
if (!IsValidWaypoint(waypoint_id)) return ScriptCompany::COMPANY_INVALID;
|
||||||
|
|
||||||
|
return static_cast<ScriptCompany::CompanyID>((int)::Waypoint::Get(waypoint_id)->owner);
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ StationID ScriptWaypoint::GetWaypointID(TileIndex tile)
|
/* static */ StationID ScriptWaypoint::GetWaypointID(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (!ScriptRail::IsRailWaypointTile(tile) && !ScriptMarine::IsBuoyTile(tile)) return STATION_INVALID;
|
if (!ScriptRail::IsRailWaypointTile(tile) && !ScriptMarine::IsBuoyTile(tile)) return STATION_INVALID;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define SCRIPT_WAYPOINT_HPP
|
#define SCRIPT_WAYPOINT_HPP
|
||||||
|
|
||||||
#include "script_basestation.hpp"
|
#include "script_basestation.hpp"
|
||||||
|
#include "script_company.hpp"
|
||||||
#include "script_error.hpp"
|
#include "script_error.hpp"
|
||||||
#include "../../station_type.h"
|
#include "../../station_type.h"
|
||||||
|
|
||||||
|
@ -53,6 +54,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool IsValidWaypoint(StationID waypoint_id);
|
static bool IsValidWaypoint(StationID waypoint_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the owner of a waypoint.
|
||||||
|
* @param waypoint_id The waypoint to get the owner of.
|
||||||
|
* @pre IsValidWaypoint(waypoint_id).
|
||||||
|
* @return The owner the waypoint has.
|
||||||
|
* @api -ai
|
||||||
|
*/
|
||||||
|
static ScriptCompany::CompanyID GetOwner(StationID waypoint_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the StationID of a tile.
|
* Get the StationID of a tile.
|
||||||
* @param tile The tile to find the StationID of.
|
* @param tile The tile to find the StationID of.
|
||||||
|
|
Loading…
Reference in New Issue