OpenTTD
Public Member Functions | Data Fields
OrthogonalTileArea Struct Reference

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

#include <tilearea_type.h>

Inheritance diagram for OrthogonalTileArea:
Airport ETileArea StationFinder

Public Member Functions

 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...
 
void ClampToMap ()
 Clamp the tile area to map borders.
 
TileIndex GetCenterTile () const
 Get the center tile. More...
 

Data Fields

TileIndex tile
 The base tile of the area.
 
uint16 w
 The width of the area.
 
uint16 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,
uint8  w = 0,
uint8  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.

References Add().

Referenced by OrthogonalTileIterator::OrthogonalTileIterator().

◆ 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 23 of file tilearea.cpp.

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 45 of file tilearea.cpp.

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

Referenced by OrthogonalTileArea().

◆ 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 ClampToMap(), Contains(), Intersects(), and 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 106 of file tilearea.cpp.

References w.

Referenced by TileMatrix< uint32, 4 >::Add(), Clear(), and DiagonalTileArea::Clear().

◆ GetCenterTile()

TileIndex OrthogonalTileArea::GetCenterTile ( ) const
inline

Get the center tile.

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

Definition at line 57 of file tilearea_type.h.

References TILE_ADDXY.

◆ 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 77 of file tilearea.cpp.

References w.

Referenced by Clear().


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