OpenTTD Source 20260711-master-g3fb3006dff
vehicle_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
9
10#ifndef VEHICLE_TYPE_H
11#define VEHICLE_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "core/pool_type.hpp"
15
18
19static const int GROUND_ACCELERATION = 9800;
20
40
41struct Vehicle;
42struct Train;
43struct RoadVehicle;
44struct Ship;
45struct Aircraft;
46struct EffectVehicle;
47struct DisasterVehicle;
48
53
60
63
64static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32;
65
67static const uint VEHICLE_LENGTH = 8;
68
70enum class AccelerationModel : uint8_t {
73};
74
76enum class EngineImageType : uint8_t {
77 OnMap = 0x00,
78 InDepot = 0x10,
79 InDetails = 0x11,
80 InList = 0x12,
81 Purchase = 0x20,
82 Preview = 0x21,
83};
84
93
96
102template <typename T, VehicleType Tend = VehicleType::CompanyEnd>
104
106enum class GroundVehicleFlag : uint8_t {
110};
111
114
115#endif /* VEHICLE_TYPE_H */
Enum-as-bit-set wrapper.
Type (helpers) for enums.
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:86
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
@ Invalid
broken savegame (used internally)
Definition saveload.h:449
Aircraft, helicopters, rotors and their shadows belong to this class.
Definition aircraft.h:75
Base vehicle class.
VehicleType type
Type of vehicle.
Disasters, like submarines, skyrangers and their shadows, belong to this class.
A special vehicle is one of the following:
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:50
Buses, trucks and trams belong to this class.
Definition roadveh.h:105
All ships have this type.
Definition ship.h:32
'Train' is either a loco or a wagon.
Definition train.h:97
Vehicle data structure.
EnumBitSet< DepotCommandFlag, uint8_t > DepotCommandFlags
Bitset of DepotCommandFlag elements.
EnumBitSet< VehicleRandomTrigger, uint8_t > VehicleRandomTriggers
Bitset of VehicleRandomTrigger elements.
EngineImageType
Visualisation contexts of vehicles and engines.
@ Preview
Vehicle drawn in preview window, news, ...
@ InDepot
Vehicle drawn in depot.
@ Purchase
Vehicle drawn in purchase list, autoreplace gui, ...
@ OnMap
Vehicle drawn in viewport.
@ InList
Vehicle drawn in vehicle list, group list, ...
@ InDetails
Vehicle drawn in vehicle details, refit window, ...
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
VehicleType
Available vehicle types.
@ Begin
Begin marker.
@ Invalid
Non-existing type of vehicle.
@ CompanyEnd
Last company-ownable type.
@ End
End marker.
@ Effect
Effect vehicle type (smoke, explosions, sparks, bubbles).
@ Road
Road vehicle type.
@ Disaster
Disaster vehicle type.
VehicleRandomTrigger
Randomisation triggers for vehicles.
@ Callback32
All vehicles in consist: 32 day callback requested rerandomisation.
@ NewCargo
Affected vehicle only: Vehicle is loaded with cargo, after it was empty.
@ AnyNewCargo
All vehicles in consist: Any vehicle in the consist received new cargo.
@ Empty
Front vehicle only: Entire consist is empty.
DepotCommandFlag
Flags for goto depot commands.
@ MassSend
Tells that it's a mass send to depot command (type in VLW flag).
@ DontCancel
Don't cancel current goto depot command if any.
@ Service
The vehicle will leave the depot right after arrival (service only).
AccelerationModel
Vehicle acceleration models.
@ Original
Original acceleration model.
@ Realistic
"Realistic" acceleration model.
EnumBitSet< GroundVehicleFlag, uint16_t > GroundVehicleFlags
Bitset of GroundVehicleFlag elements.
EnumIndexArray< T, VehicleType, Tend > VehicleTypeIndexArray
Array with VehicleType as index.
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS
The maximum length of a vehicle name in characters including '\0'.
GroundVehicleFlag
Ground vehicle flags.
@ GoingUp
Vehicle is currently going uphill. (Cached track information for acceleration).
@ SuppressImplicitOrders
Disable insertion and removal of automatic orders until the vehicle completes the real order.
@ GoingDown
Vehicle is currently going downhill. (Cached track information for acceleration).
static const uint VEHICLE_LENGTH
The length of a vehicle in tile units.