StationRect Struct Reference

StationRect - used to track station spread out rectangle - cheaper than scanning whole map. More...

#include <base_station_base.h>

Inheritance diagram for StationRect:
Rect

Public Types

enum  StationRectMode { ADD_TEST = 0, ADD_TRY, ADD_FORCE }

Public Member Functions

void MakeEmpty ()
bool PtInExtendedRect (int x, int y, int distance=0) const
 Determines whether a given point (x, y) is within a certain distance of the station rectangle.
bool AreaInExtendedRect (const TileArea &area, int distance=0) const
 Determines whether a tile area intersects the station rectangle with a given offset.
bool IsEmpty () const
CommandCost BeforeAddTile (TileIndex tile, StationRectMode mode)
CommandCost BeforeAddRect (TileIndex tile, int w, int h, StationRectMode mode)
bool AfterRemoveTile (BaseStation *st, TileIndex tile)
bool AfterRemoveRect (BaseStation *st, TileArea ta)
StationRectoperator= (const Rect &src)

Static Public Member Functions

static bool ScanForStationTiles (StationID st_id, int left_a, int top_a, int right_a, int bottom_a)
 Check whether station tiles of the given station id exist in the given rectangle.

Detailed Description

StationRect - used to track station spread out rectangle - cheaper than scanning whole map.

Definition at line 31 of file base_station_base.h.


Member Function Documentation

bool StationRect::AreaInExtendedRect ( const TileArea area,
int  distance = 0 
) const

Determines whether a tile area intersects the station rectangle with a given offset.

Parameters:
area The tile area to test.
distance Offset the station rect is grown on all sides (L1 norm).
Returns:
True if the tile area intersects with the station rectangle.

Definition at line 392 of file station.cpp.

References TileArea::h, TileArea::tile, TileX(), TileY(), and TileArea::w.

Referenced by CYapfDestinationRouteLinkT< Types >::PfDetectDestination().

bool StationRect::PtInExtendedRect ( int  x,
int  y,
int  distance = 0 
) const

Determines whether a given point (x, y) is within a certain distance of the station rectangle.

Note:
x and y are in Tile coordinates
Parameters:
x X coordinate
y Y coordinate
distance The maxmium distance a point may have (L1 norm)
Returns:
true if the point is within distance tiles of the station rectangle

Definition at line 380 of file station.cpp.

bool StationRect::ScanForStationTiles ( StationID  st_id,
int  left_a,
int  top_a,
int  right_a,
int  bottom_a 
) [static]

Check whether station tiles of the given station id exist in the given rectangle.

Parameters:
st_id Station ID to look for in the rectangle
left_a Minimal tile X edge of the rectangle
top_a Minimal tile Y edge of the rectangle
right_a Maximal tile X edge of the rectangle (inclusive)
bottom_a Maximal tile Y edge of the rectangle (inclusive)
Returns:
true if a station tile with the given st_id exists in the rectangle, false otherwise

Definition at line 462 of file station.cpp.

References GetStationIndex(), IsTileType(), MP_STATION, TILE_AREA_LOOP, and TileXY().


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

Generated on Mon May 9 05:20:33 2011 for OpenTTD by  doxygen 1.6.1