OpenTTD Source  20241108-master-g80f628063a
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. More...
 
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)
 
- Public Member Functions inherited from Rect
int Width () const
 Get width of Rect. More...
 
int Height () const
 Get height of Rect. More...
 
Rect Shrink (int s) const
 Copy and shrink Rect by s pixels. More...
 
Rect Shrink (int h, int v) const
 Copy and shrink Rect by h horizontal and v vertical pixels. More...
 
Rect Shrink (int left, int top, int right, int bottom) const
 Copy and shrink Rect by pixels. More...
 
Rect Shrink (const RectPadding &other) const
 Copy and shrink Rect by a RectPadding. More...
 
Rect Shrink (const RectPadding &horz, const RectPadding &vert) const
 Copy and shrink Rect by a different horizontal and vertical RectPadding. More...
 
Rect Expand (int s) const
 Copy and expand Rect by s pixels. More...
 
Rect Expand (const RectPadding &other) const
 Copy and expand Rect by a RectPadding. More...
 
Rect Translate (int x, int y) const
 Copy and translate Rect by x,y pixels. More...
 
Rect WithWidth (int width, bool end) const
 Copy Rect and set its width. More...
 
Rect Indent (int indent, bool end) const
 Copy Rect and indent it from its position. More...
 
Rect WithHeight (int height, bool end=false) const
 Copy Rect and set its height. More...
 
bool Contains (const Point &pt) const
 Test if a point falls inside this Rect. More...
 

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. More...
 

Additional Inherited Members

- Data Fields inherited from Rect
int left
 
int top
 
int right
 
int bottom
 

Detailed Description

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

Definition at line 36 of file base_station_base.h.

Member Function Documentation

◆ PtInExtendedRect()

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
xX coordinate
yY coordinate
distanceThe maximum distance a point may have (L1 norm)
Returns
true if the point is within distance tiles of the station rectangle

Definition at line 560 of file station.cpp.

◆ ScanForStationTiles()

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_idStation ID to look for in the rectangle
left_aMinimal tile X edge of the rectangle
top_aMinimal tile Y edge of the rectangle
right_aMaximal tile X edge of the rectangle (inclusive)
bottom_aMaximal 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 625 of file station.cpp.

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


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