OpenTTD Source: src/station_type.h Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef STATION_TYPE_H
11#define STATION_TYPE_H
12
13#include "core/pool_type.hpp"
14#include "tilearea_type.h"
15
16using StationID = PoolID<uint16_t, struct StationIDTag, 64000, 0xFFFF>;
17static constexpr StationID NEW_STATION{0xFFFD};
18static constexpr StationID ADJACENT_STATION{0xFFFE};
19
20using RoadStopID = PoolID<uint16_t, struct RoadStopIDTag, 64000, 0xFFFF>;
21
22struct BaseStation;
23struct Station;
24struct RoadStop;
25struct StationSpec;
26struct Waypoint;
27
29 enum class StationType : uint8_t {
30 Rail,
31 Airport,
32 Truck,
33 Bus,
34 Oilrig,
35 Dock,
36 Buoy,
37 RailWaypoint,
38 RoadWaypoint,
39 End,
40};
41
43 enum class RoadStopType : uint8_t {
44 Bus,
45 Truck,
46 End,
47};
48
50 enum class StationFacility : uint8_t {
51 Train = 0,
52 TruckStop = 1,
53 BusStop = 2,
54 Airport = 3,
55 Dock = 4,
56 Waypoint = 7,
57};
58using StationFacilities = EnumBitSet<StationFacility, uint8_t>;
59
61 static constexpr StationFacility STATION_FACILITY_GHOST{6};
62
64 enum StationHadVehicleOfType : uint8_t {
65 HVOT_NONE = 0,
66 HVOT_TRAIN = 1 << 1,
67 HVOT_BUS = 1 << 2,
68 HVOT_TRUCK = 1 << 3,
69 HVOT_AIRCRAFT = 1 << 4,
70 HVOT_SHIP = 1 << 5,
71
72 HVOT_WAYPOINT = 1 << 6,
73};
74 DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType)
75
76
77enum class StationRandomTrigger : uint8_t {
78 NewCargo,
79 CargoTaken,
80 VehicleArrives,
81 VehicleDeparts,
82 VehicleLoads,
83 PathReservation,
84};
85using StationRandomTriggers = EnumBitSet<StationRandomTrigger, uint8_t>;
86
88 enum class StationAnimationTrigger : uint8_t {
89 Built,
90 NewCargo,
91 CargoTaken,
92 VehicleArrives,
93 VehicleDeparts,
94 VehicleLoads,
95 AcceptanceTick,
96 TileLoop,
97 PathReservation,
98 End
99};
100using StationAnimationTriggers = EnumBitSet<StationAnimationTrigger, uint16_t>;
101
103 enum class AirportAnimationTrigger : uint8_t {
104 Built,
105 TileLoop,
106 NewCargo,
107 CargoTaken,
108 AcceptanceTick,
109 AirplaneTouchdown,
110};
111using AirportAnimationTriggers = EnumBitSet<AirportAnimationTrigger, uint8_t>;
112
113/* The different catchment area sizes. */
114 static constexpr uint CA_NONE = 0;
115 static constexpr uint CA_BUS = 3;
116 static constexpr uint CA_TRUCK = 3;
117 static constexpr uint CA_TRAIN = 4;
118 static constexpr uint CA_DOCK = 5;
119
120 static constexpr uint CA_UNMODIFIED = 4;
121
122 static constexpr uint MAX_CATCHMENT = 10;
123
124 static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
125
126 struct StationCompare {
127 bool operator() (const Station *lhs, const Station *rhs) const;
128};
129
131 typedef std::set<Station *, StationCompare> StationList;
132
137 class StationFinder : TileArea {
138 StationList stations;
139public:
144 StationFinder(const TileArea &area) : TileArea(area) {}
145 const StationList &GetStations();
146};
147
148#endif /* STATION_TYPE_H */
EnumBitSet< StationFacility, uint8_t >
StationFinder
Structure contains cached list of stations nearby.
Definition station_type.h:137
StationFinder::GetStations
const StationList & GetStations()
Run a tile loop to find stations around a tile, on demand.
Definition station_cmd.cpp:4545
StationFinder::stations
StationList stations
List of stations nearby.
Definition station_type.h:138
StationFinder::StationFinder
StationFinder(const TileArea &area)
Constructs StationFinder.
Definition station_type.h:144
CommandType::End
@ End
End marker.
DECLARE_ENUM_AS_BIT_SET
#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:119
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
CA_TRAIN
static constexpr uint CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition station_type.h:117
RoadStopType
RoadStopType
Types of RoadStops.
Definition station_type.h:43
STATION_FACILITY_GHOST
static constexpr StationFacility STATION_FACILITY_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
Definition station_type.h:61
StationHadVehicleOfType
StationHadVehicleOfType
The vehicles that may have visited a station.
Definition station_type.h:64
HVOT_WAYPOINT
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
Definition station_type.h:72
HVOT_TRUCK
@ HVOT_TRUCK
Station has seen a truck.
Definition station_type.h:68
HVOT_NONE
@ HVOT_NONE
Station has seen no vehicles.
Definition station_type.h:65
HVOT_AIRCRAFT
@ HVOT_AIRCRAFT
Station has seen an aircraft.
Definition station_type.h:69
HVOT_BUS
@ HVOT_BUS
Station has seen a bus.
Definition station_type.h:67
HVOT_SHIP
@ HVOT_SHIP
Station has seen a ship.
Definition station_type.h:70
HVOT_TRAIN
@ HVOT_TRAIN
Station has seen a train.
Definition station_type.h:66
StationFacility
StationFacility
The facilities a station might be having.
Definition station_type.h:50
StationFacility::TruckStop
@ TruckStop
Station with truck stops.
StationFacility::BusStop
@ BusStop
Station with bus stops.
CA_NONE
static constexpr uint CA_NONE
Catchment when the station has no facilities.
Definition station_type.h:114
StationType
StationType
Station types.
Definition station_type.h:29
StationRandomTrigger
StationRandomTrigger
Randomisation triggers for stations and roadstops.
Definition station_type.h:77
StationRandomTrigger::VehicleArrives
@ VehicleArrives
Trigger platform when train arrives.
StationRandomTrigger::NewCargo
@ NewCargo
Trigger station on new cargo arrival.
StationRandomTrigger::PathReservation
@ PathReservation
Trigger platform when train reserves path.
StationRandomTrigger::VehicleDeparts
@ VehicleDeparts
Trigger platform when train leaves.
StationRandomTrigger::CargoTaken
@ CargoTaken
Trigger station when cargo is completely taken.
StationRandomTrigger::VehicleLoads
@ VehicleLoads
Trigger platform when train loads/unloads.
MAX_CATCHMENT
static constexpr uint MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
Definition station_type.h:122
CA_DOCK
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
Definition station_type.h:118
CA_BUS
static constexpr uint CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition station_type.h:115
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:120
StationList
std::set< Station *, StationCompare > StationList
List of stations.
Definition station_type.h:131
StationAnimationTrigger
StationAnimationTrigger
Animation triggers for stations and roadstops.
Definition station_type.h:88
StationAnimationTrigger::Built
@ Built
Trigger tile when built.
StationAnimationTrigger::TileLoop
@ TileLoop
Trigger in the periodic tile loop.
StationAnimationTrigger::AcceptanceTick
@ AcceptanceTick
Trigger station every 250 ticks.
CA_TRUCK
static constexpr uint CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition station_type.h:116
MAX_LENGTH_STATION_NAME_CHARS
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
Definition station_type.h:124
AirportAnimationTrigger
AirportAnimationTrigger
Animation triggers for airport tiles.
Definition station_type.h:103
AirportAnimationTrigger::AirplaneTouchdown
@ AirplaneTouchdown
Triggered when an airplane (not a helicopter) touches down at the airport (for single tile).
Airport
All airport-related information.
Definition station_base.h:351
BaseStation
Base class for all station-ish types.
Definition base_station_base.h:58
OrthogonalTileArea
Represents the covered area of e.g.
Definition tilearea_type.h:18
PoolID< uint16_t, struct StationIDTag, 64000, 0xFFFF >
RoadStop
A Stop for a Road Vehicle.
Definition roadstop_base.h:21
StationCompare
Definition station_type.h:126
StationSpec
Station specification.
Definition newgrf_station.h:123
Station
Station data structure.
Definition station_base.h:500
Train
'Train' is either a loco or a wagon.
Definition train.h:91
Waypoint
Representation of a waypoint.
Definition waypoint_base.h:23
tilearea_type.h
Type for storing the 'area' of something uses on the map.