OpenTTD Source: StationFinder Class Reference

OpenTTD Source 12.2

Public Member Functions | Private Attributes
StationFinder Class Reference

Structure contains cached list of stations nearby. More...

`#include <station_type.h>`

Inheritance diagram for StationFinder:

## Public Member Functions
| StationFinder (const TileArea &area)
| Constructs StationFinder. More...
const StationList * | GetStations ()
| Run a tile loop to find stations around a tile, on demand. More...

## Private Attributes
StationList | stations
| List of stations nearby.
Private Attributes inherited from OrthogonalTileArea
TileIndex | tile
| The base tile of the area.
uint16 | w
| The width of the area.
uint16 | h
| The height of the area.

## Additional Inherited Members
Private Member Functions inherited from OrthogonalTileArea
| OrthogonalTileArea (TileIndex tile=INVALID_TILE, uint8 w=0, uint8 h=0)
| Construct this tile area with some set values. More...
| OrthogonalTileArea (TileIndex start, TileIndex end)
| Construct this tile area based on two points. More...
void | Add (TileIndex to_add)
| Add a single tile to a tile area; enlarge if needed. More...
void | Clear ()
| Clears the 'tile area', i.e. More...
bool | Intersects (const OrthogonalTileArea &ta) const
| Does this tile area intersect with another? More...
bool | Contains (TileIndex tile) const
| Does this tile area contain a tile? More...
OrthogonalTileArea & | Expand (int rad)
| Expand a tile area by rad tiles in each direction, keeping within map bounds. More...
void | ClampToMap ()
| Clamp the tile area to map borders.
TileIndex | GetCenterTile () const
| Get the center tile. More...
OrthogonalTileIterator | begin () const
| Returns an iterator to the beginning of the tile area. More...
OrthogonalTileIterator | end () const
| Returns an iterator to the end of the tile area. More...

## Detailed Description

Structure contains cached list of stations nearby.

The list is created upon first call to GetStations()

Definition at line 100 of file station_type.h.

## Constructor & Destructor Documentation

## ◆ StationFinder()

StationFinder::StationFinder | ( | const TileArea & | area | ) |
| inline

Constructs StationFinder.

Parameters

  area | the area to search from

Definition at line 107 of file station_type.h.

## Member Function Documentation

## ◆ GetStations()

const StationList * StationFinder::GetStations | ( |  | ) |

Run a tile loop to find stations around a tile, on demand.

Cache the result for further requests

Returns
  pointer to a StationList containing all stations found

Definition at line 3985 of file station_cmd.cpp.

References OrthogonalTileArea::h, INVALID_TILE, IsTileType(), MP_HOUSE, and OrthogonalTileArea::w.

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

- src/station_type.h
- src/station_cmd.cpp