OpenTTD Source: src/vehicle_type.h Source File

OpenTTD Source 15.0-RC2

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
10#ifndef VEHICLE_TYPE_H
11#define VEHICLE_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "core/pool_type.hpp"
15
17 using VehicleID = PoolID<uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF>;
18
19 static const int GROUND_ACCELERATION = 9800;
20
22 enum VehicleType : uint8_t {
23 VEH_BEGIN,
24
25 VEH_TRAIN = VEH_BEGIN,
26 VEH_ROAD,
27 VEH_SHIP,
28 VEH_AIRCRAFT,
29
30 VEH_COMPANY_END,
31
32 VEH_EFFECT = VEH_COMPANY_END,
33 VEH_DISASTER,
34
35 VEH_END,
36 VEH_INVALID = 0xFF,
37};
38 DECLARE_INCREMENT_DECREMENT_OPERATORS(VehicleType)
39 DECLARE_ENUM_AS_ADDABLE(VehicleType)
40
41struct Vehicle;
42struct Train;
43struct RoadVehicle;
44struct Ship;
45struct Aircraft;
46struct EffectVehicle;
47struct DisasterVehicle;
48
50 struct BaseVehicle {
51 VehicleType type = VEH_INVALID;
52};
53
55 enum class DepotCommandFlag : uint8_t {
56 Service,
57 MassSend,
58 DontCancel,
59};
60using DepotCommandFlags = EnumBitSet<DepotCommandFlag, uint8_t>;
61
62 static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32;
63
65 static const uint VEHICLE_LENGTH = 8;
66
68 enum AccelerationModel : uint8_t {
69 AM_ORIGINAL,
70 AM_REALISTIC,
71};
72
74 enum EngineImageType : uint8_t {
75 EIT_ON_MAP = 0x00,
76 EIT_IN_DEPOT = 0x10,
77 EIT_IN_DETAILS = 0x11,
78 EIT_IN_LIST = 0x12,
79 EIT_PURCHASE = 0x20,
80 EIT_PREVIEW = 0x21,
81};
82
84 enum class VehicleRandomTrigger : uint8_t {
85 NewCargo,
86 Depot,
87 Empty,
88 AnyNewCargo,
89 Callback32,
90};
91using VehicleRandomTriggers = EnumBitSet<VehicleRandomTrigger, uint8_t>;
92
93#endif /* VEHICLE_TYPE_H */
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
enum_type.hpp
Type (helpers) for enums.
DECLARE_ENUM_AS_ADDABLE
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
Definition enum_type.hpp:129
DECLARE_INCREMENT_DECREMENT_OPERATORS
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:63
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Aircraft
Aircraft, helicopters, rotors and their shadows belong to this class.
Definition aircraft.h:72
BaseVehicle
Base vehicle class.
Definition vehicle_type.h:50
BaseVehicle::type
VehicleType type
Type of vehicle.
Definition vehicle_type.h:51
DisasterVehicle
Disasters, like submarines, skyrangers and their shadows, belong to this class.
Definition disaster_vehicle.h:37
EffectVehicle
A special vehicle is one of the following:
Definition effectvehicle_base.h:24
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF >
RoadVehicle
Buses, trucks and trams belong to this class.
Definition roadveh.h:98
Ship
All ships have this type.
Definition ship.h:32
Train
'Train' is either a loco or a wagon.
Definition train.h:91
Vehicle
Vehicle data structure.
Definition vehicle_base.h:205
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition vehicle_type.h:74
EIT_PURCHASE
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Definition vehicle_type.h:79
EIT_IN_DEPOT
@ EIT_IN_DEPOT
Vehicle drawn in depot.
Definition vehicle_type.h:76
EIT_IN_DETAILS
@ EIT_IN_DETAILS
Vehicle drawn in vehicle details, refit window, ...
Definition vehicle_type.h:77
EIT_ON_MAP
@ EIT_ON_MAP
Vehicle drawn in viewport.
Definition vehicle_type.h:75
EIT_IN_LIST
@ EIT_IN_LIST
Vehicle drawn in vehicle list, group list, ...
Definition vehicle_type.h:78
EIT_PREVIEW
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
Definition vehicle_type.h:80
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:22
VEH_INVALID
@ VEH_INVALID
Non-existing type of vehicle.
Definition vehicle_type.h:36
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition vehicle_type.h:26
VEH_DISASTER
@ VEH_DISASTER
Disaster vehicle type.
Definition vehicle_type.h:33
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition vehicle_type.h:28
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:27
VEH_EFFECT
@ VEH_EFFECT
Effect vehicle type (smoke, explosions, sparks, bubbles)
Definition vehicle_type.h:32
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition vehicle_type.h:25
VEH_COMPANY_END
@ VEH_COMPANY_END
Last company-ownable type.
Definition vehicle_type.h:30
VehicleRandomTrigger
VehicleRandomTrigger
Randomisation triggers for vehicles.
Definition vehicle_type.h:84
VehicleRandomTrigger::Callback32
@ Callback32
All vehicles in consist: 32 day callback requested rerandomisation.
VehicleRandomTrigger::NewCargo
@ NewCargo
Affected vehicle only: Vehicle is loaded with cargo, after it was empty.
VehicleRandomTrigger::Depot
@ Depot
Front vehicle only: Consist arrived in depot.
VehicleRandomTrigger::AnyNewCargo
@ AnyNewCargo
All vehicles in consist: Any vehicle in the consist received new cargo.
VehicleRandomTrigger::Empty
@ Empty
Front vehicle only: Entire consist is empty.
DepotCommandFlag
DepotCommandFlag
Flags for goto depot commands.
Definition vehicle_type.h:55
DepotCommandFlag::MassSend
@ MassSend
Tells that it's a mass send to depot command (type in VLW flag)
DepotCommandFlag::DontCancel
@ DontCancel
Don't cancel current goto depot command if any.
DepotCommandFlag::Service
@ Service
The vehicle will leave the depot right after arrival (service only)
AccelerationModel
AccelerationModel
Vehicle acceleration models.
Definition vehicle_type.h:68
GROUND_ACCELERATION
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
Definition vehicle_type.h:19
MAX_LENGTH_VEHICLE_NAME_CHARS
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS
The maximum length of a vehicle name in characters including '\0'.
Definition vehicle_type.h:62
VEHICLE_LENGTH
static const uint VEHICLE_LENGTH
The length of a vehicle in tile units.
Definition vehicle_type.h:65