# AIWaypoint Class Reference

Class that handles all waypoint related functions. More...

`#include <ai_waypoint.hpp>`

Inheritance diagram for AIWaypoint:

## Public Types
enum | SpecialWaypointIDs { WAYPOINT_INVALID = 0xFFFF }
## Static Public Member Functions
static const char * | GetClassName ()
static bool | IsValidWaypoint (WaypointID waypoint_id)
| Checks whether the given waypoint is valid and owned by you.
static WaypointID | GetWaypointID (TileIndex tile)
| Get the WaypointID of a tile.
static char * | GetName (WaypointID waypoint_id)
| Get the name of a waypoint.
static bool | SetName (WaypointID waypoint_id, const char *name)
| Set the name this waypoint.
static TileIndex | GetLocation (WaypointID waypoint_id)
| Get the current location of a waypoint.

## Detailed Description

Class that handles all waypoint related functions.

Definition at line 14 of file ai_waypoint.hpp.

## Member Enumeration Documentation

enum AIWaypoint::SpecialWaypointIDs

Enumerator:

  WAYPOINT_INVALID | An invalid WaypointID.

Definition at line 18 of file ai_waypoint.hpp.

## Member Function Documentation

bool AIWaypoint::IsValidWaypoint | ( | WaypointID | waypoint_id | ) | `[static]`

Checks whether the given waypoint is valid and owned by you.

Parameters:

  | waypoint_id | The waypoint to check.

Returns:
  True if and only if the waypoint is valid.

Definition at line 15 of file ai_waypoint.cpp.

Referenced by GetLocation(), GetName(), and SetName().

WaypointID AIWaypoint::GetWaypointID | ( | TileIndex | tile | ) | `[static]`

Get the WaypointID of a tile.

Parameters:

  | tile | The tile to find the WaypointID of.

Precondition:
  AIRail::IsRailWaypointTile(tile).

Returns:
  WaypointID of the waypoint.

Definition at line 20 of file ai_waypoint.cpp.

References GetWaypointIndex(), AIRail::IsRailWaypointTile(), and WAYPOINT_INVALID.

char * AIWaypoint::GetName | ( | WaypointID | waypoint_id | ) | `[static]`

Get the name of a waypoint.

Parameters:

  | waypoint_id | The waypoint to get the name of.

Precondition:
  IsValidWaypoint(waypoint_id).

Returns:
  The name of the waypoint.

Definition at line 27 of file ai_waypoint.cpp.

References IsValidWaypoint().

bool AIWaypoint::SetName | ( | WaypointID | waypoint_id,
|  | const char * | name |
| ) |  |  | `[static]`

Set the name this waypoint.

Parameters:

  | waypoint_id | The waypoint to set the name of.
  | name | The new name of the waypoint.

Precondition:
  IsValidWaypointwaypoint_id).

  'name' must have at least one character.

  'name' must have at most 30 characters.

Exceptions:

  | AIError::ERR_NAME_IS_NOT_UNIQUE |

Returns:
  True if the name was changed.

Definition at line 39 of file ai_waypoint.cpp.

References CMD_RENAME_WAYPOINT, AIObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, AIError::ERR_PRECONDITION_STRING_TOO_LONG, IsValidWaypoint(), MAX_LENGTH_WAYPOINT_NAME_BYTES, and StrEmpty().

TileIndex AIWaypoint::GetLocation | ( | WaypointID | waypoint_id | ) | `[static]`

Get the current location of a waypoint.

Parameters:

  | waypoint_id | The waypoint to get the location of.

Precondition:
  IsValidWaypoint(waypoint_id).

Returns:
  The tile the waypoint is currently on.

Definition at line 48 of file ai_waypoint.cpp.

References INVALID_TILE, and IsValidWaypoint().

The documentation for this class was generated from the following files:

- src/ai/api/ai_waypoint.hpp
- src/ai/api/ai_waypoint.cpp