# AIBaseStation Class Reference

Base class for stations and waypoints. More...

`#include <ai_basestation.hpp>`

Inheritance diagram for AIBaseStation:

## Public Types

enum | SpecialStationIDs { STATION_NEW = 0xFFFD, STATION_JOIN_ADJACENT = 0xFFFE, STATION_INVALID = 0xFFFF }
| Special station IDs for building adjacent/new stations when the adjacent/distant join features are enabled. More...

## Static Public Member Functions

static const char * | GetClassName ()
static bool | IsValidBaseStation (StationID station_id)
| Checks whether the given basestation is valid and owned by you.
static char * | GetName (StationID station_id)
| Get the name of a basestation.
static bool | SetName (StationID station_id, const char *name)
| Set the name this basestation.
static TileIndex | GetLocation (StationID station_id)
| Get the current location of a basestation.
static int32 | GetConstructionDate (StationID station_id)
| Get the last date a station part was added to this station.

## Detailed Description

Base class for stations and waypoints.

Definition at line 21 of file ai_basestation.hpp.

## Member Enumeration Documentation

enum AIBaseStation::SpecialStationIDs

Special station IDs for building adjacent/new stations when the adjacent/distant join features are enabled.

Enumerator:

  STATION_NEW | Build a new station.
  STATION_JOIN_ADJACENT | Join an neighbouring station if one exists.
  STATION_INVALID | Invalid station id.

Definition at line 29 of file ai_basestation.hpp.

## Member Function Documentation

int32 AIBaseStation::GetConstructionDate | ( | StationID | station_id | ) | `[static]`

Get the last date a station part was added to this station.

Parameters:

  | station_id | The station to look at.

Returns:
  The last date some part of this station was build.

Definition at line 54 of file ai_basestation.cpp.

References IsValidBaseStation().

TileIndex AIBaseStation::GetLocation | ( | StationID | station_id | ) | `[static]`

Get the current location of a basestation.

Parameters:

  | station_id | The basestation to get the location of.

Precondition:
  IsValidBaseStation(station_id).

Returns:
  The tile the basestation is currently on.

Definition at line 47 of file ai_basestation.cpp.

References INVALID_TILE, and IsValidBaseStation().

Referenced by AIStation::GetDistanceManhattanToTile(), AIStation::GetDistanceSquareToTile(), and AIStation::IsWithinTownInfluence().

char * AIBaseStation::GetName | ( | StationID | station_id | ) | `[static]`

Get the name of a basestation.

Parameters:

  | station_id | The basestation to get the name of.

Precondition:
  IsValidBaseStation(station_id).

Returns:
  The name of the station.

Definition at line 26 of file ai_basestation.cpp.

References IsValidBaseStation(), SpecializedStation< Station, false >::IsValidID(), and SetDParam().

bool AIBaseStation::IsValidBaseStation | ( | StationID | station_id | ) | `[static]`

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

Parameters:

  | station_id | The station to check.

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

Note:
  IsValidBaseStation == (IsValidStation || IsValidWaypoint).

Definition at line 20 of file ai_basestation.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_station_pool >::GetIfValid(), BaseStation::owner, and OWNER_NONE.

Referenced by AIVehicleList_Station::AIVehicleList_Station(), GetConstructionDate(), GetLocation(), GetName(), and SetName().

bool AIBaseStation::SetName | ( | StationID | station_id,
|  | const char * | name |
| ) |  |  | `[static]`

Set the name this basestation.

Parameters:

  | station_id | The basestation to set the name of.
  | name | The new name of the station.

Precondition:
  IsValidBaseStation(station_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 38 of file ai_basestation.cpp.

References CMD_RENAME_STATION, CMD_RENAME_WAYPOINT, AIObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, AIError::ERR_PRECONDITION_STRING_TOO_LONG, IsValidBaseStation(), SpecializedStation< Station, false >::IsValidID(), MAX_LENGTH_STATION_NAME_BYTES, and StrEmpty().

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

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