OpenTTD Source 20260512-master-g20b387b91f
vehicle_type.h File Reference

Types related to vehicles. More...

#include "core/enum_type.hpp"
#include "core/pool_type.hpp"

Go to the source code of this file.

Data Structures

struct  BaseVehicle
 Base vehicle class. More...

Typedefs

using VehicleID = PoolID<uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF>
 The type all our vehicle IDs have.
using DepotCommandFlags = EnumBitSet<DepotCommandFlag, uint8_t>
using VehicleRandomTriggers = EnumBitSet<VehicleRandomTrigger, uint8_t>
template<typename T, VehicleType Tend = VehicleType::CompanyEnd>
using VehicleTypeIndexArray = EnumIndexArray<T, VehicleType, Tend>
 Array with VehicleType as index.

Enumerations

enum class  VehicleType : uint8_t {
  Begin , Train = VehicleType::Begin , Road , Ship ,
  Aircraft , CompanyEnd , Effect = VehicleType::CompanyEnd , Disaster ,
  End , Invalid = 0xFF
}
 Available vehicle types. More...
enum class  DepotCommandFlag : uint8_t { Service , MassSend , DontCancel }
 Flags for goto depot commands. More...
enum  AccelerationModel : uint8_t { AM_ORIGINAL , AM_REALISTIC }
 Vehicle acceleration models. More...
enum  EngineImageType : uint8_t {
  EIT_ON_MAP = 0x00 , EIT_IN_DEPOT = 0x10 , EIT_IN_DETAILS = 0x11 , EIT_IN_LIST = 0x12 ,
  EIT_PURCHASE = 0x20 , EIT_PREVIEW = 0x21
}
 Visualisation contexts of vehicles and engines. More...
enum class  VehicleRandomTrigger : uint8_t {
  NewCargo , Depot , Empty , AnyNewCargo ,
  Callback32
}
 Randomisation triggers for vehicles. More...

Variables

static const int GROUND_ACCELERATION = 9800
 Acceleration due to gravity, 9.8 m/s^2.
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32
 The maximum length of a vehicle name in characters including '\0'.
static const uint VEHICLE_LENGTH = 8
 The length of a vehicle in tile units.

Detailed Description

Types related to vehicles.

Definition in file vehicle_type.h.

Typedef Documentation

◆ DepotCommandFlags

using DepotCommandFlags = EnumBitSet<DepotCommandFlag, uint8_t>

Definition at line 60 of file vehicle_type.h.

◆ VehicleID

using VehicleID = PoolID<uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF>

The type all our vehicle IDs have.

Definition at line 17 of file vehicle_type.h.

◆ VehicleRandomTriggers

using VehicleRandomTriggers = EnumBitSet<VehicleRandomTrigger, uint8_t>

Definition at line 91 of file vehicle_type.h.

◆ VehicleTypeIndexArray

template<typename T, VehicleType Tend = VehicleType::CompanyEnd>
using VehicleTypeIndexArray = EnumIndexArray<T, VehicleType, Tend>

Array with VehicleType as index.

Template Parameters
Tthe type contained within the array.
Tendthe number of elements in the array.

Definition at line 99 of file vehicle_type.h.

Enumeration Type Documentation

◆ AccelerationModel

enum AccelerationModel : uint8_t

Vehicle acceleration models.

Definition at line 68 of file vehicle_type.h.

◆ DepotCommandFlag

enum class DepotCommandFlag : uint8_t
strong

Flags for goto depot commands.

Enumerator
Service 

The vehicle will leave the depot right after arrival (service only).

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.

Definition at line 55 of file vehicle_type.h.

◆ EngineImageType

enum EngineImageType : uint8_t

Visualisation contexts of vehicles and engines.

Enumerator
EIT_ON_MAP 

Vehicle drawn in viewport.

EIT_IN_DEPOT 

Vehicle drawn in depot.

EIT_IN_DETAILS 

Vehicle drawn in vehicle details, refit window, ...

EIT_IN_LIST 

Vehicle drawn in vehicle list, group list, ...

EIT_PURCHASE 

Vehicle drawn in purchase list, autoreplace gui, ...

EIT_PREVIEW 

Vehicle drawn in preview window, news, ...

Definition at line 74 of file vehicle_type.h.

◆ VehicleRandomTrigger

enum class VehicleRandomTrigger : uint8_t
strong

Randomisation triggers for vehicles.

Enumerator
NewCargo 

Affected vehicle only: Vehicle is loaded with cargo, after it was empty.

Depot 

Front vehicle only: Consist arrived in depot.

Empty 

Front vehicle only: Entire consist is empty.

AnyNewCargo 

All vehicles in consist: Any vehicle in the consist received new cargo.

Callback32 

All vehicles in consist: 32 day callback requested rerandomisation.

Definition at line 84 of file vehicle_type.h.

◆ VehicleType

enum class VehicleType : uint8_t
strong

Available vehicle types.

It needs to be 8bits, because we save and load it as such

Enumerator
Begin 

Begin marker.

Train 

Train vehicle type.

Road 

Road vehicle type.

Ship 

Ship vehicle type.

Aircraft 

Aircraft vehicle type.

CompanyEnd 

Last company-ownable type.

Effect 

Effect vehicle type (smoke, explosions, sparks, bubbles).

Disaster 

Disaster vehicle type.

End 

End marker.

Invalid 

Non-existing type of vehicle.

Definition at line 22 of file vehicle_type.h.

Variable Documentation

◆ GROUND_ACCELERATION

const int GROUND_ACCELERATION = 9800
static

Acceleration due to gravity, 9.8 m/s^2.

Definition at line 19 of file vehicle_type.h.

Referenced by Engine::GetDisplayMaxTractiveEffort(), and GroundVehicle< T, Type >::PowerChanged().

◆ MAX_LENGTH_VEHICLE_NAME_CHARS

const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32
static

The maximum length of a vehicle name in characters including '\0'.

Definition at line 62 of file vehicle_type.h.

Referenced by CmdRenameVehicle(), and VehicleViewWindow::OnClick().

◆ VEHICLE_LENGTH