OpenTTD Source: src/vehicle_base.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Typedefs | Enumerations | Functions | Variables
vehicle_base.h File Reference

Base class for all vehicles. More...

`#include "sprite.h"`
`#include "track_type.h"`
`#include "command_type.h"`
`#include "order_base.h"`
`#include "cargopacket.h"`
`#include "texteff.hpp"`
`#include "engine_type.h"`
`#include "order_func.h"`
`#include "transport_type.h"`
`#include "group_type.h"`
`#include "base_consist.h"`
`#include "network/network.h"`
`#include "saveload/saveload.h"`
`#include "timer/timer_game_calendar.h"`

Go to the source code of this file.

## Data Structures
struct | NewGRFCache
| Cached often queried (NewGRF) values. More...
struct | VehicleCache
| Cached often queried values common to all vehicles. More...
struct | VehicleSpriteSeq
| Sprite sequence for a vehicle part. More...
struct | MutableSpriteCache
| Cache for vehicle sprites and values relating to whether they should be updated before drawing, or calculating the viewport. More...
struct | RefitDesc
| Simulated cargo type and capacity for prediction of future links. More...
struct | ClosestDepot
| Structure to return information about the closest depot location, and whether it could be found. More...
struct | Vehicle
| Vehicle data structure. More...
struct | SpecializedVehicle< T, Type >
| Class defining several overloaded accessors so we don't have to cast vehicle types that often. More...

## Typedefs
using | VehStates = EnumBitSet< VehState, uint8_t >
typedef Pool< Vehicle, VehicleID, 512 > | VehiclePool
| A vehicle pool for a little over 1 million vehicles.

## Enumerations
enum class | VehState : uint8_t { Hidden = 0 , Stopped = 1 , Unclickable = 2 , DefaultPalette = 3 , TrainSlowing = 4 , Shadow = 5 , AircraftBroken = 6 , Crashed = 7 }
| Vehicle state bits in Vehicle::vehstatus. More...
enum | NewGRFCacheValidValues : uint8_t { NCVV_POSITION_CONSIST_LENGTH = 0 , NCVV_POSITION_SAME_ID_LENGTH = 1 , NCVV_CONSIST_CARGO_INFORMATION = 2 , NCVV_COMPANY_INFORMATION = 3 , NCVV_POSITION_IN_VEHICLE = 4 , NCVV_END }
| Bit numbers used to indicate which of the NewGRFCache values are valid. More...
enum | VisualEffectSpawnModel : uint8_t { VESM_NONE = 0 , VESM_STEAM , VESM_DIESEL , VESM_ELECTRIC , VESM_END }
| Models for spawning visual effects. More...
enum | GroundVehicleSubtypeFlags : uint8_t { GVSF_FRONT = 0 , GVSF_ARTICULATED_PART = 1 , GVSF_WAGON = 2 , GVSF_ENGINE = 3 , GVSF_FREE_WAGON = 4 , GVSF_MULTIHEADED = 5 }
| Enum to handle ground vehicle subtypes. More...

## Functions
bool | LoadOldVehicle (LoadgameState &ls, int num)
| Load the vehicles of an old style savegame.
void | FixOldVehicles (LoadgameState &ls)
| Convert the old style vehicles into something that resembles the old new style savegames.

## Variables
const uint | TILE_AXIAL_DISTANCE = 192
const uint | TILE_CORNER_DISTANCE = 128
VehiclePool | _vehicle_pool
static const int32_t | INVALID_COORD = 0x7fffffff
| Sentinel for an invalid coordinate.

## Detailed Description

Base class for all vehicles.

Definition in file vehicle_base.h.

## Typedef Documentation

## ◆ VehiclePool

typedef Pool<Vehicle, VehicleID, 512> VehiclePool

A vehicle pool for a little over 1 million vehicles.

Definition at line 166 of file vehicle_base.h.

## ◆ VehStates

using VehStates = EnumBitSet<VehState, uint8_t>

Definition at line 42 of file vehicle_base.h.

## Enumeration Type Documentation

## ◆ GroundVehicleSubtypeFlags

enum GroundVehicleSubtypeFlags : uint8_t

Enum to handle ground vehicle subtypes.

This is defined here instead of at GroundVehicle because some common function require access to these flags. Do not access it directly unless you have to. Use the subtype access functions.

Enumerator
GVSF_FRONT | Leading engine of a consist.
GVSF_ARTICULATED_PART | Articulated part of an engine.
GVSF_WAGON | Wagon (not used for road vehicles).
GVSF_ENGINE | Engine that can be front engine, but might be placed behind another engine (not used for road vehicles).
GVSF_FREE_WAGON | First in a wagon chain (in depot) (not used for road vehicles).
GVSF_MULTIHEADED | Engine is multiheaded (not used for road vehicles).

Definition at line 82 of file vehicle_base.h.

## ◆ NewGRFCacheValidValues

enum NewGRFCacheValidValues : uint8_t

Bit numbers used to indicate which of the NewGRFCache values are valid.

Enumerator
NCVV_POSITION_CONSIST_LENGTH | This bit will be set if the NewGRF var 40 currently stored is valid.
NCVV_POSITION_SAME_ID_LENGTH | This bit will be set if the NewGRF var 41 currently stored is valid.
NCVV_CONSIST_CARGO_INFORMATION | This bit will be set if the NewGRF var 42 currently stored is valid.
NCVV_COMPANY_INFORMATION | This bit will be set if the NewGRF var 43 currently stored is valid.
NCVV_POSITION_IN_VEHICLE | This bit will be set if the NewGRF var 4D currently stored is valid.
NCVV_END | End of the bits.

Definition at line 45 of file vehicle_base.h.

## ◆ VehState

enum class VehState : uint8_t
| strong

Vehicle state bits in Vehicle::vehstatus.

Enumerator
Hidden | Vehicle is not visible.
Stopped | Vehicle is stopped by the player.
Unclickable | Vehicle is not clickable by the user (shadow vehicles).
DefaultPalette | Use default vehicle palette. See also DoDrawVehicle
TrainSlowing | Train is slowing down.
Shadow | Vehicle is a shadow vehicle.
AircraftBroken | Aircraft is broken down.
Crashed | Vehicle is crashed.

Definition at line 32 of file vehicle_base.h.

## ◆ VisualEffectSpawnModel

enum VisualEffectSpawnModel : uint8_t

Models for spawning visual effects.

Enumerator
VESM_NONE | No visual effect.
VESM_STEAM | Steam model.
VESM_DIESEL | Diesel model.
VESM_ELECTRIC | Electric model.

Definition at line 68 of file vehicle_base.h.

## Function Documentation

## ◆ FixOldVehicles()

void FixOldVehicles | ( | LoadgameState & | ls | ) |
| extern

Convert the old style vehicles into something that resembles the old new style savegames.

Then AfterLoadGame can handle the rest of the conversion.

Definition at line 217 of file oldloader_sl.cpp.

## ◆ LoadOldVehicle()

bool LoadOldVehicle | ( | LoadgameState & | ls,
|  | int | num
| ) |  |
| extern

Load the vehicles of an old style savegame.

Parameters

  ls | State (buffer) of the currently loaded game.
  num | The number of vehicles to load.

Returns
  True iff loading went without problems.

So we can set the proper next pointer while loading.

Parameters

  ls | State (buffer) of the currently loaded game.
  num | The number of vehicles to load.

Returns
  True iff loading went without problems.

Definition at line 219 of file oldloader_sl.cpp.

## Variable Documentation

## ◆ INVALID_COORD

const int32_t INVALID_COORD = 0x7fffffff
| static

Sentinel for an invalid coordinate.

Definition at line 1207 of file vehicle_base.h.

Referenced by AfterLoadVehiclesPhase2(), Vehicle::UpdateBoundingBoxCoordinates(), Vehicle::UpdateViewport(), Vehicle::Vehicle(), and Vehicle::~Vehicle().

## ◆ TILE_AXIAL_DISTANCE

const uint TILE_AXIAL_DISTANCE = 192

Definition at line 28 of file vehicle_base.h.

## ◆ TILE_CORNER_DISTANCE

const uint TILE_CORNER_DISTANCE = 128

Definition at line 29 of file vehicle_base.h.