# RoadVehicle Struct Reference

Buses, trucks and trams belong to this class. More...

`#include <roadveh.h>`

Inheritance diagram for RoadVehicle:

## Public Member Functions
| RoadVehicle ()
| We don't want GCC to zero our struct! It already is zeroed and has an index!
virtual | ~RoadVehicle ()
| We want to 'destruct' the right class.
const char * | GetTypeString () const
void | MarkDirty ()
void | UpdateDeltaXY (Direction direction)
ExpensesType | GetExpenseType (bool income) const
bool | IsPrimaryVehicle () const
SpriteID | GetImage (Direction direction) const
int | GetDisplaySpeed () const
int | GetDisplayMaxSpeed () const
Money | GetRunningCost () const
int | GetDisplayImageWidth (Point *offset=NULL) const
| Get the width of a road vehicle image in the GUI.
bool | IsInDepot () const
bool | IsStoppedInDepot () const
bool | Tick ()
void | OnNewDay ()
uint | Crash (bool flooded=false)
Trackdir | GetVehicleTrackdir () const
TileIndex | GetOrderStationLocation (StationID station)
bool | FindClosestDepot (TileIndex *location, DestinationID *destination, bool *reverse)
bool | IsBus () const
| Check whether a roadvehicle is a bus.
FORCEINLINE bool | IsRoadVehFront () const
| Check if vehicle is a front engine.
FORCEINLINE void | SetRoadVehFront ()
| Set front engine state.
FORCEINLINE bool | IsArticulatedPart () const
| Check if vehicl is an articulated part of an engine.
FORCEINLINE void | SetArticulatedPart ()
| Set a vehicle to be an articulated part.
FORCEINLINE bool | HasArticulatedPart () const
| Check if an engine has an articulated part.
## Data Fields
RoadVehicleCache | rcache
| Cache of often used calculated values.
byte | state
byte | frame
uint16 | blocked_ctr
byte | overtaking
byte | overtaking_ctr
uint16 | crashed_ctr
byte | reverse_ctr
RoadType | roadtype
RoadTypes | compatible_roadtypes

## Detailed Description

Buses, trucks and trams belong to this class.

Definition at line 92 of file roadveh.h.

## Constructor & Destructor Documentation

virtual RoadVehicle::~RoadVehicle | ( |  | ) | `[inline, virtual]`

We want to 'destruct' the right class.

Definition at line 108 of file roadveh.h.

## Member Function Documentation

int RoadVehicle::GetDisplayImageWidth | ( | Point * | offset = `NULL` | ) | const

Get the width of a road vehicle image in the GUI.

Parameters:

  | offset | Additional offset for positioning the sprite; set to NULL if not needed

Returns:
  Width in pixels

Definition at line 103 of file roadveh_cmd.cpp.

References RoadVehicleCache::cached_veh_length, rcache, Point::x, and Point::y.

Referenced by DrawRoadVehImage().

bool RoadVehicle::IsBus | ( |  | ) | const

Check whether a roadvehicle is a bus.

Returns:
  true if bus

Definition at line 92 of file roadveh_cmd.cpp.

References CC_PASSENGERS, IsCargoInClass(), and IsRoadVehFront().

Referenced by CmdCloneOrder(), and RoadFindPathToDest().

FORCEINLINE bool RoadVehicle::IsRoadVehFront | ( |  | ) | const`[inline]`

Check if vehicle is a front engine.

Returns:
  Returns true if vehicle is a front engine

Definition at line 135 of file roadveh.h.

Referenced by AfterLoadVehicles(), DisasterTick_Ufo(), and IsBus().

FORCEINLINE bool RoadVehicle::IsArticulatedPart | ( |  | ) | const`[inline]`

Check if vehicl is an articulated part of an engine.

Returns:
  Returns true if vehicle is an articulated part

Definition at line 146 of file roadveh.h.

Referenced by HasArticulatedPart().

FORCEINLINE bool RoadVehicle::HasArticulatedPart | ( |  | ) | const`[inline]`

Check if an engine has an articulated part.

Returns:
  True if the engine has an articulated part.

Definition at line 157 of file roadveh.h.

References IsArticulatedPart(), and SpecializedVehicle< RoadVehicle, VEH_ROAD >::Next().

Referenced by CheckConsistencyOfArticulatedVehicle(), CmdCloneVehicle(), DrawRoadVehDetails(), RoadStop::Enter(), IsArticulatedVehicleCarryingDifferentCargos(), and RoadFindPathToDest().

## Field Documentation

byte RoadVehicle::state

See also:
  RoadVehicleStates

Definition at line 94 of file roadveh.h.

Referenced by CmdBuildRoadVeh(), CmdTurnRoadVeh(), RoadStop::Enter(), FindVehiclesInRoadStop(), and RoadStop::Leave().

The documentation for this struct was generated from the following files:

- src/roadveh.h
- src/roadveh_cmd.cpp