OpenTTD Source 20250905-master-g122023be8d
station_layout_type.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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef STATION_LAYOUT_TYPE_H
11#define STATION_LAYOUT_TYPE_H
12
13#include "newgrf_station.h"
14#include "station_map.h"
15
17private:
18 std::span<const StationGfx> layout{};
19 uint platforms;
20 uint length;
21public:
22 RailStationTileLayout(const StationSpec *spec, uint8_t platforms, uint8_t length);
23
24 class Iterator {
26 uint position = 0;
27 public:
28 using value_type = StationGfx;
29 using difference_type = std::ptrdiff_t;
30 using iterator_category = std::forward_iterator_tag;
31 using pointer = void;
32 using reference = void;
33
35
36 bool operator==(const Iterator &rhs) const { return this->position == rhs.position; }
37 bool operator==(const std::default_sentinel_t &) const { return this->position == this->stl.platforms * this->stl.length; }
38
39 StationGfx operator*() const;
40
41 Iterator &operator++()
42 {
43 ++this->position;
44 return *this;
45 }
46
47 Iterator operator++(int)
48 {
49 Iterator result = *this;
50 ++*this;
51 return result;
52 }
53 };
54
55 Iterator begin() const { return Iterator(*this); }
56 std::default_sentinel_t end() const { return std::default_sentinel_t(); }
57};
58
59#endif /* STATION_LAYOUT_TYPE_H */
uint position
Position within iterator.
const RailStationTileLayout & stl
Station tile layout being iterated.
uint length
Length of platforms.
uint platforms
Number of platforms.
std::span< const StationGfx > layout
Predefined tile layout.
uint8_t StationGfx
Copy from station_map.h.
Header file for NewGRF stations.
Maps accessors for stations.
Station specification.