OpenTTD Source 20261112-master-gbcbec5e63f
tilearea_airport.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_AIRPORT_HPP
11#define TILEAREA_AIRPORT_HPP
12
13#include "station_base.h"
14#include "tilearea_orthogonal.h"
15
18private:
19 const Station *st = nullptr;
21
22public:
24 using difference_type = std::ptrdiff_t;
25 using iterator_category = std::forward_iterator_tag;
26 using pointer = void;
27 using reference = void;
28
33 AirportTileIterator(const Station *st) : st(st), iter(st->airport)
34 {
35 if (*this->iter != INVALID_TILE && !st->TileBelongsToAirport(*this->iter)) ++this->iter;
36 }
37
43 bool operator==(const AirportTileIterator &other) const
44 {
45 return this->st == other.st && this->iter == other.iter;
46 };
47
52 bool operator==(const std::default_sentinel_t &) const
53 {
54 return **this == INVALID_TILE;
55 }
56
62 {
63 return *this->iter;
64 }
65
71 {
72 do {
73 ++this->iter;
74 } while (*this->iter != INVALID_TILE && !st->TileBelongsToAirport(*this->iter));
75 return *this;
76 }
77};
78
79#endif /* TILEAREA_AIRPORT_HPP */
OrthogonalTileArea::iterator iter
The underlying tile area iterator.
void reference
reference iterator trait
AirportTileIterator & operator++()
Increment the iterator and set it to the next position.
bool operator==(const std::default_sentinel_t &) const
Compare with end sentinel.
void pointer
pointer iterator trait
const Station * st
The station the airport is a part of.
AirportTileIterator(const Station *st)
Construct the iterator.
bool operator==(const AirportTileIterator &other) const
Compare with other iterator.
std::ptrdiff_t difference_type
difference_type iterator trait
std::forward_iterator_tag iterator_category
iterator_category iterator trait
TileIndex operator*() const
Get the current tile.
TileIndex value_type
value_type iterator trait
Iterator to iterate over a tile area (rectangle) of the map.
Base classes/functions for stations.
Station data structure.
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
Type for storing and iterating orthogonal tile areas.