OpenTTD Source  20240915-master-g3784a3d3d6
OrthogonalTileArea Struct Reference

Represents the covered area of e.g. More...

#include <tilearea_type.h>

Inheritance diagram for OrthogonalTileArea:
Airport BitmapTileArea ETileArea StationFinder

Public Member Functions

 OrthogonalTileArea (TileIndex tile=INVALID_TILE, uint16_t w=0, uint16_t 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...
 
OrthogonalTileAreaExpand (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...
 

Data Fields

TileIndex tile
 The base tile of the area.
 
uint16_t w
 The width of the area.
 
uint16_t h
 The height of the area.
 

Detailed Description

Represents the covered area of e.g.

a rail station

Definition at line 18 of file tilearea_type.h.

Constructor & Destructor Documentation

◆ OrthogonalTileArea() [1/2]

OrthogonalTileArea::OrthogonalTileArea ( TileIndex  tile = INVALID_TILE,
uint16_t  w = 0,
uint16_t  h = 0 
)
inline

Construct this tile area with some set values.

Parameters
tilethe base tile
wthe width
hthe height

Definition at line 29 of file tilearea_type.h.

Referenced by end().

◆ OrthogonalTileArea() [2/2]

OrthogonalTileArea::OrthogonalTileArea ( TileIndex  start,
TileIndex  end 
)

Construct this tile area based on two points.

Parameters
startthe start of the area
endthe end of the area

Definition at line 21 of file tilearea.cpp.

References end(), h, Map::Size(), Swap(), tile, TileX(), TileXY(), TileY(), and w.

Member Function Documentation

◆ Add()

void OrthogonalTileArea::Add ( TileIndex  to_add)

Add a single tile to a tile area; enlarge if needed.

Parameters
to_addThe tile to add

Definition at line 43 of file tilearea.cpp.

References h, INVALID_TILE, tile, TileX(), TileXY(), TileY(), and w.

Referenced by CheckForDockingTile().

◆ begin()

OrthogonalTileIterator OrthogonalTileArea::begin ( ) const

Returns an iterator to the beginning of the tile area.

Returns
The OrthogonalTileIterator.

Definition at line 153 of file tilearea.cpp.

◆ Clear()

void OrthogonalTileArea::Clear ( )
inline

Clears the 'tile area', i.e.

make the tile invalid.

Definition at line 40 of file tilearea_type.h.

References INVALID_TILE.

◆ Contains()

bool OrthogonalTileArea::Contains ( TileIndex  tile) const

Does this tile area contain a tile?

Parameters
tileTile to test for.
Returns
True if the tile is inside the area.

Definition at line 104 of file tilearea.cpp.

References h, IsInsideBS(), tile, TileX(), TileY(), and w.

Referenced by BitmapTileArea::ClrTile(), WaterRegion::GetLabel(), WaterRegion::GetLocalIndex(), BitmapTileArea::HasTile(), and BitmapTileArea::SetTile().

◆ end()

OrthogonalTileIterator OrthogonalTileArea::end ( ) const

Returns an iterator to the end of the tile area.

Returns
The OrthogonalTileIterator.

Definition at line 162 of file tilearea.cpp.

References OrthogonalTileArea().

Referenced by OrthogonalTileArea().

◆ Expand()

OrthogonalTileArea & OrthogonalTileArea::Expand ( int  rad)

Expand a tile area by rad tiles in each direction, keeping within map bounds.

Parameters
radNumber of tiles to expand
Returns
The OrthogonalTileArea.

Definition at line 123 of file tilearea.cpp.

Referenced by CheckIfFarEnoughFromConflictingIndustry(), FindSubsidyCargoDestination(), FindSubsidyTownCargoRoute(), ForAllStationsAroundTiles(), GetAcceptanceAroundTiles(), GetProductionAroundTiles(), and Station::RecomputeCatchment().

◆ GetCenterTile()

TileIndex OrthogonalTileArea::GetCenterTile ( ) const
inline

Get the center tile.

Returns
The tile at the center, or just north of it.

Definition at line 59 of file tilearea_type.h.

References TileAddXY().

◆ Intersects()

bool OrthogonalTileArea::Intersects ( const OrthogonalTileArea ta) const

Does this tile area intersect with another?

Parameters
tathe other tile area to check against.
Returns
true if they intersect.

Definition at line 75 of file tilearea.cpp.

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


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