OpenTTD Source  20240915-master-g3784a3d3d6
vehicle_func.h File Reference
#include "gfx_type.h"
#include "direction_type.h"
#include "timer/timer_game_economy.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 std::vector< VehicleIDVehicleSet
 

Functions

template<VehicleType T>
bool IsValidImageIndex (uint8_t image_index)
 Helper to check whether an image index is valid for a particular vehicle. More...
 
void VehicleServiceInDepot (Vehicle *v)
 Service a vehicle and all subsequent vehicles in the consist. More...
 
uint CountVehiclesInChain (const Vehicle *v)
 
void FindVehicleOnPos (TileIndex tile, void *data, VehicleFromPosProc *proc)
 Find a vehicle from a specific location. More...
 
void FindVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc)
 Find a vehicle from a specific location. More...
 
bool HasVehicleOnPos (TileIndex tile, void *data, VehicleFromPosProc *proc)
 Checks whether a vehicle is on a specific location. More...
 
bool HasVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc)
 Checks whether a vehicle in on a specific location. More...
 
void CallVehicleTicks ()
 
uint8_t CalcPercentVehicleFilled (const Vehicle *v, StringID *colour)
 Calculates how full a vehicle is. More...
 
void VehicleLengthChanged (const Vehicle *u)
 Logs a bug in GRF and shows a warning message if this is for the first time this happened. More...
 
void ResetVehicleHash ()
 
void ResetVehicleColourMap ()
 
uint8_t GetBestFittingSubType (Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
 Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for. More...
 
void ViewportAddVehicles (DrawPixelInfo *dpi)
 Add the vehicle sprites that should be drawn at a part of the screen. More...
 
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. More...
 
CommandCost TunnelBridgeIsFree (TileIndex tile, TileIndex endtile, const Vehicle *ignore=nullptr)
 Finds vehicle in tunnel / bridge. More...
 
void DecreaseVehicleValue (Vehicle *v)
 Decrease the value of a vehicle. More...
 
void CheckVehicleBreakdown (Vehicle *v)
 
void EconomyAgeVehicle (Vehicle *v)
 Update economy age of a vehicle. More...
 
void AgeVehicle (Vehicle *v)
 Update age of a vehicle. More...
 
void RunVehicleCalendarDayProc ()
 Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.
 
void VehicleEnteredDepotThisTick (Vehicle *v)
 Adds a vehicle to the list of vehicles that visited a depot this tick. More...
 
UnitID GetFreeUnitNumber (VehicleType type)
 Get an unused unit number for a vehicle (if allowed). More...
 
void VehicleEnterDepot (Vehicle *v)
 Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc. More...
 
bool CanBuildVehicleInfrastructure (VehicleType type, uint8_t subtype=0)
 Check whether we can build infrastructure for the given vehicle type. More...
 
GetNewVehiclePosResult GetNewVehiclePos (const Vehicle *v)
 Get position information of a vehicle when moving one pixel in the direction it is facing. More...
 
Direction GetDirectionTowards (const Vehicle *v, int x, int y)
 
bool IsCompanyBuildableVehicleType (VehicleType type)
 Is the given vehicle type buildable by a company? More...
 
bool IsCompanyBuildableVehicleType (const BaseVehicle *v)
 Is the given vehicle buildable by a company? More...
 
LiveryScheme GetEngineLiveryScheme (EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
 Determines the LiveryScheme for a vehicle. More...
 
const struct LiveryGetEngineLivery (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, uint8_t livery_setting)
 Determines the livery for a vehicle. More...
 
SpriteID GetEnginePalette (EngineID engine_type, CompanyID company)
 Get the colour map for an engine. More...
 
SpriteID GetVehiclePalette (const Vehicle *v)
 Get the colour map for a vehicle. More...
 
StringID GetCmdBuildVehMsg (VehicleType type)
 
StringID GetCmdBuildVehMsg (const BaseVehicle *v)
 
StringID GetCmdSellVehMsg (VehicleType type)
 
StringID GetCmdSellVehMsg (const BaseVehicle *v)
 
StringID GetCmdRefitVehMsg (VehicleType type)
 
StringID GetCmdRefitVehMsg (const BaseVehicle *v)
 
StringID GetCmdSendToDepotMsg (VehicleType type)
 
StringID GetCmdSendToDepotMsg (const BaseVehicle *v)
 
CommandCost EnsureNoVehicleOnGround (TileIndex tile)
 Ensure there is no vehicle at the ground at the given position. More...
 
CommandCost EnsureNoTrainOnTrackBits (TileIndex tile, TrackBits track_bits)
 Tests if a vehicle interacts with the specified track bits. More...
 
bool CanVehicleUseStation (EngineID engine_type, const struct Station *st)
 
bool CanVehicleUseStation (const Vehicle *v, const struct Station *st)
 
StringID GetVehicleCannotUseStationReason (const Vehicle *v, const Station *st)
 Get reason string why this station can't be used by the given vehicle. More...
 
void ReleaseDisasterVehicle (VehicleID vehicle)
 Notify disasters that we are about to delete a vehicle. More...
 
void GetVehicleSet (VehicleSet &set, Vehicle *v, uint8_t num_vehicles)
 Calculates the set of vehicles that will be affected by a given selection. More...
 
void CheckCargoCapacity (Vehicle *v)
 Check the capacity of all vehicles in a chain and spread cargo if needed. More...
 
bool VehiclesHaveSameEngineList (const Vehicle *v1, const Vehicle *v2)
 Checks if two vehicle chains have the same list of engines. More...
 
bool VehiclesHaveSameOrderList (const Vehicle *v1, const Vehicle *v2)
 Checks if two vehicles have the same list of orders. More...
 
bool IsUniqueVehicleName (const std::string &name)
 Test if a name is unique among vehicle names. More...
 

Variables

static const TimerGameEconomy::Date VEHICLE_PROFIT_MIN_AGE = CalendarTime::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 StringID _veh_build_msg_table []
 
const StringID _veh_sell_msg_table []
 
const StringID _veh_refit_msg_table []
 
const StringID _send_to_depot_msg_table []
 

Detailed Description

Functions related to vehicles.

Definition in file vehicle_func.h.

Function Documentation

◆ AgeVehicle()

◆ CalcPercentVehicleFilled()

uint8_t 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 1493 of file vehicle.cpp.

References Vehicle::current_order, and Order::IsType().

◆ CanBuildVehicleInfrastructure()

bool CanBuildVehicleInfrastructure ( VehicleType  type,
uint8_t  subtype 
)

Check whether we can build infrastructure for the given vehicle type.

This to disable building stations etc. when you are not allowed/able to have the vehicle type yet.

Parameters
typethe vehicle type to check this for
Returns
true if there is any reason why you may build the infrastructure for the given vehicle type

Definition at line 1922 of file vehicle.cpp.

References _local_company, _settings_game, HasAnyRailTypesAvail(), HasAnyRoadTypesAvail(), IsCompanyBuildableVehicleType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.

Referenced by BuildAirToolbarWindow::OnInvalidateData(), BuildDocksToolbarWindow::OnInvalidateData(), and BuildRailToolbarWindow::OnInvalidateData().

◆ CheckCargoCapacity()

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 107 of file autoreplace_cmd.cpp.

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

◆ DecreaseVehicleValue()

void DecreaseVehicleValue ( Vehicle v)

◆ EconomyAgeVehicle()

◆ EnsureNoTrainOnTrackBits()

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 608 of file vehicle.cpp.

References VehicleFromPos().

Referenced by CmdConvertRail(), and EnsureNoTrainOnTrack().

◆ EnsureNoVehicleOnGround()

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 546 of file vehicle.cpp.

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

Referenced by CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdConvertRail(), DoBuildLock(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), and RemoveRoadWaypointStop().

◆ FindVehicleOnPos()

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 505 of file vehicle.cpp.

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

◆ FindVehicleOnPosXY()

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 445 of file vehicle.cpp.

Referenced by CheckTrainCollision().

◆ GetBestFittingSubType()

uint8_t 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 523 of file vehicle_gui.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, GetCargoSubtypeText(), Vehicle::GetEngine(), Vehicle::GetFirstEnginePart(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), HasBit(), include(), and MAX_REFIT_CYCLE.

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

◆ GetEngineLivery()

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

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. nullptr if in purchase list etc.
livery_settingThe livery settings to use for acquiring the livery information.
Returns
livery to use

Definition at line 2064 of file vehicle.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().

Referenced by LiveryHelper().

◆ GetEngineLiveryScheme()

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, nullptr if in purchase list etc.
Returns
livery scheme to use.

Definition at line 1970 of file vehicle.cpp.

◆ GetEnginePalette()

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 2142 of file vehicle.cpp.

◆ GetFreeUnitNumber()

UnitID GetFreeUnitNumber ( VehicleType  type)

Get an unused unit number for a vehicle (if allowed).

Parameters
typeType of vehicle
Returns
A unused unit number for the given type of vehicle if it is allowed to build one, else UINT16_MAX.

Definition at line 1895 of file vehicle.cpp.

References _settings_game, VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.

Referenced by CheckNewTrain(), and NormaliseTrainHead().

◆ GetNewVehiclePos()

GetNewVehiclePosResult GetNewVehiclePos ( const Vehicle v)

Get position information of a vehicle when moving one pixel in the direction it is facing.

Parameters
vVehicle to move
Returns
Position information after the move

Definition at line 1784 of file vehicle.cpp.

Referenced by DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Submarine(), DisasterTick_Zeppeliner(), and TrainController().

◆ GetVehicleCannotUseStationReason()

StringID GetVehicleCannotUseStationReason ( const Vehicle v,
const Station st 
)

Get reason string why this station can't be used by the given vehicle.

Parameters
vThe vehicle to test.
stThe station to test for.
Returns
The string explaining why the vehicle cannot use the station.

Definition at line 3104 of file vehicle.cpp.

References RoadVehicle::compatible_roadtypes, SpecializedVehicle< RoadVehicle, Type >::From(), Vehicle::HasArticulatedPart(), HasTileAnyRoadType(), IsBayRoadStopTile(), RoadVehicle::IsBus(), RoadStop::next, ROADSTOP_BUS, ROADSTOP_TRUCK, BaseVehicle::type, VEH_ROAD, VEH_TRAIN, and RoadStop::xy.

◆ GetVehiclePalette()

SpriteID GetVehiclePalette ( const Vehicle v)

Get the colour map for a vehicle.

Parameters
vVehicle to get colour map for
Returns
A ready-to-use palette modifier

Definition at line 2152 of file vehicle.cpp.

References Vehicle::IsGroundVehicle().

◆ GetVehicleSet()

void GetVehicleSet ( VehicleSet &  set,
Vehicle v,
uint8_t  num_vehicles 
)

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

Parameters
[in,out]setSet 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 3218 of file vehicle.cpp.

References SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), include(), 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(), and RefitVehicle().

◆ HasVehicleOnPos()

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-nullptr.

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-nullptr.

Definition at line 520 of file vehicle.cpp.

Referenced by CYapfCostShipT< Types >::PfCalcCost(), TrainApproachingCrossing(), and TrainOnCrossing().

◆ HasVehicleOnPosXY()

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-nullptr.

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-nullptr.

Definition at line 461 of file vehicle.cpp.

◆ IsCompanyBuildableVehicleType() [1/2]

bool IsCompanyBuildableVehicleType ( const BaseVehicle v)
inline

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.

◆ IsCompanyBuildableVehicleType() [2/2]

bool IsCompanyBuildableVehicleType ( VehicleType  type)
inline

◆ IsUniqueVehicleName()

bool IsUniqueVehicleName ( const std::string &  name)

Test if a name is unique among vehicle names.

Parameters
nameName to test.
Returns
True ifffffff the name is unique.

Definition at line 753 of file vehicle_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate().

Referenced by CloneVehicleName(), and CmdRenameVehicle().

◆ IsValidImageIndex()

template<VehicleType T>
bool IsValidImageIndex ( uint8_t  image_index)

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

Template Parameters
TThe type of vehicle.
Parameters
image_indexThe image index to check.
Returns
True iff the image index is valid.

◆ ReleaseDisasterVehicle()

void ReleaseDisasterVehicle ( VehicleID  vehicle)

Notify disasters that we are about to delete a vehicle.

So make them head elsewhere.

Parameters
vehicledeleted vehicle

Definition at line 981 of file disaster_vehicle.cpp.

References Vehicle::age, Vehicle::dest_tile, GetAircraftFlightLevelBounds(), SpecializedVehicle< DisasterVehicle, VEH_DISASTER >::GetIfValid(), RandomTile, ST_SMALL_UFO, DisasterVehicle::state, Vehicle::subtype, and Vehicle::z_pos.

◆ ShowNewGrfVehicleError()

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 317 of file vehicle.cpp.

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

Referenced by VehicleLengthChanged().

◆ TunnelBridgeIsFree()

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 575 of file vehicle.cpp.

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

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

◆ VehicleEnterDepot()

◆ VehicleEnteredDepotThisTick()

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 921 of file vehicle.cpp.

◆ VehicleLengthChanged()

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 346 of file vehicle.cpp.

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

Referenced by RoadVehUpdateCache().

◆ VehicleServiceInDepot()

◆ VehiclesHaveSameEngineList()

bool VehiclesHaveSameEngineList ( const Vehicle v1,
const Vehicle v2 
)

Checks if two vehicle chains have the same list of engines.

Parameters
v1First vehicle chain.
v1Second vehicle chain.
Returns
True if same, false if different.

Definition at line 3272 of file vehicle.cpp.

References Vehicle::GetEngine(), and Vehicle::GetNextVehicle().

Referenced by DepotWindow::OnVehicleSelect().

◆ VehiclesHaveSameOrderList()

bool VehiclesHaveSameOrderList ( const Vehicle v1,
const Vehicle v2 
)

Checks if two vehicles have the same list of orders.

Parameters
v1First vehicles.
v1Second vehicles.
Returns
True if same, false if different.

Definition at line 3289 of file vehicle.cpp.

References Order::Equals(), Vehicle::GetFirstOrder(), and Order::next.

Referenced by DepotWindow::OnVehicleSelect(), and OrdersWindow::OnVehicleSelect().

◆ ViewportAddVehicles()

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 1154 of file vehicle.cpp.

References MAX_VEHICLE_PIXEL_X.