1
0
Fork 0

Add: [Script] GSWaypoint::GetOwner

Added method for Game Scripts to retrieve the owner of a waypoint.
pull/13405/head
SamuXarick 2025-01-30 11:42:44 +00:00
parent 56b1e9df1f
commit 425a75b769
3 changed files with 18 additions and 0 deletions

View File

@ -21,6 +21,7 @@
* \li GSEventVehicleCrashed::GetVictims
* \li GSEventCompanyRenamed
* \li GSEventPresidentRenamed
* \li GSWaypoint::GetOwner
*
* Other changes:
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType

View File

@ -22,6 +22,13 @@
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)
{
if (!ScriptRail::IsRailWaypointTile(tile) && !ScriptMarine::IsBuoyTile(tile)) return STATION_INVALID;

View File

@ -11,6 +11,7 @@
#define SCRIPT_WAYPOINT_HPP
#include "script_basestation.hpp"
#include "script_company.hpp"
#include "script_error.hpp"
#include "../../station_type.h"
@ -53,6 +54,15 @@ public:
*/
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.
* @param tile The tile to find the StationID of.