OpenTTD Source 20250205-master-gfd85ab1e2c
engine_type.h File Reference

Types related to engines. More...

#include "economy_type.h"
#include "landscape_type.h"
#include "newgrf_callbacks.h"
#include "rail_type.h"
#include "road_type.h"
#include "cargo_type.h"
#include "timer/timer_game_calendar.h"
#include "sound_type.h"
#include "strings_type.h"

Go to the source code of this file.

Data Structures

struct  RailVehicleInfo
 Information about a rail vehicle. More...
 
struct  ShipVehicleInfo
 Information about a ship vehicle. More...
 
struct  AircraftVehicleInfo
 Information about a aircraft vehicle. More...
 
struct  RoadVehicleInfo
 Information about a road vehicle. More...
 
struct  EngineInfo
 Information about a vehicle. More...
 

Typedefs

typedef uint16_t EngineID
 Unique identification number of an engine.
 
using ExtraEngineFlags = EnumBitSet< ExtraEngineFlag, uint8_t >
 
using EngineMiscFlags = EnumBitSet< EngineMiscFlag, uint8_t >
 
using EngineFlags = EnumBitSet< EngineFlag, uint8_t >
 

Enumerations

enum  RailVehicleTypes : uint8_t { RAILVEH_SINGLEHEAD , RAILVEH_MULTIHEAD , RAILVEH_WAGON }
 Available types of rail vehicles. More...
 
enum  EngineClass : uint8_t {
  EC_STEAM , EC_DIESEL , EC_ELECTRIC , EC_MONORAIL ,
  EC_MAGLEV
}
 Type of rail engine. More...
 
enum  AircraftSubTypeBits : uint8_t { AIR_HELI = 0 , AIR_CTOL = 1 , AIR_FAST = 2 }
 AircraftVehicleInfo subtypes, bitmask type. More...
 
enum class  ExtraEngineFlag : uint8_t { NoNews = 0 , NoPreview = 1 , JoinPreview = 2 , SyncReliability = 3 }
 Extra engine flags for NewGRF features. More...
 
enum class  EngineMiscFlag : uint8_t {
  RailTilts = 0 , RoadIsTram = 0 , Uses2CC = 1 , RailIsMU = 2 ,
  RailFlips = 3 , AutoRefit = 4 , NoDefaultCargoMultiplier = 5 , NoBreakdownSmoke = 6 ,
  SpriteStack = 7
}
 EngineInfo.misc_flags is a bitmask, with the following values. More...
 
enum class  EngineFlag : uint8_t { Available = 1 , ExclusivePreview = 2 }
 Engine.flags is a bitmask, with the following values. More...
 
enum class  EngineNameContext : uint8_t {
  Generic = 0x00 , VehicleDetails = 0x11 , PurchaseList = 0x20 , PreviewNews = 0x21 ,
  AutoreplaceVehicleInUse = 0x22
}
 Contexts an engine name can be shown in. More...
 

Functions

uint64_t PackEngineNameDParam (EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
 Combine an engine ID and a name context to an engine name dparam.
 

Variables

static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32
 The maximum length of an engine name in characters including '\0'.
 
static const EngineID INVALID_ENGINE = 0xFFFF
 Constant denoting an invalid engine.
 

Detailed Description

Types related to engines.

Definition in file engine_type.h.

Typedef Documentation

◆ EngineFlags

using EngineFlags = EnumBitSet<EngineFlag, uint8_t>

Definition at line 195 of file engine_type.h.

◆ EngineID

typedef uint16_t EngineID

Unique identification number of an engine.

Definition at line 23 of file engine_type.h.

◆ EngineMiscFlags

Definition at line 162 of file engine_type.h.

◆ ExtraEngineFlags

Definition at line 143 of file engine_type.h.

Enumeration Type Documentation

◆ AircraftSubTypeBits

enum AircraftSubTypeBits : uint8_t

AircraftVehicleInfo subtypes, bitmask type.

If bit 0 is 0 then it is a helicopter, otherwise it is a plane in which case bit 1 tells us whether it's a big(fast) plane or not.

Enumerator
AIR_CTOL 

Conventional Take Off and Landing, i.e. planes.

Definition at line 95 of file engine_type.h.

◆ EngineClass

enum EngineClass : uint8_t

Type of rail engine.

Enumerator
EC_STEAM 

Steam rail engine.

EC_DIESEL 

Diesel rail engine.

EC_ELECTRIC 

Electric rail engine.

EC_MONORAIL 

Mono rail engine.

EC_MAGLEV 

Maglev engine.

Definition at line 35 of file engine_type.h.

◆ EngineFlag

enum class EngineFlag : uint8_t
strong

Engine.flags is a bitmask, with the following values.

Enumerator
Available 

This vehicle is available to everyone.

ExclusivePreview 

This vehicle is in the exclusive preview stage, either being used or being offered to a company.

Definition at line 191 of file engine_type.h.

◆ EngineMiscFlag

enum class EngineMiscFlag : uint8_t
strong

EngineInfo.misc_flags is a bitmask, with the following values.

Enumerator
RailTilts 

Rail vehicle tilts in curves.

RoadIsTram 

Road vehicle is a tram/light rail vehicle.

Uses2CC 

Vehicle uses two company colours.

RailIsMU 

Rail vehicle is a multiple-unit (DMU/EMU)

RailFlips 

Rail vehicle has old depot-flip handling.

AutoRefit 

Automatic refitting is allowed.

NoDefaultCargoMultiplier 

Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipliers. CB 15 is also called in purchase list.

NoBreakdownSmoke 

Do not show black smoke during a breakdown.

SpriteStack 

Draw vehicle by stacking multiple sprites.

Definition at line 148 of file engine_type.h.

◆ EngineNameContext

enum class EngineNameContext : uint8_t
strong

Contexts an engine name can be shown in.

Enumerator
Generic 

No specific context available.

VehicleDetails 

Name is shown in the vehicle details GUI.

PurchaseList 

Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel).

PreviewNews 

Name is shown in exclusive preview or newspaper.

AutoreplaceVehicleInUse 

Name is show in the autoreplace window 'Vehicles in use' panel.

Definition at line 200 of file engine_type.h.

◆ ExtraEngineFlag

enum class ExtraEngineFlag : uint8_t
strong

Extra engine flags for NewGRF features.

This is defined in the specification a 32 bit value, but most bits are not currently used.

Enumerator
NoNews 

No 'new vehicle' news will be generated.

NoPreview 

No exclusive preview will be offered.

JoinPreview 

Engine will join exclusive preview with variant parent.

SyncReliability 

Engine reliability will be synced with variant parent.

Definition at line 137 of file engine_type.h.

◆ RailVehicleTypes

enum RailVehicleTypes : uint8_t

Available types of rail vehicles.

Enumerator
RAILVEH_SINGLEHEAD 

indicates a "standalone" locomotive

RAILVEH_MULTIHEAD 

indicates a combination of two locomotives

RAILVEH_WAGON 

simple wagon, not motorized

Definition at line 28 of file engine_type.h.

Function Documentation

◆ PackEngineNameDParam()

uint64_t PackEngineNameDParam ( EngineID  engine_id,
EngineNameContext  context,
uint32_t  extra_data = 0 
)
inline

Variable Documentation

◆ INVALID_ENGINE

◆ MAX_LENGTH_ENGINE_NAME_CHARS

const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32
static

The maximum length of an engine name in characters including '\0'.

Definition at line 214 of file engine_type.h.

Referenced by CmdRenameEngine(), and BuildVehicleWindow::OnClick().