OpenTTD Source: src/vehicle.cpp File Reference

OpenTTD Source 15.3

Typedefs | Functions | Variables
vehicle.cpp File Reference

Base implementations of all vehicles. More...

`#include "stdafx.h"`
`#include "error.h"`
`#include "roadveh.h"`
`#include "ship.h"`
`#include "spritecache.h"`
`#include "timetable.h"`
`#include "viewport_func.h"`
`#include "news_func.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "train.h"`
`#include "aircraft.h"`
`#include "newgrf_debug.h"`
`#include "newgrf_sound.h"`
`#include "newgrf_station.h"`
`#include "group_gui.h"`
`#include "strings_func.h"`
`#include "zoom_func.h"`
`#include "vehicle_func.h"`
`#include "autoreplace_func.h"`
`#include "autoreplace_gui.h"`
`#include "station_base.h"`
`#include "ai/ai.hpp"`
`#include "depot_func.h"`
`#include "network/network.h"`
`#include "core/pool_func.hpp"`
`#include "economy_base.h"`
`#include "articulated_vehicles.h"`
`#include "roadstop_base.h"`
`#include "core/random_func.hpp"`
`#include "core/backup_type.hpp"`
`#include "core/container_func.hpp"`
`#include "order_backup.h"`
`#include "sound_func.h"`
`#include "effectvehicle_func.h"`
`#include "effectvehicle_base.h"`
`#include "vehiclelist.h"`
`#include "bridge_map.h"`
`#include "tunnel_map.h"`
`#include "depot_map.h"`
`#include "gamelog.h"`
`#include "linkgraph/linkgraph.h"`
`#include "linkgraph/refresh.h"`
`#include "framerate_type.h"`
`#include "autoreplace_cmd.h"`
`#include "misc_cmd.h"`
`#include "train_cmd.h"`
`#include "vehicle_cmd.h"`
`#include "newgrf_roadstop.h"`
`#include "timer/timer.h"`
`#include "timer/timer_game_calendar.h"`
`#include "timer/timer_game_economy.h"`
`#include "timer/timer_game_tick.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Typedefs
using | AutoreplaceMap = std::map< VehicleID, bool >
| List of vehicles that should check for autoreplace this tick.

## Functions
static uint | GetViewportHashX (int x)
static uint | GetViewportHashY (int y)
static uint | GetViewportHash (int x, int y)
void | VehicleServiceInDepot (Vehicle *v)
| Service a vehicle and all subsequent vehicles in the consist.
void | ShowNewGrfVehicleError (EngineID engine, StringID part1, StringID part2, GRFBug bug_type, bool critical)
| Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking.
void | VehicleLengthChanged (const Vehicle *u)
| Logs a bug in GRF and shows a warning message if this is for the first time this happened.
static uint | GetTileHash1D (uint p)
| Compute hash for 1D tile coordinate.
static uint | IncTileHash1D (uint h)
| Increment 1D hash to next bucket.
static uint | ComposeTileHash (uint hx, uint hy)
| Compose two 1D hashes into 2D hash.
static uint | GetTileHash (uint x, uint y)
| Compute hash for tile coordinate.
CommandCost | EnsureNoVehicleOnGround (TileIndex tile)
| Ensure there is no vehicle at the ground at the given position.
CommandCost | TunnelBridgeIsFree (TileIndex tile, TileIndex endtile, const Vehicle *ignore)
| Finds vehicle in tunnel / bridge.
CommandCost | EnsureNoTrainOnTrackBits (TileIndex tile, TrackBits track_bits)
| Tests if a vehicle interacts with the specified track bits.
static void | UpdateVehicleTileHash (Vehicle *v, bool remove)
static void | UpdateVehicleViewportHash (Vehicle *v, int x, int y, int old_x, int old_y)
void | ResetVehicleHash ()
void | ResetVehicleColourMap ()
void | InitializeVehicles ()
uint | CountVehiclesInChain (const Vehicle *v)
static void | VehicleEnteredDepotThisTick (Vehicle *v)
| Adds a vehicle to the list of vehicles that visited a depot this tick.
void | RunVehicleCalendarDayProc ()
| Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.
static void | RunEconomyVehicleDayProc ()
| Increases the day counter for all vehicles and calls 1-day and 32-day handlers.
void | CallVehicleTicks ()
static void | DoDrawVehicle (const Vehicle *v)
| Add vehicle sprite for drawing to the screen.
void | ViewportAddVehicles (DrawPixelInfo *dpi)
| Add the vehicle sprites that should be drawn at a part of the screen.
Vehicle * | CheckClickOnVehicle (const Viewport &vp, int x, int y)
| Find the vehicle close to the clicked coordinates.
void | DecreaseVehicleValue (Vehicle *v)
| Decrease the value of a vehicle.
void | CheckVehicleBreakdown (Vehicle *v)
void | EconomyAgeVehicle (Vehicle *v)
| Update economy age of a vehicle.
void | AgeVehicle (Vehicle *v)
| Update age of a vehicle.
uint8_t | CalcPercentVehicleFilled (const Vehicle *front, StringID *colour)
| Calculates how full a vehicle is.
void | VehicleEnterDepot (Vehicle *v)
| Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc.
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)
VehicleEnterTileStates | VehicleEnterTile (Vehicle *v, TileIndex tile, int x, int y)
| Call the tile callback function for a vehicle entering a tile.
UnitID | GetFreeUnitNumber (VehicleType type)
| Get an unused unit number for a vehicle (if allowed).
bool | CanBuildVehicleInfrastructure (VehicleType type, uint8_t subtype)
| Check whether we can build infrastructure for the given vehicle type.
LiveryScheme | GetEngineLiveryScheme (EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
| Determines the LiveryScheme for a vehicle.
const Livery * | GetEngineLivery (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, uint8_t livery_setting)
| Determines the livery for a vehicle.
static PaletteID | GetEngineColourMap (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
PaletteID | GetEnginePalette (EngineID engine_type, CompanyID company)
| Get the colour map for an engine.
PaletteID | GetVehiclePalette (const Vehicle *v)
| Get the colour map for a vehicle.
static bool | PreviousOrderIsUnbunching (const Vehicle *v)
| Check if the previous order is a depot unbunching order.
static void | SpawnAdvancedVisualEffect (const Vehicle *v)
| Call CBID_VEHICLE_SPAWN_VISUAL_EFFECT and spawn requested effects.
static bool | IsBridgeAboveVehicle (const Vehicle *v)
| Test if a bridge is above a vehicle.
bool | CanVehicleUseStation (EngineID engine_type, const Station *st)
| Can this station be used by the given engine type?
bool | CanVehicleUseStation (const Vehicle *v, const Station *st)
| Can this station be used by the given vehicle?
StringID | GetVehicleCannotUseStationReason (const Vehicle *v, const Station *st)
| Get reason string why this station can't be used by the given vehicle.
void | GetVehicleSet (VehicleSet &set, Vehicle *v, uint8_t num_vehicles)
| Calculates the set of vehicles that will be affected by a given selection.
bool | VehiclesHaveSameEngineList (const Vehicle *v1, const Vehicle *v2)
| Checks if two vehicle chains have the same list of engines.
bool | VehiclesHaveSameOrderList (const Vehicle *v1, const Vehicle *v2)
| Checks if two vehicles have the same list of orders.

## Variables
static const uint | GEN_HASHX_BITS = 6
static const uint | GEN_HASHY_BITS = 6
static const uint | GEN_HASHX_BUCKET_BITS = 7
static const uint | GEN_HASHY_BUCKET_BITS = 6
static const uint | GEN_HASHX_SIZE = 1 << (GEN_HASHX_BUCKET_BITS + GEN_HASHX_BITS + ZOOM_BASE_SHIFT)
static const uint | GEN_HASHY_SIZE = 1 << (GEN_HASHY_BUCKET_BITS + GEN_HASHY_BITS + ZOOM_BASE_SHIFT)
static const uint | GEN_HASHX_INC = 1
static const uint | GEN_HASHY_INC = 1 << GEN_HASHX_BITS
static const uint | GEN_HASHX_MASK = (1 << GEN_HASHX_BITS) - 1
static const uint | GEN_HASHY_MASK = ((1 << GEN_HASHY_BITS) - 1) << GEN_HASHX_BITS
VehiclePool | _vehicle_pool ("Vehicle")
| The pool with all our precious vehicles.
constexpr uint | TILE_HASH_BITS = 7
constexpr uint | TILE_HASH_SIZE = 1 << TILE_HASH_BITS
constexpr uint | TILE_HASH_MASK = TILE_HASH_SIZE - 1
constexpr uint | TOTAL_TILE_HASH_SIZE = 1 << (TILE_HASH_BITS * 2)
constexpr uint | TILE_HASH_RES = 0
static std::array< Vehicle *, TOTAL_TILE_HASH_SIZE > | _vehicle_tile_hash {}
static std::array< Vehicle *, 1<<(GEN_HASHX_BITS+GEN_HASHY_BITS)> | _vehicle_viewport_hash {}
static AutoreplaceMap | _vehicles_to_autoreplace
static const uint8_t | _breakdown_chance [64]
static const Direction | _new_direction_table []
static const int8_t | _vehicle_smoke_pos [8]
static const IntervalTimer< TimerGameEconomy > | _economy_vehicles_yearly ({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::VEHICLE}, [](auto) { for(Vehicle *v :Vehicle::Iterate()) { if(v->IsPrimaryVehicle()) { Money profit=v->GetDisplayProfitThisYear();if(v->economy_age >=VEHICLE_PROFIT_MIN_AGE &&profit< 0) { if(_settings_client.gui.vehicle_income_warn &&v->owner==_local_company) { AddVehicleAdviceNewsItem(AdviceType::VehicleUnprofitable, GetEncodedString(TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_VEHICLE_UNPROFITABLE_PERIOD :STR_NEWS_VEHICLE_UNPROFITABLE_YEAR, v->index, profit), v->index);} AI::NewEvent(v->owner, new ScriptEventVehicleUnprofitable(v->index));} v->profit_last_year=v->profit_this_year;v->profit_this_year=0;SetWindowDirty(WC_VEHICLE_DETAILS, v->index);} } GroupStatistics::UpdateProfits();SetWindowClassesDirty(WC_TRAINS_LIST);SetWindowClassesDirty(WC_SHIPS_LIST);SetWindowClassesDirty(WC_ROADVEH_LIST);SetWindowClassesDirty(WC_AIRCRAFT_LIST);})

## Detailed Description

Base implementations of all vehicles.

Definition in file vehicle.cpp.

## Typedef Documentation

## ◆ AutoreplaceMap

using AutoreplaceMap = std::map<VehicleID, bool>

List of vehicles that should check for autoreplace this tick.

Mapping of vehicle -> leave depot immediately after autoreplace.

Definition at line 665 of file vehicle.cpp.

## Function Documentation

## ◆ AgeVehicle()

void AgeVehicle | ( | Vehicle * | v | ) |

Update age of a vehicle.

Parameters

  v | Vehicle to update.

Definition at line 1410 of file vehicle.cpp.

References _local_company, _settings_client, AddVehicleAdviceNewsItem(), Vehicle::age, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Engine::company_avail, TimerGame< struct Calendar >::DateAtStartOfYear(), TimerGameConst< struct Calendar >::DAYS_IN_LEAP_YEAR, CompanySettings::engine_renew, Vehicle::engine_type, EngineHasReplacementForCompany(), SpecializedVehicle< T, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetEncodedString(), Vehicle::GetEngine(), Vehicle::group_id, ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Vehicle::max_age, TimerGameConst< struct Calendar >::MAX_DATE, GUISettings::old_vehicle_warn, Vehicle::owner, Vehicle::Previous(), Vehicle::reliability_spd_dec, CompanyProperties::settings, SetWindowDirty(), BaseVehicle::type, VEH_TRAIN, VehicleOld, Vehicle::vehstatus, and WC_VEHICLE_DETAILS.

Referenced by Aircraft::OnNewCalendarDay(), RoadVehicle::OnNewCalendarDay(), Ship::OnNewCalendarDay(), and Train::OnNewCalendarDay().

## ◆ CalcPercentVehicleFilled()

uint8_t CalcPercentVehicleFilled | ( | const Vehicle * | front,
|  | StringID * | colour
| ) |  |

Calculates how full a vehicle is.

Parameters

  front | The front vehicle of the consist to check.
  colour | The 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 1461 of file vehicle.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoUnloading, CeilDiv(), Vehicle::current_order, SpecializedStation< Station, false >::GetIfValid(), Order::GetLoadType(), Station::goods, Order::IsFullLoadOrder(), Order::IsType(), Vehicle::last_station_visited, LoadingFinished, Vehicle::Next(), NoLoad, StopLoading, VehicleCargoList::StoredCount(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and BaseConsist::vehicle_flags.

Referenced by AfterLoadVehiclesPhase2(), Vehicle::LeaveStation(), LoadUnloadVehicle(), and ProcessConditionalOrder().

## ◆ CallVehicleTicks()

void CallVehicleTicks | ( |  | ) |

Definition at line 954 of file vehicle.cpp.

## ◆ 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

  type | the 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 1903 of file vehicle.cpp.

References _local_company, _settings_game, SpecializedVehicle< T, Type >::From(), HasAnyRailTypesAvail(), HasAnyRoadTypesAvail(), IsCompanyBuildableVehicleType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), Engine::IterateType(), VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, Vehicle::owner, RoadVehicleInfo::roadtype, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.

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

## ◆ CanVehicleUseStation() [1/2]

bool CanVehicleUseStation | ( | const Vehicle * | v,
|  | const Station * | st
| ) |  |

Can this station be used by the given vehicle?

Parameters

  v | the vehicle to test
  st | the station to test for

Returns
  true if and only if the vehicle can use this station.

Definition at line 3079 of file vehicle.cpp.

References CanVehicleUseStation(), Vehicle::engine_type, SpecializedVehicle< T, Type >::From(), BaseVehicle::type, and VEH_ROAD.

## ◆ CanVehicleUseStation() [2/2]

bool CanVehicleUseStation | ( | EngineID | engine_type,
|  | const Station * | st
| ) |  |

Can this station be used by the given engine type?

Parameters

  engine_type | the type of vehicles to test
  st | the station to test for

Returns
  true if and only if the vehicle of the type can use this station.

Note
  For road vehicles the Vehicle is needed to determine whether it can use the station. This function will return true for road vehicles when at least one of the facilities is available.

Definition at line 3046 of file vehicle.cpp.

References AIR_CTOL, AirportFTAClass::Airplanes, Station::airport, Airport, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), BusStop, CanVehicleUseStation(), Dock, BaseStation::facilities, AirportFTAClass::flags, Airport::GetFTA(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::GetIfValid(), AirportFTAClass::Helicopters, AircraftVehicleInfo::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Train, TruckStop, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by CanVehicleUseStation(), CanVehicleUseStation(), CheckOrders(), CmdBuildAircraft(), CmdCloneOrder(), CmdInsertOrder(), DrawOrderString(), Aircraft::FindClosestDepot(), RoadVehicle::GetOrderStationLocation(), Ship::GetOrderStationLocation(), and UpdateAirplanesOnNewStation().

## ◆ CheckClickOnVehicle()

Vehicle * CheckClickOnVehicle | ( | const Viewport & | vp,
|  | int | x,
|  | int | y
| ) |  |

Find the vehicle close to the clicked coordinates.

Parameters

  vp | Viewport clicked in.
  x | X coordinate in the viewport.
  y | Y coordinate in the viewport.

Returns
  Closest vehicle, or `nullptr` if none found.

Definition at line 1215 of file vehicle.cpp.

References abs(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Vehicle::coord, Vehicle::hash_viewport_next, Viewport::height, Hidden, IsInsideMM(), Viewport::left, MAX_VEHICLE_PIXEL_X, MAX_VEHICLE_PIXEL_Y, ScaleByZoom(), Viewport::top, Unclickable, Vehicle::vehstatus, Viewport::virtual_left, Viewport::virtual_top, Viewport::width, and Viewport::zoom.

## ◆ CheckVehicleBreakdown()

void CheckVehicleBreakdown | ( | Vehicle * | v | ) |

Definition at line 1287 of file vehicle.cpp.

## ◆ ComposeTileHash()

static uint ComposeTileHash | ( | uint | hx,
|  | uint | hy
| ) |  |
| inlinestatic

Compose two 1D hashes into 2D hash.

Definition at line 413 of file vehicle.cpp.

Referenced by GetTileHash(), VehiclesNearTileXY::Iterator::Iterator(), and VehiclesNearTileXY::Iterator::SkipEmptyBuckets().

## ◆ CountVehiclesInChain()

uint CountVehiclesInChain | ( | const Vehicle * | v | ) |

Definition at line 674 of file vehicle.cpp.

## ◆ DecreaseVehicleValue()

void DecreaseVehicleValue | ( | Vehicle * | v | ) |

Decrease the value of a vehicle.

Parameters

  v | Vehicle to devaluate.

Definition at line 1270 of file vehicle.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, SetWindowDirty(), Vehicle::value, and WC_VEHICLE_DETAILS.

Referenced by Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), and Train::OnNewEconomyDay().

## ◆ DoDrawVehicle()

static void DoDrawVehicle | ( | const Vehicle * | v | ) |
| static

Add vehicle sprite for drawing to the screen.

Parameters

  v | Vehicle to draw.

Definition at line 1092 of file vehicle.cpp.

References AddSortableSpriteToDraw(), Vehicle::bounds, Crashed, DefaultPalette, EndSpriteCombine(), SpecializedVehicle< EffectVehicle, VEH_EFFECT >::From(), EffectVehicle::GetTransparencyOption(), GetVehiclePalette(), IsInvisibilitySet(), IsTransparencySet(), PALETTE_CRASH, Shadow, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, StartSpriteCombine(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TO_INVALID, BaseVehicle::type, VEH_EFFECT, Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by ViewportAddVehicles().

## ◆ EconomyAgeVehicle()

void EconomyAgeVehicle | ( | Vehicle * | v | ) |

Update economy age of a vehicle.

Parameters

  v | Vehicle to update.

Definition at line 1398 of file vehicle.cpp.

References Vehicle::economy_age, Vehicle::IsPrimaryVehicle(), TimerGameConst< struct Economy >::MAX_DATE, VEHICLE_PROFIT_MIN_AGE, and GroupStatistics::VehicleReachedMinAge().

Referenced by Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), and Train::OnNewEconomyDay().

## ◆ 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

  tile | The tile.
  track_bits | The track bits.

Returns
  `true` if no train that interacts, is found. `false` if a train is found.

Definition at line 575 of file vehicle.cpp.

References SpecializedVehicle< T, Type >::From(), TracksOverlap(), and VEH_TRAIN.

Referenced by CmdConvertRail(), EnsureNoTrainOnTrack(), and ExploreSegment().

## ◆ EnsureNoVehicleOnGround()

CommandCost EnsureNoVehicleOnGround | ( | TileIndex | tile | ) |

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

Parameters

  tile | Position to examine.

Returns
  Succeeded command (ground is free) or failed command (a vehicle is found).

Definition at line 527 of file vehicle.cpp.

References AIR_SHADOW, GetTileMaxPixelZ(), VEH_AIRCRAFT, and VEH_DISASTER.

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

## ◆ GetDirectionTowards()

Direction GetDirectionTowards | ( | const Vehicle * | v,
|  | int | x,
|  | int | y
| ) |  |

Definition at line 1789 of file vehicle.cpp.

## ◆ GetEngineColourMap()

static PaletteID GetEngineColourMap | ( | EngineID | engine_type,
|  | CompanyID | company,
|  | EngineID | parent_engine_type,
|  | const Vehicle * | v
| ) |  |
| static

Definition at line 2074 of file vehicle.cpp.

## ◆ GetEngineLivery()

const 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_type | EngineID of the vehicle
  company | Owner of the vehicle
  parent_engine_type | EngineID of the front vehicle. VehicleID::Invalid() if vehicle is at front itself.
  v | the vehicle. nullptr if in purchase list etc.
  livery_setting | The livery settings to use for acquiring the livery information.

Returns
  livery to use

Definition at line 2045 of file vehicle.cpp.

References _local_company, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetEngineLiveryScheme(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::GetIfValid(), Vehicle::group_id, Livery::in_use, LIT_ALL, LIT_COMPANY, Group::livery, and Group::parent.

Referenced by LiveryHelper().

## ◆ GetEngineLiveryScheme()

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

Determines the LiveryScheme for a vehicle.

Parameters

  engine_type | Engine of the vehicle.
  parent_engine_type | Engine of the front vehicle, EngineID::Invalid() if vehicle is at front itself.
  v | the vehicle, `nullptr` if in purchase list etc.

Returns
  livery scheme to use.

Definition at line 1951 of file vehicle.cpp.

References AIR_CTOL, Vehicle::cargo_type, EC_DIESEL, EC_ELECTRIC, EC_MAGLEV, EC_MONORAIL, EC_STEAM, RailVehicleInfo::engclass, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), CargoSpec::Get(), Engine::GetDefaultCargoType(), Vehicle::IsArticulatedPart(), IsCargoInClass(), IsValidCargoType(), EngineInfo::misc_flags, Passengers, RailIsMU, RAILVEH_WAGON, RoadIsTram, AircraftVehicleInfo::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Engine::type, UsesWagonOverride(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by FinaliseEngineArray(), and GetEngineLivery().

## ◆ GetEnginePalette()

PaletteID GetEnginePalette | ( | EngineID | engine_type,
|  | CompanyID | company
| ) |  |

Get the colour map for an engine.

This used for unbuilt engines in the user interface.

Parameters

  engine_type | ID of engine
  company | ID of company

Returns
  A ready-to-use palette modifier

Definition at line 2123 of file vehicle.cpp.

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

## ◆ GetFreeUnitNumber()

UnitID GetFreeUnitNumber | ( | VehicleType | type | ) |

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

Parameters

  type | Type 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 1876 of file vehicle.cpp.

References _current_company, _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), Company::group_all, 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(), CmdBuildVehicle(), 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

  v | Vehicle to move

Returns
  Position information after the move

Definition at line 1765 of file vehicle.cpp.

References Vehicle::direction, GetNewVehiclePosResult::new_tile, GetNewVehiclePosResult::old_tile, Vehicle::tile, TileVirtXY(), Vehicle::x_pos, GetNewVehiclePosResult::y, and Vehicle::y_pos.

Referenced by AircraftController(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Submarine(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), TrainController(), and UpdateOldAircraft().

## ◆ GetTileHash()

static uint GetTileHash | ( | uint | x,
|  | uint | y
| ) |  |
| inlinestatic

Compute hash for tile coordinate.

Definition at line 421 of file vehicle.cpp.

References ComposeTileHash(), and GetTileHash1D().

Referenced by VehiclesOnTile::Iterator::Iterator().

## ◆ GetTileHash1D()

static uint GetTileHash1D | ( | uint | p | ) |
| inlinestatic

Compute hash for 1D tile coordinate.

Definition at line 397 of file vehicle.cpp.

References GB().

Referenced by GetTileHash(), and VehiclesNearTileXY::Iterator::Iterator().

## ◆ GetVehicleCannotUseStationReason()

StringID GetVehicleCannotUseStationReason | ( | const Vehicle * | v,
|  | const Station * | st
| ) |  |

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

Parameters

  v | The vehicle to test.
  st | The station to test for.

Returns
  The string explaining why the vehicle cannot use the station.

Definition at line 3092 of file vehicle.cpp.

References AIR_CTOL, Airport, Bus, RoadVehicle::compatible_roadtypes, BaseStation::facilities, SpecializedVehicle< T, Type >::From(), Vehicle::GetEngine(), Vehicle::HasArticulatedPart(), HasTileAnyRoadType(), INVALID_STRING_ID, IsBayRoadStopTile(), RoadVehicle::IsBus(), RoadStop::next, RoadVehicle::roadtype, AircraftVehicleInfo::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Truck, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and RoadStop::xy.

Referenced by CmdCloneOrder(), and CmdInsertOrder().

## ◆ GetVehiclePalette()

PaletteID GetVehiclePalette | ( | const Vehicle * | v | ) |

Get the colour map for a vehicle.

Parameters

  v | Vehicle to get colour map for

Returns
  A ready-to-use palette modifier

Definition at line 2133 of file vehicle.cpp.

References Vehicle::engine_type, GroundVehicleCache::first_engine, Vehicle::GetGroundVehicleCache(), Vehicle::IsGroundVehicle(), and Vehicle::owner.

Referenced by DoDrawVehicle(), DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainDetails(), DrawTrainImage(), and SetMouseCursorVehicle().

## ◆ 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] | set | Set of affected vehicles.
  | v | First vehicle of the selection.
  | num_vehicles | Number 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 3206 of file vehicle.cpp.

References SpecializedVehicle< T, Type >::From(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), include(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::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().

## ◆ GetViewportHash()

static uint GetViewportHash | ( | int | x,
|  | int | y
| ) |  |
| inlinestatic

Definition at line 87 of file vehicle.cpp.

## ◆ GetViewportHashX()

static uint GetViewportHashX | ( | int | x | ) |
| inlinestatic

Definition at line 77 of file vehicle.cpp.

## ◆ GetViewportHashY()

static uint GetViewportHashY | ( | int | y | ) |
| inlinestatic

Definition at line 82 of file vehicle.cpp.

## ◆ IncTileHash1D()

static uint IncTileHash1D | ( | uint | h | ) |
| inlinestatic

Increment 1D hash to next bucket.

Definition at line 405 of file vehicle.cpp.

Referenced by VehiclesNearTileXY::Iterator::SkipEmptyBuckets().

## ◆ InitializeVehicles()

void InitializeVehicles | ( |  | ) |

Definition at line 668 of file vehicle.cpp.

## ◆ IsBridgeAboveVehicle()

static bool IsBridgeAboveVehicle | ( | const Vehicle * | v | ) |
| static

Test if a bridge is above a vehicle.

Parameters

  v | Vehicle to test.

Returns
  true iff a bridge is above the vehicle.

Definition at line 2762 of file vehicle.cpp.

References IsBridgeAbove(), IsBridgeTile(), Vehicle::tile, TileVirtXY(), Vehicle::x_pos, and Vehicle::y_pos.

Referenced by Vehicle::ShowVisualEffect().

## ◆ PreviousOrderIsUnbunching()

static bool PreviousOrderIsUnbunching | ( | const Vehicle * | v | ) |
| static

Check if the previous order is a depot unbunching order.

Returns
  true Iff the previous order is a depot order with the unbunch flag.

Definition at line 2473 of file vehicle.cpp.

References BaseConsist::cur_implicit_order_index, Order::GetDepotActionType(), Vehicle::GetFirstOrder(), Vehicle::GetLastOrder(), Vehicle::GetOrder(), Order::IsType(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Unbunch.

Referenced by Vehicle::IsWaitingForUnbunching(), and Vehicle::LeaveUnbunchingDepot().

## ◆ ResetVehicleColourMap()

void ResetVehicleColourMap | ( |  | ) |

Definition at line 656 of file vehicle.cpp.

## ◆ ResetVehicleHash()

void ResetVehicleHash | ( |  | ) |

Definition at line 649 of file vehicle.cpp.

## ◆ RunEconomyVehicleDayProc()

static void RunEconomyVehicleDayProc | ( |  | ) |
| static

Increases the day counter for all vehicles and calls 1-day and 32-day handlers.

Each tick, it processes vehicles with "index % DAY_TICKS == TimerGameEconomy::date_fract", so each day, all vehicles are processes in DAY_TICKS steps.

Definition at line 924 of file vehicle.cpp.

References Callback32, CALLBACK_FAILED, CBID_VEHICLE_32DAY_CALLBACK, TimerGameEconomy::date_fract, Vehicle::day_counter, Ticks::DAY_TICKS, Vehicle::engine_type, ErrorUnknownCallbackResult(), Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Get(), Vehicle::GetGRFID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::GetPoolSize(), GetVehicleCallback(), HasBit(), Vehicle::HasEngineType(), Vehicle::MarkDirty(), and Vehicle::OnNewEconomyDay().

## ◆ RunVehicleCalendarDayProc()

void RunVehicleCalendarDayProc | ( |  | ) |

Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.

Definition at line 907 of file vehicle.cpp.

References TimerGameCalendar::date_fract, Ticks::DAY_TICKS, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::GetPoolSize(), and Vehicle::OnNewCalendarDay().

Referenced by StateGameLoop().

## ◆ ShowNewGrfVehicleError()

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

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

Parameters

  engine | The engine that caused the problem
  part1 | Part 1 of the error message, taking the grfname as parameter 1
  part2 | Part 2 of the error message, taking the engine as parameter 2
  bug_type | Flag to check and set in grfconfig
  critical | Shall the "OpenTTD might crash"-message be shown when the player tries to unpause?

Definition at line 328 of file vehicle.cpp.

References _networking, Debug, Error, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetEncodedString(), GetGRFConfig(), Engine::GetGRFID(), GRFConfig::GetName(), GetString(), GRFConfig::grf_bugs, Normal, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), ShowErrorMessage(), StrMakeValid(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WL_CRITICAL.

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

## ◆ SpawnAdvancedVisualEffect()

static void SpawnAdvancedVisualEffect | ( | const Vehicle * | v | ) |
| static

Call CBID_VEHICLE_SPAWN_VISUAL_EFFECT and spawn requested effects.

Parameters

  v | Vehicle to create effects for.

Definition at line 2704 of file vehicle.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_SPAWN_VISUAL_EFFECT, ChangeDir(), CreateEffectVehicleRel(), DIRDIFF_90RIGHT, Vehicle::direction, Vehicle::engine_type, EV_BREAKDOWN_SMOKE_AIRCRAFT, EV_DIESEL_SMOKE, EV_ELECTRIC_SPARK, EV_STEAM_SMOKE, Flipped, SpecializedVehicle< T, Type >::From(), GB(), GetVehicleCallback(), HasBit(), Random, ReverseDir(), BaseVehicle::type, VEH_ROAD, VEH_TRAIN, and VEHICLE_LENGTH.

Referenced by Vehicle::ShowVisualEffect().

## ◆ TunnelBridgeIsFree()

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

Finds vehicle in tunnel / bridge.

Parameters

  tile | first end
  endtile | second end
  ignore | Ignore 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 551 of file vehicle.cpp.

References VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

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

## ◆ UpdateVehicleTileHash()

static void UpdateVehicleTileHash | ( | Vehicle * | v,
|  | bool | remove
| ) |  |
| static

Definition at line 592 of file vehicle.cpp.

## ◆ UpdateVehicleViewportHash()

static void UpdateVehicleViewportHash | ( | Vehicle * | v,
|  | int | x,
|  | int | y,
|  | int | old_x,
|  | int | old_y
| ) |  |
| static

Definition at line 625 of file vehicle.cpp.

## ◆ VehicleEnterDepot()

void VehicleEnterDepot | ( | Vehicle * | v | ) |

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

Parameters

  v | Vehicle that entered a depot.

Definition at line 1520 of file vehicle.cpp.

References _current_company, _local_company, _settings_client, AddVehicleAdviceNewsItem(), CCF_ARRANGE, Clamp(), Train::ConsistChanged(), TimerGameTick::counter, BaseConsist::cur_real_order_index, Vehicle::cur_speed, Vehicle::current_order, Vehicle::DeleteUnreachedImplicitOrders(), Depot, BaseConsist::depot_unbunching_last_departure, Vehicle::dest_tile, Execute, CommandCost::Failed(), Vehicle::First(), SpecializedVehicle< T, Type >::From(), SpecializedVehicle< Ship, VEH_SHIP >::From(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), CommandCost::GetCost(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetDestination(), GetEncodedString(), Vehicle::GetOrder(), Order::GetRefitCargo(), GetStationIndex(), ClientSettings::gui, Halt, HandleAircraftEnterHangar(), Hidden, Vehicle::IncrementImplicitOrderIndex(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_DIAGDIR, InvalidateWindowData(), Order::IsRefit(), Order::IsType(), Vehicle::last_loading_station, Order::MakeDummy(), Vehicle::MarkDirty(), MarkTileDirtyByTile(), NearestDepot, AI::NewEvent(), Vehicle::owner, PartOfOrders, Vehicle::profit_this_year, RefitFailed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseConsist::ResetDepotUnbunching(), Backup< T >::Restore(), Reversed, BaseConsist::round_trip_time, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetDepotReservation(), SetWindowClassesDirty(), SetWindowDirty(), GUISettings::show_track_reservation, ShowCostOrIncomeAnimation(), Ship::state, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, Vehicle::tile, TRACK_BIT_DEPOT, BaseVehicle::type, Unbunch, Ship::UpdateCache(), UpdateSignalsOnSegment(), UpdateVehicleTimetable(), SpecializedVehicle< T, Type >::UpdateViewport(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, VehicleEnteredDepotThisTick(), VehicleServiceInDepot(), VehicleWaiting, Vehicle::vehstatus, 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(), CheckShipStayInDepot(), CheckTrainStayInDepot(), and VehicleEnter_Track().

## ◆ VehicleEnteredDepotThisTick()

static void VehicleEnteredDepotThisTick | ( | Vehicle * | v | ) |
| static

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

Parameters

  *v | vehicle to add

Definition at line 891 of file vehicle.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), Stopped, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Vehicle::vehstatus.

Referenced by VehicleEnterDepot().

## ◆ VehicleEnterTile()

VehicleEnterTileStates VehicleEnterTile | ( | Vehicle * | v,
|  | TileIndex | tile,
|  | int | x,
|  | int | y
| ) |  |

Call the tile callback function for a vehicle entering a tile.

Parameters

  v | Vehicle entering the tile
  tile | Tile entered
  x | X position
  y | Y position

Returns
  Some meta-data over the to be entered tile.

See also
  VehicleEnterTileStates to see what the bits in the return value mean.

Definition at line 1819 of file vehicle.cpp.

References _tile_type_procs, GetTileType(), and TileTypeProcs::vehicle_enter_tile_proc.

Referenced by TrainController(), and UpdateStatusAfterSwap().

## ◆ 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

  u | first vehicle of chain

Definition at line 354 of file vehicle.cpp.

References _gamelog, Vehicle::engine_type, Vehicle::GetEngine(), GetGRFConfig(), GRFConfig::grf_bugs, Engine::grf_prop, Gamelog::GRFBugReverse(), GRFFilePropsBase::grfid, GRFFilePropsBase::local_id, ShowNewGrfVehicleError(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and VehLength.

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

## ◆ VehicleServiceInDepot()

void VehicleServiceInDepot | ( | Vehicle * | v | ) |

Service a vehicle and all subsequent vehicles in the consist.

Parameters

  *v | The vehicle or vehicle chain being serviced

Definition at line 178 of file vehicle.cpp.

References _settings_game, Vehicle::breakdown_chance, Vehicle::breakdowns_since_last_service, TimerGameCalendar::date, TimerGameEconomy::date, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, GameSettings::difficulty, Vehicle::GetEngine(), Vehicle::HasEngineType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Vehicle::Next(), Engine::reliability, Vehicle::reliability, SetWindowDirty(), DifficultySettings::vehicle_breakdowns, and WC_VEHICLE_DETAILS.

Referenced by AircraftLeaveHangar(), CheckIfTrainNeedsService(), CheckShipStayInDepot(), CheckTrainStayInDepot(), and VehicleEnterDepot().

## ◆ VehiclesHaveSameEngineList()

bool VehiclesHaveSameEngineList | ( | const Vehicle * | v1,
|  | const Vehicle * | v2
| ) |  |

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

Parameters

  v1 | First vehicle chain.
  v1 | Second vehicle chain.

Returns
  True if same, false if different.

Definition at line 3260 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

  v1 | First vehicles.
  v1 | Second vehicles.

Returns
  True if same, false if different.

Definition at line 3277 of file vehicle.cpp.

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

  dpi | Rectangle being drawn.

Definition at line 1121 of file vehicle.cpp.

References Vehicle::coord, Vehicle::direction, DoDrawVehicle(), EIT_ON_MAP, Vehicle::GetImage(), Vehicle::hash_viewport_next, Hidden, VehicleSpriteSeq::IsValid(), MAX_VEHICLE_PIXEL_X, MAX_VEHICLE_PIXEL_Y, MutableSpriteCache::revalidate_before_draw, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::UpdateBoundingBoxCoordinates(), and Vehicle::vehstatus.

## Variable Documentation

## ◆ _breakdown_chance

const uint8_t _breakdown_chance[64]
| static

Initial value:
= {
3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 5, 5, 6, 6, 7, 7,
8, 8, 9, 9, 10, 10, 11, 11,
12, 13, 13, 13, 13, 14, 15, 16,
17, 19, 21, 25, 28, 31, 34, 37,
40, 44, 48, 52, 56, 60, 64, 68,
72, 80, 90, 100, 110, 120, 130, 140,
150, 170, 190, 210, 230, 250, 250, 250,
}

Definition at line 1276 of file vehicle.cpp.

## ◆ _new_direction_table

const Direction _new_direction_table[]
| static

Initial value:
= {
DIR_N, DIR_NW, DIR_W,
DIR_NE, DIR_SE, DIR_SW,
DIR_E, DIR_SE, DIR_S
}
DIR_SW
@ DIR_SW
Southwest.
Definition direction_type.h:31
DIR_NW
@ DIR_NW
Northwest.
Definition direction_type.h:33
DIR_N
@ DIR_N
North.
Definition direction_type.h:26
DIR_SE
@ DIR_SE
Southeast.
Definition direction_type.h:29
DIR_S
@ DIR_S
South.
Definition direction_type.h:30
DIR_NE
@ DIR_NE
Northeast.
Definition direction_type.h:27
DIR_W
@ DIR_W
West.
Definition direction_type.h:32
DIR_E
@ DIR_E
East.
Definition direction_type.h:28

Definition at line 1783 of file vehicle.cpp.

## ◆ _vehicle_smoke_pos

const int8_t _vehicle_smoke_pos[8]
| static

Initial value:
= {
1, 1, 1, 0, -1, -1, -1, 0
}

Definition at line 2696 of file vehicle.cpp.

## ◆ _vehicle_tile_hash

std::array<Vehicle *, TOTAL_TILE_HASH_SIZE> _vehicle_tile_hash {}
| static

Definition at line 426 of file vehicle.cpp.

## ◆ _vehicle_viewport_hash

std::array<Vehicle *, 1 << (GEN_HASHX_BITS + GEN_HASHY_BITS)> _vehicle_viewport_hash {}
| static

Definition at line 623 of file vehicle.cpp.

## ◆ _vehicles_to_autoreplace

AutoreplaceMap _vehicles_to_autoreplace
| static

Definition at line 666 of file vehicle.cpp.

## ◆ GEN_HASHX_BITS

const uint GEN_HASHX_BITS = 6
| static

Definition at line 69 of file vehicle.cpp.

## ◆ GEN_HASHX_BUCKET_BITS

const uint GEN_HASHX_BUCKET_BITS = 7
| static

Definition at line 73 of file vehicle.cpp.

## ◆ GEN_HASHX_INC

const uint GEN_HASHX_INC = 1
| static

Definition at line 97 of file vehicle.cpp.

## ◆ GEN_HASHX_MASK

const uint GEN_HASHX_MASK = (1 << GEN_HASHX_BITS) - 1
| static

Definition at line 101 of file vehicle.cpp.

## ◆ GEN_HASHX_SIZE

const uint GEN_HASHX_SIZE = 1 << (GEN_HASHX_BUCKET_BITS + GEN_HASHX_BITS + ZOOM_BASE_SHIFT)
| static

Definition at line 93 of file vehicle.cpp.

## ◆ GEN_HASHY_BITS

const uint GEN_HASHY_BITS = 6
| static

Definition at line 70 of file vehicle.cpp.

## ◆ GEN_HASHY_BUCKET_BITS

const uint GEN_HASHY_BUCKET_BITS = 6
| static

Definition at line 74 of file vehicle.cpp.

## ◆ GEN_HASHY_INC

const uint GEN_HASHY_INC = 1 << GEN_HASHX_BITS
| static

Definition at line 98 of file vehicle.cpp.

## ◆ GEN_HASHY_MASK

const uint GEN_HASHY_MASK = ((1 << GEN_HASHY_BITS) - 1) << GEN_HASHX_BITS
| static

Definition at line 102 of file vehicle.cpp.

## ◆ GEN_HASHY_SIZE

const uint GEN_HASHY_SIZE = 1 << (GEN_HASHY_BUCKET_BITS + GEN_HASHY_BITS + ZOOM_BASE_SHIFT)
| static

Definition at line 94 of file vehicle.cpp.

## ◆ TILE_HASH_BITS

constexpr uint TILE_HASH_BITS = 7
| constexpr

Definition at line 385 of file vehicle.cpp.

## ◆ TILE_HASH_MASK

constexpr uint TILE_HASH_MASK = TILE_HASH_SIZE - 1
| constexpr

Definition at line 387 of file vehicle.cpp.

## ◆ TILE_HASH_RES

constexpr uint TILE_HASH_RES = 0
| constexpr

Definition at line 392 of file vehicle.cpp.

## ◆ TILE_HASH_SIZE

constexpr uint TILE_HASH_SIZE = 1 << TILE_HASH_BITS
| constexpr

Definition at line 386 of file vehicle.cpp.

## ◆ TOTAL_TILE_HASH_SIZE

constexpr uint TOTAL_TILE_HASH_SIZE = 1 << (TILE_HASH_BITS * 2)
| constexpr

Definition at line 388 of file vehicle.cpp.