OpenTTD Source: src/vehicle_type.h Source File

OpenTTD Source 15.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef VEHICLE_TYPE_H
11#define VEHICLE_TYPE_H
12
13#include "core/enum_type.hpp"
14
16 typedef uint32_t VehicleID;
17
18 static const int GROUND_ACCELERATION = 9800;
19
21 enum VehicleType : uint8_t {
22 VEH_BEGIN,
23
24 VEH_TRAIN = VEH_BEGIN,
25 VEH_ROAD,
26 VEH_SHIP,
27 VEH_AIRCRAFT,
28
29 VEH_COMPANY_END,
30
31 VEH_EFFECT = VEH_COMPANY_END,
32 VEH_DISASTER,
33
34 VEH_END,
35 VEH_INVALID = 0xFF,
36};
37 DECLARE_POSTFIX_INCREMENT(VehicleType)
38 DECLARE_ENUM_AS_ADDABLE(VehicleType)
39
40struct Vehicle;
41struct Train;
42struct RoadVehicle;
43struct Ship;
44struct Aircraft;
45struct EffectVehicle;
46struct DisasterVehicle;
47
49 struct BaseVehicle
50{
51 VehicleType type;
52};
53
54 static const VehicleID INVALID_VEHICLE = 0xFFFFF;
55
57 enum class DepotCommand : uint8_t {
58 None = 0,
59 Service = (1U << 0),
60 MassSend = (1U << 1),
61 DontCancel = (1U << 2),
62 LocateHangar = (1U << 3),
63};
64 DECLARE_ENUM_AS_BIT_SET(DepotCommand)
65
66static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32;
67
69static const uint VEHICLE_LENGTH = 8;
70
72enum AccelerationModel {
73 AM_ORIGINAL,
74 AM_REALISTIC,
75};
76
78 enum EngineImageType {
79 EIT_ON_MAP = 0x00,
80 EIT_IN_DEPOT = 0x10,
81 EIT_IN_DETAILS = 0x11,
82 EIT_IN_LIST = 0x12,
83 EIT_PURCHASE = 0x20,
84 EIT_PREVIEW = 0x21,
85};
86
87#endif /* VEHICLE_TYPE_H */
enum_type.hpp
Type (helpers) for enums.
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:35
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition enum_type.hpp:18
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:45
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
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:89
Vehicle
Vehicle data structure.
Definition vehicle_base.h:244
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition vehicle_type.h:78
EIT_PURCHASE
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Definition vehicle_type.h:83
EIT_IN_DEPOT
@ EIT_IN_DEPOT
Vehicle drawn in depot.
Definition vehicle_type.h:80
EIT_IN_DETAILS
@ EIT_IN_DETAILS
Vehicle drawn in vehicle details, refit window, ...
Definition vehicle_type.h:81
EIT_ON_MAP
@ EIT_ON_MAP
Vehicle drawn in viewport.
Definition vehicle_type.h:79
EIT_IN_LIST
@ EIT_IN_LIST
Vehicle drawn in vehicle list, group list, ...
Definition vehicle_type.h:82
EIT_PREVIEW
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
Definition vehicle_type.h:84
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:21
VEH_INVALID
@ VEH_INVALID
Non-existing type of vehicle.
Definition vehicle_type.h:35
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition vehicle_type.h:25
VEH_DISASTER
@ VEH_DISASTER
Disaster vehicle type.
Definition vehicle_type.h:32
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition vehicle_type.h:27
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:26
VEH_EFFECT
@ VEH_EFFECT
Effect vehicle type (smoke, explosions, sparks, bubbles)
Definition vehicle_type.h:31
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition vehicle_type.h:24
VEH_COMPANY_END
@ VEH_COMPANY_END
Last company-ownable type.
Definition vehicle_type.h:29
AccelerationModel
AccelerationModel
Vehicle acceleration models.
Definition vehicle_type.h:72
VehicleID
uint32_t VehicleID
The type all our vehicle IDs have.
Definition vehicle_type.h:16
GROUND_ACCELERATION
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
Definition vehicle_type.h:18
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:66
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition vehicle_type.h:54
VEHICLE_LENGTH
static const uint VEHICLE_LENGTH
The length of a vehicle in tile units.
Definition vehicle_type.h:69
DepotCommand
DepotCommand
Flags for goto depot commands.
Definition vehicle_type.h:57
DepotCommand::LocateHangar
@ LocateHangar
Find another airport if the target one lacks a hangar.
DepotCommand::None
@ None
No special flags.
DepotCommand::MassSend
@ MassSend
Tells that it's a mass send to depot command (type in VLW flag)
DepotCommand::DontCancel
@ DontCancel
Don't cancel current goto depot command if any.
DepotCommand::Service
@ Service
The vehicle will leave the depot right after arrival (service only)