Change: [Script] GetWaypointID to return the StationID of any waypoint

Modified ScriptWaypoint::GetWaypointID to also return the StationID of any waypoint (including road waypoint).
This commit is contained in:
SamuXarick 2025-01-30 13:28:12 +00:00 committed by rubidium42
parent 3ea4d1d4fc
commit f5d43ffdf8
4 changed files with 6 additions and 4 deletions

View File

@ -24,6 +24,7 @@
*
* Other changes:
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
* \li AIWaypoint::GetWaypointID now returns the StationID of any type of waypoint
*
* \b 14.0
*

View File

@ -24,6 +24,7 @@
*
* Other changes:
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
* \li GSWaypoint::GetWaypointID now returns the StationID of any type of waypoint
*
* \b 14.0
*

View File

@ -24,8 +24,7 @@
/* static */ StationID ScriptWaypoint::GetWaypointID(TileIndex tile)
{
if (!ScriptRail::IsRailWaypointTile(tile) && !ScriptMarine::IsBuoyTile(tile)) return STATION_INVALID;
if (!::IsValidTile(tile) || !::IsTileType(tile, MP_STATION) || ::Waypoint::GetByTile(tile) == nullptr) return INVALID_STATION;
return ::GetStationIndex(tile);
}

View File

@ -54,10 +54,11 @@ public:
static bool IsValidWaypoint(StationID waypoint_id);
/**
* Get the StationID of a tile.
* Get the StationID of a tile, if there is a waypoint.
* @param tile The tile to find the StationID of.
* @pre ScriptRail::IsRailWaypointTile(tile).
* @pre IsValidTile(tile).
* @return StationID of the waypoint.
* @post Use IsValidWaypoint() to see if the waypoint is valid.
*/
static StationID GetWaypointID(TileIndex tile);