OpenTTD Source 20261112-master-gbcbec5e63f
BitmapTileArea Class Reference

Represents a tile area containing containing individually set tiles. More...

#include <tilearea_bitmap.h>

Data Structures

class  iterator
 Iterator to iterate over all tiles belonging to a BitmapTileArea. More...

Public Member Functions

 BitmapTileArea ()=default
 Construct an empty bitmap tile area.
 BitmapTileArea (const OrthogonalTileArea &ta)
 Construct this BitmapTileArea from an OrthogonalTileArea.
void Clear ()
 Reset and clear the BitmapTileArea.
bool IsEmpty () const
 Test if this tile area is empty.
void Initialize (const OrthogonalTileArea &ta)
 Initialize the BitmapTileArea with the specified OrthogonalTileArea.
void Add (TileIndex tile)
 Add a tile as part of the tile area.
void Remove (TileIndex tile)
 Remove a tile from the tile area.
bool Contains (TileIndex tile) const
 Test if a tile is part of the tile area.
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.

Private Member Functions

uint Index (TileIndex tile) const
 Get the internal index for the given tile.

Private Attributes

std::vector< bool > data
 Storage of tiles contained within the tile area.
OrthogonalTileArea ta {INVALID_TILE, 0, 0}
 Underlying tile area.

Detailed Description

Represents a tile area containing containing individually set tiles.

Each tile must be contained within the preallocated area. A std::vector<bool> is used to mark which tiles are contained.

Definition at line 19 of file tilearea_bitmap.h.

Constructor & Destructor Documentation

◆ BitmapTileArea()

BitmapTileArea::BitmapTileArea ( const OrthogonalTileArea & ta)
explicit

Construct this BitmapTileArea from an OrthogonalTileArea.

Parameters
taThe orthogonal tile area.

Definition at line 20 of file tilearea_bitmap.cpp.

References data, ta, and OrthogonalTileArea::w.

Member Function Documentation

◆ Add()

void BitmapTileArea::Add ( TileIndex tile)
inline

Add a tile as part of the tile area.

Parameters
tileTile to add.

Definition at line 59 of file tilearea_bitmap.h.

References OrthogonalTileArea::Contains(), and Index().

◆ begin()

iterator BitmapTileArea::begin ( ) const
inline

Returns an iterator to the start of the tile area.

Returns
The iterator.

Definition at line 152 of file tilearea_bitmap.h.

◆ Clear()

void BitmapTileArea::Clear ( )
inline

Reset and clear the BitmapTileArea.

Definition at line 46 of file tilearea_bitmap.h.

References OrthogonalTileArea::Clear().

◆ Contains()

bool BitmapTileArea::Contains ( TileIndex tile) const
inline

Test if a tile is part of the tile area.

Parameters
tileTile to check.
Returns
true iff the tile is in this area.

Definition at line 80 of file tilearea_bitmap.h.

References OrthogonalTileArea::Contains(), and Index().

Referenced by BitmapTileArea::iterator::iterator(), and BitmapTileArea::iterator::operator++().

◆ end()

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

Returns an iterator to the end of the tile area.

Returns
The iterator.

Definition at line 161 of file tilearea_bitmap.h.

◆ Index()

uint BitmapTileArea::Index ( TileIndex tile) const
inlineprivate

Get the internal index for the given tile.

Parameters
tileThe tile.
Returns
The internal index.

Definition at line 29 of file tilearea_bitmap.h.

References OrthogonalTileArea::tile, TileIndexToTileIndexDiffC(), and OrthogonalTileArea::w.

Referenced by Add(), Contains(), and Remove().

◆ Initialize()

void BitmapTileArea::Initialize ( const OrthogonalTileArea & ta)

Initialize the BitmapTileArea with the specified OrthogonalTileArea.

Parameters
taThe tile area.

Definition at line 40 of file tilearea_bitmap.cpp.

References data, OrthogonalTileArea::h, ta, OrthogonalTileArea::tile, and OrthogonalTileArea::w.

◆ IsEmpty()

bool BitmapTileArea::IsEmpty ( ) const

Test if this tile area is empty.

Returns
true iff the tile area is empty.

Definition at line 29 of file tilearea_bitmap.cpp.

References data, and ta.

◆ Remove()

void BitmapTileArea::Remove ( TileIndex tile)
inline

Remove a tile from the tile area.

Parameters
tileTile to clear

Definition at line 69 of file tilearea_bitmap.h.

References OrthogonalTileArea::Contains(), and Index().

Field Documentation

◆ data

std::vector<bool> BitmapTileArea::data
private

Storage of tiles contained within the tile area.

Definition at line 21 of file tilearea_bitmap.h.

Referenced by BitmapTileArea(), Initialize(), and IsEmpty().

◆ ta

OrthogonalTileArea BitmapTileArea::ta {INVALID_TILE, 0, 0}
private

Underlying tile area.

Definition at line 22 of file tilearea_bitmap.h.

Referenced by BitmapTileArea(), BitmapTileArea(), Initialize(), IsEmpty(), and BitmapTileArea::iterator::iterator().


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