OpenTTD Source 20261112-master-gbcbec5e63f
tilearea_airportlayout.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef TILEAREA_AIRPORTLAYOUT_HPP
11#define TILEAREA_AIRPORTLAYOUT_HPP
12
13#include "newgrf_airport.h"
14
17private:
18 std::span<const AirportTileTable> att;
19 std::span<const AirportTileTable>::iterator iter;
23
24public:
26 using difference_type = std::ptrdiff_t;
27 using iterator_category = std::forward_iterator_tag;
28 using pointer = void;
29 using reference = void;
30
38
44 bool operator==(const AirportTileTableIterator &other) const
45 {
46 return this->base_tile == other.base_tile && this->tile == other.tile;
47 }
48
53 bool operator==(const std::default_sentinel_t &) const
54 {
55 return **this == INVALID_TILE;
56 }
57
63 {
64 return this->tile;
65 }
66
72 {
73 do {
74 ++this->iter;
75 if (this->iter == std::end(att)) {
76 this->tile = INVALID_TILE;
77 } else {
78 this->tile = this->base_tile + ToTileIndexDiff(this->iter->ti);
79 }
80 } while (this->tile != INVALID_TILE && !this->include_special && this->GetAirportGfx() == AIRPORTGFX_CLEARTILE_SPECIALCHECK);
81 return *this;
82 }
83
89 {
90 return this->iter->gfx;
91 }
92};
93
94#endif /* TILEAREA_AIRPORTLAYOUT_HPP */
std::ptrdiff_t difference_type
difference_type iterator trait
TileIndex operator*() const
Get the current tile.
TileIndex tile
The current file.
TileIndex base_tile
The tile we base the offsets off.
AirportGfx GetAirportGfx() const
Get the AirportGfx for the current tile.
std::span< const AirportTileTable > att
The offsets.
AirportTileTableIterator & operator++()
Increment the iterator and set it to the next position.
TileIndex value_type
value_type iterator trait
void reference
reference iterator trait
std::span< constAirportTileTable >::iterator iter
Underlying tile area.
bool operator==(const AirportTileTableIterator &other) const
Compare with other iterator.
std::forward_iterator_tag iterator_category
iterator_category iterator trait
void pointer
pointer iterator trait
bool include_special
Include special tiles.
bool operator==(const std::default_sentinel_t &) const
Compare with end sentinel.
AirportTileTableIterator(std::span< const AirportTileTable > att, TileIndex base_tile, bool include_special)
Construct the iterator.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
Definition map_func.h:444
NewGRF handling of airports.
uint16_t AirportGfx
Airport graphics tile.
static constexpr AirportGfx AIRPORTGFX_CLEARTILE_SPECIALCHECK
Sentinel marker in airport layout to perform a clear tile check.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:100