OpenTTD Source 20250205-master-gfd85ab1e2c
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
14#include "tilearea_type.h"
15
16typedef uint16_t StationID;
17typedef uint16_t RoadStopID;
18
19struct BaseStation;
20struct Station;
21struct RoadStop;
22struct StationSpec;
23struct Waypoint;
24
25static const StationID NEW_STATION = 0xFFFD;
26static const StationID ADJACENT_STATION = 0xFFFE;
27static const StationID INVALID_STATION = 0xFFFF;
28
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 StationFacility : uint8_t {
55 FACIL_TRAIN = 1 << 0,
57 FACIL_BUS_STOP = 1 << 2,
58 FACIL_AIRPORT = 1 << 3,
59 FACIL_DOCK = 1 << 4,
60 FACIL_WAYPOINT = 1 << 7,
61};
63
64
65static constexpr StationFacility FACIL_GHOST{1U << 6};
66
70 HVOT_TRAIN = 1 << 1,
71 HVOT_BUS = 1 << 2,
72 HVOT_TRUCK = 1 << 3,
73 HVOT_AIRCRAFT = 1 << 4,
74 HVOT_SHIP = 1 << 5,
75
76 HVOT_WAYPOINT = 1 << 6,
77};
79
80/* The different catchment area sizes. */
81static constexpr uint CA_NONE = 0;
82static constexpr uint CA_BUS = 3;
83static constexpr uint CA_TRUCK = 3;
84static constexpr uint CA_TRAIN = 4;
85static constexpr uint CA_DOCK = 5;
86
87static constexpr uint CA_UNMODIFIED = 4;
88
89static constexpr uint MAX_CATCHMENT = 10;
90
91static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
92
94 bool operator() (const Station *lhs, const Station *rhs) const;
95};
96
98typedef std::set<Station *, StationCompare> StationList;
99
106public:
111 StationFinder(const TileArea &area) : TileArea(area) {}
112 const StationList &GetStations();
113};
114
115#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:68
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.
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.
@ FACIL_DOCK
Station with a dock.
@ FACIL_BUS_STOP
Station with bus stops.
@ FACIL_AIRPORT
Station with an airport.
@ FACIL_WAYPOINT
Station is a waypoint.
@ FACIL_TRUCK_STOP
Station with truck stops.
@ FACIL_TRAIN
Station with train station.
@ FACIL_NONE
The station has no facilities at all.
static constexpr uint CA_NONE
Catchment when the station has no facilities.
StationType
Station types.
static constexpr StationFacility FACIL_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
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.
Representation of a waypoint.
Type for storing the 'area' of something uses on the map.