OpenTTD Source 20261112-master-gbcbec5e63f
OrthogonalTileArea Class Reference

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

#include <tilearea_orthogonal.h>

Inheritance diagram for OrthogonalTileArea:
Airport StationFinder

Data Structures

class  iterator
 Iterator to iterate over a tile area (rectangle) of the map. More...

Public Member Functions

 OrthogonalTileArea (TileIndex tile=INVALID_TILE, uint16_t w=0, uint16_t h=0)
 Construct this tile area with some set values.
 OrthogonalTileArea (TileIndex start, TileIndex end)
 Construct this tile area based on two points.
bool IsEmpty () const
 Test if this tile area is empty.
void Add (TileIndex to_add)
 Add a single tile to a tile area; enlarge if needed.
void Add (const OrthogonalTileArea &area)
 Add another tile area to this tile area.
void Clear ()
 Clears the 'tile area', i.e.
bool Intersects (const OrthogonalTileArea &ta) const
 Does this tile area intersect with another?
bool Contains (TileIndex tile) const
 Does this tile area contain a tile?
OrthogonalTileArea & Expand (int rad)
 Expand a tile area by rad tiles in each direction, keeping within map bounds.
void ClampToMap ()
 Clamp the tile area to map borders.
TileIndex GetCentreTile () const
 Get the centre tile.
iterator begin () const
 Returns an iterator to the start of the tile area.
std::default_sentinel_t end () const
 Returns an iterator to the end of the tile area.

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 16 of file tilearea_orthogonal.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 28 of file tilearea_orthogonal.h.

References h, INVALID_TILE, tile, and w.

Referenced by Add(), Expand(), Intersects(), and OrthogonalTileArea::iterator::iterator().

◆ 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_orthogonal.cpp.

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

Member Function Documentation

◆ Add() [1/2]

void OrthogonalTileArea::Add ( const OrthogonalTileArea & area)
inline

Add another tile area to this tile area.

Parameters
areaThe tile area to add.

Definition at line 47 of file tilearea_orthogonal.h.

References Add(), h, OrthogonalTileArea(), tile, TileAddXY(), and w.

◆ Add() [2/2]

◆ begin()

iterator OrthogonalTileArea::begin ( ) const
inline

Returns an iterator to the start of the tile area.

Returns
The iterator.

Definition at line 147 of file tilearea_orthogonal.h.

◆ ClampToMap()

void OrthogonalTileArea::ClampToMap ( )

Clamp the tile area to map borders.

Definition at line 137 of file tilearea_orthogonal.cpp.

References h, Map::Size(), Map::SizeX(), Map::SizeY(), tile, TileX(), TileY(), and w.

Referenced by CommonRaiseLowerBigLand(), and SmallMapWindow::DrawSmallMapColumn().

◆ Clear()

void OrthogonalTileArea::Clear ( )
inline

Clears the 'tile area', i.e.

make the tile invalid.

Definition at line 57 of file tilearea_orthogonal.h.

References INVALID_TILE.

Referenced by BitmapTileArea::Clear(), RemoveAirport(), RemoveBuoy(), RemoveDock(), and RemoveRoadStop().

◆ 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 99 of file tilearea_orthogonal.cpp.

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

Referenced by BitmapTileArea::Add(), CmdMoveStationName(), CmdMoveWaypointName(), BitmapTileArea::Contains(), WaterRegion::GetLabel(), WaterRegion::GetLocalIndex(), and BitmapTileArea::Remove().

◆ end()

std::default_sentinel_t OrthogonalTileArea::end ( ) const
inline

Returns an iterator to the end of the tile area.

Returns
The iterator.

Definition at line 156 of file tilearea_orthogonal.h.

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 118 of file tilearea_orthogonal.cpp.

References h, OrthogonalTileArea(), Map::SizeX(), Map::SizeY(), tile, TileX(), TileXY(), TileY(), and w.

Referenced by FindSubsidyCargoDestination(), FindSubsidyTownCargoRoute(), ForAllStationsAroundTiles(), GetAcceptanceAroundTiles(), GetProductionAroundTiles(), GetStationAround(), Station::RecomputeCatchment(), and Industry::~Industry().

◆ GetCentreTile()

TileIndex OrthogonalTileArea::GetCentreTile ( ) const
inline

Get the centre tile.

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

Definition at line 73 of file tilearea_orthogonal.h.

References TileAddXY().

Referenced by WaypointWindow::GetCenterTile(), SmallMapWindow::GetStationMiddle(), and IndustryViewWindow::OnClick().

◆ 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_orthogonal.cpp.

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

◆ IsEmpty()

Field Documentation

◆ h

◆ tile

◆ w


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