AIBaseStation Class Reference

Base class for stations and waypoints. More...

#include <ai_basestation.hpp>

Inheritance diagram for AIBaseStation:

AIObject SimpleCountedObject AIStation AIWaypoint

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

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

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< Tpool >::GetIfValid(), BaseStation::owner, and OWNER_NONE.

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

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::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().

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().

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().


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

Generated on Tue Jan 5 21:03:17 2010 for OpenTTD by  doxygen 1.5.6