OpenTTD
Data Structures | Macros | Typedefs | Functions | Variables
vehicle_func.h File Reference

Functions related to vehicles. More...

#include "gfx_type.h"
#include "direction_type.h"
#include "command_type.h"
#include "vehicle_type.h"
#include "engine_type.h"
#include "transport_type.h"
#include "newgrf_config.h"
#include "track_type.h"
#include "livery.h"

Go to the source code of this file.

Data Structures

struct  GetNewVehiclePosResult
 Position information of a vehicle after it moved. More...

Macros

#define is_custom_sprite(x)   (x >= 0xFD)
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x)   (x == 0xFD)
#define IS_CUSTOM_SECONDHEAD_SPRITE(x)   (x == 0xFE)

Typedefs

typedef VehicleVehicleFromPosProc (Vehicle *v, void *data)
typedef SmallVector< VehicleID, 2 > VehicleSet

Functions

template<VehicleType T>
bool IsValidImageIndex (uint8 image_index)
 Helper to check whether an image index is valid for a particular vehicle.
void VehicleServiceInDepot (Vehicle *v)
 Service a vehicle and all subsequent vehicles in the consist.
uint CountVehiclesInChain (const Vehicle *v)
void FindVehicleOnPos (TileIndex tile, void *data, VehicleFromPosProc *proc)
 Find a vehicle from a specific location.
void FindVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc)
 Find a vehicle from a specific location.
bool HasVehicleOnPos (TileIndex tile, void *data, VehicleFromPosProc *proc)
 Checks whether a vehicle is on a specific location.
bool HasVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc)
 Checks whether a vehicle in on a specific location.
void CallVehicleTicks ()
uint8 CalcPercentVehicleFilled (const Vehicle *v, StringID *colour)
 Calculates how full a vehicle is.
void VehicleLengthChanged (const Vehicle *u)
 Logs a bug in GRF and shows a warning message if this is for the first time this happened.
byte VehicleRandomBits ()
 Get a value for a vehicle's random_bits.
void ResetVehicleHash ()
void ResetVehicleColourMap ()
byte GetBestFittingSubType (Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
 Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
void ViewportAddVehicles (DrawPixelInfo *dpi)
 Add the vehicle sprites that should be drawn at a part of the screen.
void ShowNewGrfVehicleError (EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical)
 Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking.
CommandCost TunnelBridgeIsFree (TileIndex tile, TileIndex endtile, const Vehicle *ignore=NULL)
 Finds vehicle in tunnel / bridge.
void DecreaseVehicleValue (Vehicle *v)
 Decrease the value of a vehicle.
void CheckVehicleBreakdown (Vehicle *v)
void AgeVehicle (Vehicle *v)
 Update age of a vehicle.
void VehicleEnteredDepotThisTick (Vehicle *v)
 Adds a vehicle to the list of vehicles that visited a depot this tick.
UnitID GetFreeUnitNumber (VehicleType type)
 Get an unused unit number for a vehicle (if allowed).
void VehicleEnterDepot (Vehicle *v)
 Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc.
bool CanBuildVehicleInfrastructure (VehicleType type)
 Check whether we can build infrastructure for the given vehicle type.
GetNewVehiclePosResult GetNewVehiclePos (const Vehicle *v)
 Get position information of a vehicle when moving one pixel in the direction it is facing.
Direction GetDirectionTowards (const Vehicle *v, int x, int y)
static bool IsCompanyBuildableVehicleType (VehicleType type)
 Is the given vehicle type buildable by a company?
static bool IsCompanyBuildableVehicleType (const BaseVehicle *v)
 Is the given vehicle buildable by a company?
LiveryScheme GetEngineLiveryScheme (EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
 Determines the LiveryScheme for a vehicle.
struct LiveryGetEngineLivery (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting)
 Determines the livery for a vehicle.
SpriteID GetEnginePalette (EngineID engine_type, CompanyID company)
 Get the colour map for an engine.
SpriteID GetVehiclePalette (const Vehicle *v)
 Get the colour map for a vehicle.
static uint32 GetCmdBuildVeh (VehicleType type)
static uint32 GetCmdBuildVeh (const BaseVehicle *v)
static uint32 GetCmdSellVeh (VehicleType type)
static uint32 GetCmdSellVeh (const BaseVehicle *v)
static uint32 GetCmdRefitVeh (VehicleType type)
static uint32 GetCmdRefitVeh (const BaseVehicle *v)
static uint32 GetCmdSendToDepot (VehicleType type)
static uint32 GetCmdSendToDepot (const BaseVehicle *v)
CommandCost EnsureNoVehicleOnGround (TileIndex tile)
 Ensure there is no vehicle at the ground at the given position.
CommandCost EnsureNoTrainOnTrackBits (TileIndex tile, TrackBits track_bits)
 Tests if a vehicle interacts with the specified track bits.
bool CanVehicleUseStation (EngineID engine_type, const struct Station *st)
bool CanVehicleUseStation (const Vehicle *v, const struct Station *st)
void ReleaseDisastersTargetingVehicle (VehicleID vehicle)
 Notify disasters that we are about to delete a vehicle.
void GetVehicleSet (VehicleSet &set, Vehicle *v, uint8 num_vehicles)
 Calculates the set of vehicles that will be affected by a given selection.
void CheckCargoCapacity (Vehicle *v)
 Check the capacity of all vehicles in a chain and spread cargo if needed.

Variables

static const int VEHICLE_PROFIT_MIN_AGE = DAYS_IN_YEAR * 2
 Only vehicles older than this have a meaningful profit.
static const Money VEHICLE_PROFIT_THRESHOLD = 10000
 Threshold for a vehicle to be considered making good profit.
const uint32 _veh_build_proc_table []
const uint32 _veh_sell_proc_table []
const uint32 _veh_refit_proc_table []
const uint32 _send_to_depot_proc_table []
VehicleID _new_vehicle_id
uint16 _returned_refit_capacity
 Stores the capacity after a refit operation.
uint16 _returned_mail_refit_capacity
 Stores the mail capacity after a refit operation (Aircraft only).

Detailed Description

Functions related to vehicles.

Definition in file vehicle_func.h.

Function Documentation

void AgeVehicle ( Vehicle v)
uint8 CalcPercentVehicleFilled ( const Vehicle front,
StringID colour 
)

Calculates how full a vehicle is.

Parameters
frontThe front vehicle of the consist to check.
colourThe string to show depending on if we are unloading or loading
Returns
A percentage of how full the Vehicle is. Percentages are rounded towards 50%, so that 0% and 100% are only returned if the vehicle is completely empty or full. This is useful for both display and conditional orders.

Definition at line 1297 of file vehicle.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CeilDiv(), Vehicle::current_order, SpecializedStation< Station, false >::GetIfValid(), Order::GetLoadType(), Station::goods, HasBit(), GoodsEntry::HasRating(), Order::IsType(), Vehicle::last_station_visited, max(), Vehicle::Next(), OLFB_FULL_LOAD, OLFB_NO_LOAD, VehicleCargoList::StoredCount(), BaseConsist::vehicle_flags, VF_CARGO_UNLOADING, VF_LOADING_FINISHED, and VF_STOP_LOADING.

Referenced by LoadUnloadVehicle(), and ProcessConditionalOrder().

bool CanBuildVehicleInfrastructure ( VehicleType  type)
void CheckCargoCapacity ( Vehicle v)

Check the capacity of all vehicles in a chain and spread cargo if needed.

Parameters
vThe vehicle to check.
Precondition
You can only do this if the consist is not loading or unloading. It must not carry reserved cargo, nor cargo to be unloaded or transferred.

Definition at line 99 of file autoreplace_cmd.cpp.

References Vehicle::First(), min(), CargoList< VehicleCargoList, CargoPacketList >::MTA_KEEP, and Vehicle::Next().

Referenced by CmdMoveRailVehicle(), and ReplaceChain().

void DecreaseVehicleValue ( Vehicle v)
CommandCost EnsureNoTrainOnTrackBits ( TileIndex  tile,
TrackBits  track_bits 
)

Tests if a vehicle interacts with the specified track bits.

All track bits interact except parallel TRACK_BIT_HORZ or TRACK_BIT_VERT.

Parameters
tileThe tile.
track_bitsThe track bits.
Returns
true if no train that interacts, is found. false if a train is found.

Definition at line 536 of file vehicle.cpp.

References return_cmd_error, BaseVehicle::type, and VehicleFromPos().

Referenced by EnsureNoTrainOnTrack(), and ExploreSegment().

CommandCost EnsureNoVehicleOnGround ( TileIndex  tile)

Ensure there is no vehicle at the ground at the given position.

Parameters
tilePosition to examine.
Returns
Succeeded command (ground is free) or failed command (a vehicle is found).

Definition at line 474 of file vehicle.cpp.

References EnsureNoVehicleProcZ(), GetTileMaxPixelZ(), return_cmd_error, BaseVehicle::type, and VehicleFromPos().

Referenced by CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildObject(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), DoBuildLock(), IsValidTileForWaypoint(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRoad(), and RemoveRoadStop().

void FindVehicleOnPos ( TileIndex  tile,
void *  data,
VehicleFromPosProc *  proc 
)

Find a vehicle from a specific location.

It will call proc for ALL vehicles on the tile and YOU must make SURE that the "best one" is stored in the data value and is ALWAYS the same regardless of the order of the vehicles where proc was called on! When you fail to do this properly you create an almost untraceable DESYNC!

Note
The return value of proc will be ignored.
Use this function when you have the intention that all vehicles should be iterated over.
Parameters
tileThe location on the map
dataArbitrary data passed to proc.
procThe proc that determines whether a vehicle will be "found".

Definition at line 433 of file vehicle.cpp.

References VehicleFromPos().

Referenced by CheckTrainCollision(), CmdConvertRail(), DeleteLastWagon(), FloodVehicles(), FollowTrainReservation(), GetTrainForReservation(), RoadStop::Entry::Rebuild(), and RemoveRoadStop().

void FindVehicleOnPosXY ( int  x,
int  y,
void *  data,
VehicleFromPosProc *  proc 
)

Find a vehicle from a specific location.

It will call proc for ALL vehicles on the tile and YOU must make SURE that the "best one" is stored in the data value and is ALWAYS the same regardless of the order of the vehicles where proc was called on! When you fail to do this properly you create an almost untraceable DESYNC!

Note
The return value of proc will be ignored.
Use this when you have the intention that all vehicles should be iterated over.
Parameters
xThe X location on the map
yThe Y location on the map
dataArbitrary data passed to proc
procThe proc that determines whether a vehicle will be "found".

Definition at line 373 of file vehicle.cpp.

References VehicleFromPosXY().

Referenced by CheckTrainCollision().

byte GetBestFittingSubType ( Vehicle v_from,
Vehicle v_for,
CargoID  dest_cargo_type 
)

Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.

All articulated parts of both vehicles are tested to find a possibly shared subtype. For v_for only vehicle refittable to dest_cargo_type are considered.

Parameters
v_fromthe vehicle to match the subtype from
v_forthe vehicle to get the subtype for
dest_cargo_typeDestination cargo type.
Returns
the best sub type

Definition at line 230 of file vehicle_gui.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, SmallVector< T, S >::Clear(), SmallVector< T, S >::Contains(), GetCargoSubtypeText(), Vehicle::GetEngine(), Vehicle::GetFirstEnginePart(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), HasBit(), SmallVector< T, S >::Include(), SmallVector< T, S >::Length(), and MAX_REFIT_CYCLE.

Referenced by BuildReplacementVehicle(), CmdCloneVehicle(), LinkRefresher::HandleRefit(), and RefitVehicle().

struct Livery* GetEngineLivery ( EngineID  engine_type,
CompanyID  company,
EngineID  parent_engine_type,
const Vehicle v,
byte  livery_setting 
)
read

Determines the livery for a vehicle.

Parameters
engine_typeEngineID of the vehicle
companyOwner of the vehicle
parent_engine_typeEngineID of the front vehicle. INVALID_VEHICLE if vehicle is at front itself.
vthe vehicle. NULL if in purchase list etc.
livery_settingThe livery settings to use for acquiring the livery information.
Returns
livery to use

Definition at line 1807 of file vehicle.cpp.

References _local_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetEngineLiveryScheme(), Livery::in_use, LIT_ALL, and LIT_COMPANY.

Referenced by LiveryHelper().

LiveryScheme GetEngineLiveryScheme ( EngineID  engine_type,
EngineID  parent_engine_type,
const Vehicle v 
)

Determines the LiveryScheme for a vehicle.

Parameters
engine_typeEngine of the vehicle.
parent_engine_typeEngine of the front vehicle, INVALID_ENGINE if vehicle is at front itself.
vthe vehicle, NULL if in purchase list etc.
Returns
livery scheme to use.

Definition at line 1717 of file vehicle.cpp.

References AIR_CTOL, Vehicle::cargo_type, CC_PASSENGERS, CT_INVALID, EC_DIESEL, EC_ELECTRIC, EC_MAGLEV, EC_MONORAIL, EC_STEAM, EF_RAIL_IS_MU, EF_ROAD_TRAM, Vehicle::First(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), HasBit(), INVALID_ENGINE, Vehicle::IsArticulatedPart(), IsCargoInClass(), RAILVEH_WAGON, UsesWagonOverride(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by FinaliseEngineArray(), and GetEngineLivery().

SpriteID GetEnginePalette ( EngineID  engine_type,
CompanyID  company 
)

Get the colour map for an engine.

This used for unbuilt engines in the user interface.

Parameters
engine_typeID of engine
companyID of company
Returns
A ready-to-use palette modifier

Definition at line 1875 of file vehicle.cpp.

References INVALID_ENGINE.

Referenced by DrawEngineList(), EnginePreviewWindow::DrawWidget(), and NewsWindow::DrawWidget().

UnitID GetFreeUnitNumber ( VehicleType  type)
GetNewVehiclePosResult GetNewVehiclePos ( const Vehicle v)
SpriteID GetVehiclePalette ( const Vehicle v)
void GetVehicleSet ( VehicleSet set,
Vehicle v,
uint8  num_vehicles 
)

Calculates the set of vehicles that will be affected by a given selection.

Parameters
set[inout] Set of affected vehicles.
vFirst vehicle of the selection.
num_vehiclesNumber of vehicles in the selection (not counting articulated parts).
Precondition
set must be empty.
Postcondition
set will contain the vehicles that will be refitted.

Definition at line 2789 of file vehicle.cpp.

References SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsArticulatedPart(), GroundVehicle< T, Type >::IsMultiheaded(), SpecializedVehicle< T, Type >::Next(), BaseVehicle::type, and VEH_TRAIN.

Referenced by RefitWindow::BuildRefitList(), RefitWindow::DrawWidget(), and RefitVehicle().

bool HasVehicleOnPos ( TileIndex  tile,
void *  data,
VehicleFromPosProc *  proc 
)

Checks whether a vehicle is on a specific location.

It will call proc for vehicles until it returns non-NULL.

Note
Use FindVehicleOnPos when you have the intention that all vehicles should be iterated over.
Parameters
tileThe location on the map
dataArbitrary data passed to proc.
procThe proc that determines whether a vehicle will be "found".
Returns
True if proc returned non-NULL.

Definition at line 448 of file vehicle.cpp.

References VehicleFromPos().

Referenced by CheckRoadBlockedForOvertaking(), ExploreSegment(), TrainApproachingCrossing(), TrainController(), and UpdateLevelCrossing().

bool HasVehicleOnPosXY ( int  x,
int  y,
void *  data,
VehicleFromPosProc *  proc 
)

Checks whether a vehicle in on a specific location.

It will call proc for vehicles until it returns non-NULL.

Note
Use FindVehicleOnPosXY when you have the intention that all vehicles should be iterated over.
Parameters
xThe X location on the map
yThe Y location on the map
dataArbitrary data passed to proc
procThe proc that determines whether a vehicle will be "found".
Returns
True if proc returned non-NULL.

Definition at line 389 of file vehicle.cpp.

References VehicleFromPosXY().

static bool IsCompanyBuildableVehicleType ( VehicleType  type)
inlinestatic
static bool IsCompanyBuildableVehicleType ( const BaseVehicle v)
inlinestatic

Is the given vehicle buildable by a company?

Parameters
vVehicle being queried.
Returns
Vehicle is buildable by a company.

Definition at line 109 of file vehicle_func.h.

References IsCompanyBuildableVehicleType(), and BaseVehicle::type.

template<VehicleType T>
bool IsValidImageIndex ( uint8  image_index)

Helper to check whether an image index is valid for a particular vehicle.

Parameters
<T>The type of vehicle.
image_indexThe image index to check.
Returns
True iff the image index is valid.
void ReleaseDisastersTargetingVehicle ( VehicleID  vehicle)

Notify disasters that we are about to delete a vehicle.

So make them head elsewhere.

Parameters
vehicledeleted vehicle

Definition at line 958 of file disaster_vehicle.cpp.

References Vehicle::age, Vehicle::current_order, Vehicle::dest_tile, FOR_ALL_DISASTERVEHICLES, GetAircraftFlightLevelBounds(), Order::GetDestination(), RandomTile, Order::SetDestination(), ST_SMALL_UFO, Vehicle::subtype, and Vehicle::z_pos.

Referenced by Vehicle::PreDestructor().

void ShowNewGrfVehicleError ( EngineID  engine,
StringID  part1,
StringID  part2,
GRFBugs  bug_type,
bool  critical 
)

Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking.

Parameters
engineThe engine that caused the problem
part1Part 1 of the error message, taking the grfname as parameter 1
part2Part 2 of the error message, taking the engine as parameter 2
bug_typeFlag to check and set in grfconfig
criticalShall the "OpenTTD might crash"-message be shown when the player tries to unpause?

Definition at line 233 of file vehicle.cpp.

References _networking, CMD_PAUSE, DC_EXEC, DEBUG, DoCommand(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetGRFConfig(), Engine::GetGRFID(), GRFConfig::GetName(), GRFConfig::grf_bugs, HasBit(), lastof, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, SetBit(), SetDParam(), SetDParamStr(), ShowErrorMessage(), and WL_CRITICAL.

Referenced by CheckConsistencyOfArticulatedVehicle(), Train::ConsistChanged(), Vehicle::UpdateVisualEffect(), and VehicleLengthChanged().

CommandCost TunnelBridgeIsFree ( TileIndex  tile,
TileIndex  endtile,
const Vehicle ignore 
)

Finds vehicle in tunnel / bridge.

Parameters
tilefirst end
endtilesecond end
ignoreIgnore this vehicle when searching
Returns
Succeeded command (if tunnel/bridge is free) or failed command (if a vehicle is using the tunnel/bridge).

Definition at line 503 of file vehicle.cpp.

References GetVehicleTunnelBridgeProc(), return_cmd_error, BaseVehicle::type, and VehicleFromPos().

Referenced by ClearPathReservation(), CmdBuildRoad(), CmdConvertRail(), DoClearBridge(), DoClearTunnel(), and RemoveRoad().

void VehicleEnterDepot ( Vehicle v)

Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc.

Parameters
vVehicle that entered a depot.

Definition at line 1356 of file vehicle.cpp.

References _current_company, _local_company, _settings_client, AddVehicleAdviceNewsItem(), CCF_ARRANGE, ClrBit(), Train::ConsistChanged(), BaseConsist::cur_real_order_index, Vehicle::cur_speed, Vehicle::current_order, DC_EXEC, Vehicle::DeleteUnreachedImplicitOrders(), Vehicle::dest_tile, DoCommand(), CommandCost::Failed(), Vehicle::First(), SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Ship, VEH_SHIP >::From(), CommandCost::GetCost(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetDestination(), Vehicle::GetOrder(), Order::GetRefitCargo(), GetStationIndex(), ClientSettings::gui, HandleAircraftEnterHangar(), Vehicle::IncrementImplicitOrderIndex(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, InvalidateWindowData(), Order::IsRefit(), Order::IsType(), Vehicle::last_loading_station, Order::MakeDummy(), Vehicle::MarkDirty(), MarkTileDirtyByTile(), AI::NewEvent(), ODATFB_HALT, ODATFB_NEAREST_DEPOT, ODTFB_PART_OF_ORDERS, Vehicle::owner, Vehicle::profit_this_year, Backup< T >::Restore(), SetDepotReservation(), SetDParam(), SetWindowClassesDirty(), SetWindowDirty(), GUISettings::show_track_reservation, ShowCostOrIncomeAnimation(), Ship::state, TFP_NONE, Vehicle::tile, TRACK_BIT_DEPOT, BaseVehicle::type, Ship::UpdateCache(), UpdateSignalsOnSegment(), UpdateVehicleTimetable(), SpecializedVehicle< T, Type >::UpdateViewport(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, VehicleServiceInDepot(), Vehicle::vehstatus, VRF_TOGGLE_REVERSE, VS_HIDDEN, Train::wait_counter, WC_AIRCRAFT_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_TRAINS_LIST, WC_VEHICLE_DEPOT, WC_VEHICLE_VIEW, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by AircraftEventHandler_EnterHangar(), AircraftEventHandler_InHangar(), CheckTrainStayInDepot(), and VehicleEnter_Track().

void VehicleEnteredDepotThisTick ( Vehicle v)

Adds a vehicle to the list of vehicles that visited a depot this tick.

Parameters
*vvehicle to add

Definition at line 829 of file vehicle.cpp.

References Vehicle::vehstatus, and VS_STOPPED.

void VehicleLengthChanged ( const Vehicle u)

Logs a bug in GRF and shows a warning message if this is for the first time this happened.

Parameters
ufirst vehicle of chain

Definition at line 266 of file vehicle.cpp.

References Vehicle::engine_type, GamelogGRFBugReverse(), GBUG_VEH_LENGTH, Vehicle::GetEngine(), GetGRFConfig(), GRFConfig::grf_bugs, Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), GRFFilePropsBase< Tcnt >::local_id, and ShowNewGrfVehicleError().

Referenced by Train::ConsistChanged(), and RoadVehUpdateCache().

byte VehicleRandomBits ( )

Get a value for a vehicle's random_bits.

Returns
A random value from 0 to 255.

Definition at line 298 of file vehicle.cpp.

References GB().

Referenced by AddArticulatedParts(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), and CmdBuildShip().

void VehicleServiceInDepot ( Vehicle v)
void ViewportAddVehicles ( DrawPixelInfo dpi)

Add the vehicle sprites that should be drawn at a part of the screen.

Parameters
dpiRectangle being drawn.

Definition at line 1033 of file vehicle.cpp.

References Vehicle::coord, DoDrawVehicle(), GB(), Vehicle::hash_viewport_next, Vehicle::vehstatus, and VS_HIDDEN.