OpenTTD Source 20250312-master-gcdcc6b491d
station_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_TYPE_H
11#define STATION_TYPE_H
12
13#include "core/pool_type.hpp"
15#include "tilearea_type.h"
16
18static constexpr StationID NEW_STATION{0xFFFD};
19static constexpr StationID ADJACENT_STATION{0xFFFE};
20
22
23struct BaseStation;
24struct Station;
25struct RoadStop;
26struct StationSpec;
27struct Waypoint;
28
29using StationIDStack = SmallStack<StationID::BaseType, StationID::BaseType, StationID::Invalid().base(), 8, StationID::End().base()>;
30
32enum class StationType : uint8_t {
33 Rail,
34 Airport,
35 Truck,
36 Bus,
37 Oilrig,
38 Dock,
39 Buoy,
40 RailWaypoint,
41 RoadWaypoint,
42 End,
43};
44
46enum class RoadStopType : uint8_t {
47 Bus,
48 Truck,
49 End,
50};
51
53enum class StationFacility : uint8_t {
54 Train = 0,
55 TruckStop = 1,
56 BusStop = 2,
57 Airport = 3,
58 Dock = 4,
59 Waypoint = 7,
60};
62
65
69 HVOT_TRAIN = 1 << 1,
70 HVOT_BUS = 1 << 2,
71 HVOT_TRUCK = 1 << 3,
72 HVOT_AIRCRAFT = 1 << 4,
73 HVOT_SHIP = 1 << 5,
74
75 HVOT_WAYPOINT = 1 << 6,
76};
78
79/* The different catchment area sizes. */
80static constexpr uint CA_NONE = 0;
81static constexpr uint CA_BUS = 3;
82static constexpr uint CA_TRUCK = 3;
83static constexpr uint CA_TRAIN = 4;
84static constexpr uint CA_DOCK = 5;
85
86static constexpr uint CA_UNMODIFIED = 4;
87
88static constexpr uint MAX_CATCHMENT = 10;
89
90static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
91
93 bool operator() (const Station *lhs, const Station *rhs) const;
94};
95
97typedef std::set<Station *, StationCompare> StationList;
98
105public:
110 StationFinder(const TileArea &area) : TileArea(area) {}
111 const StationList &GetStations();
112};
113
114#endif /* STATION_TYPE_H */
Minimal stack that uses a pool to avoid pointers.
Structure contains cached list of stations nearby.
const StationList & GetStations()
Run a tile loop to find stations around a tile, on demand.
StationList stations
List of stations nearby.
StationFinder(const TileArea &area)
Constructs StationFinder.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:70
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Minimal stack that uses a pool to avoid pointers and doesn't allocate any heap memory if there is onl...
static constexpr uint CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
RoadStopType
Types of RoadStops.
static constexpr StationFacility STATION_FACILITY_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
StationHadVehicleOfType
The vehicles that may have visited a station.
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
@ HVOT_TRUCK
Station has seen a truck.
@ HVOT_NONE
Station has seen no vehicles.
@ HVOT_AIRCRAFT
Station has seen an aircraft.
@ HVOT_BUS
Station has seen a bus.
@ HVOT_SHIP
Station has seen a ship.
@ HVOT_TRAIN
Station has seen a train.
StationFacility
The facilities a station might be having.
@ TruckStop
Station with truck stops.
@ BusStop
Station with bus stops.
static constexpr uint CA_NONE
Catchment when the station has no facilities.
StationType
Station types.
static constexpr uint MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
static constexpr uint CA_BUS
Catchment for bus stops with "modified catchment" enabled.
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
std::set< Station *, StationCompare > StationList
List of stations.
static constexpr uint CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
All airport-related information.
Base class for all station-ish types.
Represents the covered area of e.g.
A Stop for a Road Vehicle.
Station specification.
Station data structure.
'Train' is either a loco or a wagon.
Definition train.h:90
Representation of a waypoint.
Type for storing the 'area' of something uses on the map.