OpenTTD Source 20250523-master-g321f7e8683
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
89
91enum class StationAnimationTrigger : uint8_t {
92 Built,
93 NewCargo,
99 TileLoop,
101 End
102};
104
106enum class AirportAnimationTrigger : uint8_t {
107 Built,
108 TileLoop,
109 NewCargo,
110 CargoTaken,
113};
115
116/* The different catchment area sizes. */
117static constexpr uint CA_NONE = 0;
118static constexpr uint CA_BUS = 3;
119static constexpr uint CA_TRUCK = 3;
120static constexpr uint CA_TRAIN = 4;
121static constexpr uint CA_DOCK = 5;
122
123static constexpr uint CA_UNMODIFIED = 4;
124
125static constexpr uint MAX_CATCHMENT = 10;
126
127static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
128
130 bool operator() (const Station *lhs, const Station *rhs) const;
131};
132
134typedef std::set<Station *, StationCompare> StationList;
135
142public:
147 StationFinder(const TileArea &area) : TileArea(area) {}
148 const StationList &GetStations();
149};
150
151#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 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.
StationRandomTrigger
Randomisation triggers for stations and roadstops.
@ VehicleArrives
Trigger platform when train arrives.
@ NewCargo
Trigger station on new cargo arrival.
@ PathReservation
Trigger platform when train reserves path.
@ VehicleDeparts
Trigger platform when train leaves.
@ CargoTaken
Trigger station when cargo is completely taken.
@ VehicleLoads
Trigger platform when train loads/unloads.
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.
StationAnimationTrigger
Animation triggers for stations and roadstops.
@ Built
Trigger tile when built.
@ TileLoop
Trigger in the periodic tile loop.
@ AcceptanceTick
Trigger station every 250 ticks.
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'.
AirportAnimationTrigger
Animation triggers for airport tiles.
@ AirplaneTouchdown
Triggered when an airplane (not a helicopter) touches down at the airport (for single tile).
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:91
Representation of a waypoint.
Type for storing the 'area' of something uses on the map.