OpenTTD Source: src/roadveh.h File Reference

OpenTTD Source 15.3

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

Road vehicle states. More...

`#include "ground_vehicle.hpp"`
`#include "engine_base.h"`
`#include "cargotype.h"`
`#include "track_func.h"`
`#include "road.h"`
`#include "road_map.h"`
`#include "newgrf_engine.h"`

Go to the source code of this file.

## Data Structures
struct | RoadVehPathElement
| Element of the RoadVehPathCache. More...
struct | RoadVehicle
| Buses, trucks and trams belong to this class. More...

## Typedefs
using | RoadVehPathCache = std::vector< RoadVehPathElement >

## Enumerations
enum | RoadVehicleStates : uint8_t { RVSB_IN_DEPOT = 0xFE , RVSB_WORMHOLE = 0xFF , RVS_USING_SECOND_BAY = 1 , RVS_ENTERED_STOP = 2 , RVS_DRIVE_SIDE = 4 , RVS_IN_ROAD_STOP = 5 , RVS_IN_DT_ROAD_STOP = 6 , RVSB_IN_ROAD_STOP = 1 << RVS_IN_ROAD_STOP , RVSB_IN_ROAD_STOP_END = RVSB_IN_ROAD_STOP + TRACKDIR_END , RVSB_IN_DT_ROAD_STOP = 1 << RVS_IN_DT_ROAD_STOP , RVSB_IN_DT_ROAD_STOP_END = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END , RVSB_DRIVE_SIDE = 1 << RVS_DRIVE_SIDE , RVSB_TRACKDIR_MASK = 0x0F , RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09 }
| Road vehicle states. More...

## Functions
void | RoadVehUpdateCache (RoadVehicle *v, bool same_length=false)
| Update the cache of a road vehicle.
void | GetRoadVehSpriteSize (EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
| Get the size of the sprite of a road vehicle sprite heading west (used for lists).

## Variables
static const uint | RDE_NEXT_TILE = 0x80
| State information about the Road Vehicle controller.
static const uint | RDE_TURNED = 0x40
| We just finished turning.
static const uint | RVC_DEFAULT_START_FRAME = 0
static const uint | RVC_TURN_AROUND_START_FRAME = 1
static const uint | RVC_DEPOT_START_FRAME = 6
static const uint | RVC_START_FRAME_AFTER_LONG_TRAM = 21
static const uint | RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16
static const uint | RVC_DRIVE_THROUGH_STOP_FRAME = 11
static const uint | RVC_DEPOT_STOP_FRAME = 11
static const uint8_t | RV_OVERTAKE_TIMEOUT = 35
| The number of ticks a vehicle has for overtaking.

## Detailed Description

Road vehicle states.

Definition in file roadveh.h.

## Typedef Documentation

## ◆ RoadVehPathCache

using RoadVehPathCache = std::vector<RoadVehPathElement>

Definition at line 93 of file roadveh.h.

## Enumeration Type Documentation

## ◆ RoadVehicleStates

enum RoadVehicleStates : uint8_t

Road vehicle states.

Enumerator
RVSB_IN_DEPOT | The vehicle is in a depot.
RVSB_WORMHOLE | The vehicle is in a tunnel and/or bridge.
RVS_USING_SECOND_BAY | Only used while in a road stop.
RVS_ENTERED_STOP | Only set when a vehicle has entered the stop.
RVS_DRIVE_SIDE | Only used when retrieving move data.
RVS_IN_ROAD_STOP | The vehicle is in a road stop.
RVS_IN_DT_ROAD_STOP | The vehicle is in a drive-through road stop.
RVSB_IN_ROAD_STOP | The vehicle is in a road stop.
RVSB_IN_DT_ROAD_STOP | The vehicle is in a drive-through road stop.
RVSB_DRIVE_SIDE | The vehicle is at the opposite side of the road.
RVSB_TRACKDIR_MASK | The mask used to extract track dirs.
RVSB_ROAD_STOP_TRACKDIR_MASK | Only bits 0 and 3 are used to encode the trackdir for road stops.

Definition at line 24 of file roadveh.h.

## Function Documentation

## ◆ GetRoadVehSpriteSize()

void GetRoadVehSpriteSize | ( | EngineID | engine,
|  | uint & | width,
|  | uint & | height,
|  | int & | xoffs,
|  | int & | yoffs,
|  | EngineImageType | image_type
| ) |  |

Get the size of the sprite of a road vehicle sprite heading west (used for lists).

Parameters

  | engine | The engine to get the sprite from.
  [out] | width | The width of the sprite.
  [out] | height | The height of the sprite.
  [out] | xoffs | Number of pixels to shift the sprite to the right.
  [out] | yoffs | Number of pixels to shift the sprite downwards.
  | image_type | Context the sprite is used in.

Definition at line 172 of file roadveh_cmd.cpp.

References VehicleSpriteSeq::GetBounds(), Rect::Height(), UnScaleGUI(), and Rect::Width().

Referenced by EnginePreviewWindow::UpdateWidgetSize().

## ◆ RoadVehUpdateCache()

void RoadVehUpdateCache | ( | RoadVehicle * | v,
|  | bool | same_length
| ) |  |

Update the cache of a road vehicle.

Parameters

  v | Road vehicle needing an update of its cache.
  same_length | should length of vehicles stay the same?

Precondition
  v must be first road vehicle.

Definition at line 219 of file roadveh_cmd.cpp.

References VehicleCache::cached_max_speed, GroundVehicleCache::cached_total_length, EngineInfo::cargo_age_period, Vehicle::engine_type, GroundVehicle< T, Type >::gcache, GetRoadVehLength(), Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::IsFrontEngine(), RoadVehicleInfo::max_speed, SpecializedVehicle< T, Type >::Next(), PROP_ROADVEH_CARGO_AGE_PERIOD, PROP_ROADVEH_SPEED, BaseVehicle::type, Vehicle::vcache, VEH_ROAD, and VehicleLengthChanged().

Referenced by AfterLoadVehiclesPhase2(), CheckCaches(), CmdBuildRoadVehicle(), and CmdRefitVehicle().

## Variable Documentation

## ◆ RDE_NEXT_TILE

const uint RDE_NEXT_TILE = 0x80
| static

State information about the Road Vehicle controller.

We should enter the next tile

Definition at line 61 of file roadveh.h.

## ◆ RDE_TURNED

const uint RDE_TURNED = 0x40
| static

We just finished turning.

Definition at line 62 of file roadveh.h.

## ◆ RV_OVERTAKE_TIMEOUT

const uint8_t RV_OVERTAKE_TIMEOUT = 35
| static

The number of ticks a vehicle has for overtaking.

Definition at line 79 of file roadveh.h.

## ◆ RVC_DEFAULT_START_FRAME

const uint RVC_DEFAULT_START_FRAME = 0
| static

Definition at line 69 of file roadveh.h.

## ◆ RVC_DEPOT_START_FRAME

const uint RVC_DEPOT_START_FRAME = 6
| static

Definition at line 71 of file roadveh.h.

## ◆ RVC_DEPOT_STOP_FRAME

const uint RVC_DEPOT_STOP_FRAME = 11
| static

Definition at line 76 of file roadveh.h.

## ◆ RVC_DRIVE_THROUGH_STOP_FRAME

const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11
| static

Definition at line 75 of file roadveh.h.

## ◆ RVC_START_FRAME_AFTER_LONG_TRAM

const uint RVC_START_FRAME_AFTER_LONG_TRAM = 21
| static

Definition at line 72 of file roadveh.h.

## ◆ RVC_TURN_AROUND_START_FRAME

const uint RVC_TURN_AROUND_START_FRAME = 1
| static

Definition at line 70 of file roadveh.h.

## ◆ RVC_TURN_AROUND_START_FRAME_SHORT_TRAM

const uint RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16
| static

Definition at line 73 of file roadveh.h.