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... | |
Defines | |
#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 Vehicle * | VehicleFromPosProc (Vehicle *v, void *data) |
typedef SmallVector< VehicleID, 2 > | VehicleSet |
Functions | |
void | VehicleServiceInDepot (Vehicle *v) |
uint | CountVehiclesInChain (const Vehicle *v) |
void | CountCompanyVehicles (CompanyID cid, uint counts[4]) |
Count the number of vehicles of a company. | |
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. | |
byte | VehicleRandomBits () |
Get a value for a vehicle's random_bits. | |
void | ResetVehiclePosHash () |
void | ResetVehicleColourMap () |
byte | GetBestFittingSubType (Vehicle *v_from, Vehicle *v_for) |
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. | |
void | VehicleMove (Vehicle *v, bool update_viewport) |
Move a vehicle in the game state; that is moving its position in the position hashes and marking its location in the viewport dirty if requested. | |
void | MarkSingleVehicleDirty (const Vehicle *v) |
Marks viewports dirty where the vehicle's image is In fact, it equals BeginVehicleMove(v); EndVehicleMove(v);. | |
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 Livery * | GetEngineLivery (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. | |
uint | GetVehicleCapacity (const Vehicle *v, uint16 *mail_capacity=NULL) |
Determines capacity of a given vehicle from scratch. | |
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. | |
Variables | |
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). | |
byte | _age_cargo_skip_counter |
Skip aging of cargo? |
Functions related to vehicles.
Definition in file vehicle_func.h.
void AgeVehicle | ( | Vehicle * | v | ) |
Update age of a vehicle.
v | Vehicle to update. |
Definition at line 1126 of file vehicle.cpp.
References _local_company, AddVehicleNewsItem(), Vehicle::age, DAYS_IN_LEAP_YEAR, Vehicle::engine_type, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::max_age, MAX_DAY, NS_ADVICE, Vehicle::owner, Vehicle::Previous(), Vehicle::reliability_spd_dec, SetDParam(), SetWindowDirty(), Vehicle::vehstatus, and VS_CRASHED.
Referenced by Train::OnNewDay(), Ship::OnNewDay(), RoadVehicle::OnNewDay(), and Aircraft::OnNewDay().
Calculates how full a vehicle is.
v | The Vehicle to check. For trains, use the first engine. | |
colour | The string to show depending on if we are unloading or loading |
Definition at line 1165 of file vehicle.cpp.
References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::current_order, SpecializedStation< Station, false >::GetIfValid(), Order::GetLoadType(), Station::goods, HasBit(), Vehicle::last_station_visited, max(), Vehicle::Next(), OLFB_NO_LOAD, VehicleCargoList::OnboardCount(), Vehicle::vehicle_flags, and VF_CARGO_UNLOADING.
Referenced by LoadUnloadVehicle(), and ProcessConditionalOrder().
bool CanBuildVehicleInfrastructure | ( | VehicleType | type | ) |
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.
type | the vehicle type to check this for |
Definition at line 1511 of file vehicle.cpp.
References _local_company, _settings_client, _settings_game, Engine::company_avail, GUISettings::disable_unsuitable_building, FOR_ALL_VEHICLES, ClientSettings::gui, HasBit(), IsCompanyBuildableVehicleType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), max(), VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, Vehicle::owner, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.
Referenced by BuildRoadToolbarWindow::OnClick(), BuildDocksToolbarWindow::OnClick(), BuildRoadToolbarWindow::OnInvalidateData(), BuildDocksToolbarWindow::OnInvalidateData(), MainToolbarWindow::OnKeyPress(), and MainToolbarWindow::OnPaint().
void CountCompanyVehicles | ( | CompanyID | cid, | |
uint | counts[4] | |||
) |
Count the number of vehicles of a company.
c | Company owning the vehicles. | |
[out] | counts | Array of counts. Contains the vehicle count ordered by type afterwards. |
Definition at line 607 of file vehicle.cpp.
References FOR_ALL_VEHICLES, Vehicle::IsPrimaryVehicle(), Vehicle::owner, and BaseVehicle::type.
Referenced by CompanyWindow::DrawWidget(), GetFreeUnitNumber(), and MayCompanyTakeOver().
void DecreaseVehicleValue | ( | Vehicle * | v | ) |
Decrease the value of a vehicle.
v | Vehicle to devaluate. |
Definition at line 1003 of file vehicle.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SetWindowDirty(), and Vehicle::value.
Referenced by Train::OnNewDay(), Ship::OnNewDay(), RoadVehicle::OnNewDay(), and Aircraft::OnNewDay().
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.
tile | The tile. | |
track_bits | The track bits. |
true
if no train that interacts, is found. false
if a train is found. Definition at line 492 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.
tile | Position to examine. |
Definition at line 430 of file vehicle.cpp.
References EnsureNoVehicleProcZ(), GetTileMaxZ(), return_cmd_error, BaseVehicle::type, and VehicleFromPos().
Referenced by CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildRoad(), CmdBuildSingleRail(), CmdConvertRail(), CmdRemoveSingleRail(), IsValidTileForWaypoint(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRailStation(), 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!
tile | The location on the map | |
data | Arbitrary data passed to proc. | |
proc | The proc that determines whether a vehicle will be "found". |
Definition at line 389 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!
x | The X location on the map | |
y | The Y location on the map | |
data | Arbitrary data passed to proc | |
proc | The proc that determines whether a vehicle will be "found". |
Definition at line 329 of file vehicle.cpp.
References VehicleFromPosXY().
Referenced by CheckTrainCollision().
Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
Assuming they are going to carry the same cargo ofcourse!
v_from | the vehicle to match the subtype from | |
v_for | the vehicle to get the subtype for |
Definition at line 218 of file vehicle_gui.cpp.
References CALLBACK_FAILED, EngineInfo::callback_mask, Engine::CanCarryCargo(), Vehicle::cargo_subtype, Vehicle::cargo_type, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, Vehicle::engine_type, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCargoSubtypeText(), GetVehicleCallback(), HasBit(), and Vehicle::InvalidateNewGRFCache().
Referenced by BuildReplacementVehicle(), and CmdCloneVehicle().
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.
engine_type | EngineID of the vehicle | |
company | Owner of the vehicle | |
parent_engine_type | EngineID of the front vehicle. INVALID_VEHICLE if vehicle is at front itself. | |
v | the vehicle. NULL if in purchase list etc. | |
livery_setting | The livery settings to use for acquiring the livery information. |
Definition at line 1644 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.
LiveryScheme GetEngineLiveryScheme | ( | EngineID | engine_type, | |
EngineID | parent_engine_type, | |||
const Vehicle * | v | |||
) |
Determines the LiveryScheme for a vehicle.
engine_type | EngineID of the vehicle | |
parent_engine_type | EngineID of the front vehicle. INVALID_VEHICLE if vehicle is at front itself. | |
v | the vehicle. NULL if in purchase list etc. |
Definition at line 1554 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().
Get the colour map for an engine.
This used for unbuilt engines in the user interface.
engine_type | ID of engine | |
company | ID of company |
Definition at line 1712 of file vehicle.cpp.
References INVALID_ENGINE.
Referenced by DrawEngineList(), NewsWindow::DrawWidget(), and EnginePreviewWindow::DrawWidget().
UnitID GetFreeUnitNumber | ( | VehicleType | type | ) |
Get an unused unit number for a vehicle (if allowed).
type | Type of vehicle |
UINT16_MAX
. Definition at line 1480 of file vehicle.cpp.
References _current_company, _settings_game, CountCompanyVehicles(), lengthof, VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, FreeUnitIDGenerator::NextID(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.
Referenced by CheckNewTrain(), CmdBuildVehicle(), and NormaliseTrainHead().
GetNewVehiclePosResult GetNewVehiclePos | ( | const Vehicle * | v | ) |
Get position information of a vehicle when moving one pixel in the direction it is facing.
v | Vehicle to move |
Definition at line 1374 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(), and UpdateOldAircraft().
uint GetVehicleCapacity | ( | const Vehicle * | v, | |
uint16 * | mail_capacity | |||
) |
Determines capacity of a given vehicle from scratch.
For aircraft the main capacity is determined. Mail might be present as well.
v | Vehicle of interest | |
mail_capacity | returns secondary cargo (mail) capacity of aircraft |
Definition at line 1739 of file vehicle.cpp.
References CALLBACK_FAILED, EngineInfo::callback_mask, Engine::CanCarryCargo(), RailVehicleInfo::capacity, Vehicle::cargo_subtype, Vehicle::cargo_type, CBID_VEHICLE_REFIT_CAPACITY, CBM_VEHICLE_REFIT_CAPACITY, CC_PASSENGERS, Vehicle::engine_type, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetDefaultCargoType(), GetVehicleCallback(), HasBit(), IsCargoInClass(), AircraftVehicleInfo::mail_capacity, AircraftVehicleInfo::passenger_capacity, PROP_AIRCRAFT_MAIL_CAPACITY, PROP_AIRCRAFT_PASSENGER_CAPACITY, PROP_ROADVEH_CARGO_CAPACITY, PROP_SHIP_CARGO_CAPACITY, PROP_TRAIN_CARGO_CAPACITY, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CmdBuildAircraft(), CmdBuildRoadVehicle(), CmdBuildShip(), Train::ConsistChanged(), RefitVehicle(), and Vehicle::RefreshNextHopsStats().
Get the colour map for a vehicle.
v | Vehicle to get colour map for |
Definition at line 1722 of file vehicle.cpp.
References Vehicle::engine_type, GroundVehicleCache::first_engine, Vehicle::GetGroundVehicleCache(), INVALID_ENGINE, Vehicle::IsGroundVehicle(), and Vehicle::owner.
Referenced by DepotWindow::DepotClick(), DoDrawVehicle(), DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainDetails(), DrawTrainImage(), and VehicleGroupWindow::OnClick().
void GetVehicleSet | ( | VehicleSet & | set, | |
Vehicle * | v, | |||
uint8 | num_vehicles | |||
) |
Calculates the set of vehicles that will be affected by a given selection.
set | [inout] Set of affected vehicles. | |
v | First vehicle of the selection. | |
num_vehicles | Number of vehicles in the selection (not counting articulated parts). |
Definition at line 2674 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.
tile | The location on the map | |
data | Arbitrary data passed to proc. | |
proc | The proc that determines whether a vehicle will be "found". |
Definition at line 404 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CheckRoadBlockedForOvertaking(), ExploreSegment(), TrainApproachingCrossing(), 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.
x | The X location on the map | |
y | The Y location on the map | |
data | Arbitrary data passed to proc | |
proc | The proc that determines whether a vehicle will be "found". |
Definition at line 345 of file vehicle.cpp.
References VehicleFromPosXY().
static bool IsCompanyBuildableVehicleType | ( | const BaseVehicle * | v | ) | [inline, static] |
Is the given vehicle buildable by a company?
v | Vehicle being queried. |
Definition at line 99 of file vehicle_func.h.
References IsCompanyBuildableVehicleType(), and BaseVehicle::type.
static bool IsCompanyBuildableVehicleType | ( | VehicleType | type | ) | [inline, static] |
Is the given vehicle type buildable by a company?
type | Vehicle type being queried. |
Definition at line 81 of file vehicle_func.h.
References VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CanBuildVehicleInfrastructure(), ChangeOwnershipOfCompanyItems(), CmdAddSharedVehicleGroup(), CmdCreateGroup(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdMassStartStopVehicle(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), FixOldVehicles(), IsCompanyBuildableVehicleType(), Load_VEHS(), EngineOverrideManager::ResetToCurrentNewGRFConfig(), and UpdateCompanyRatingAndValue().
void MarkSingleVehicleDirty | ( | const Vehicle * | v | ) |
Marks viewports dirty where the vehicle's image is In fact, it equals BeginVehicleMove(v); EndVehicleMove(v);.
v | vehicle to mark dirty |
Definition at line 1364 of file vehicle.cpp.
References Vehicle::coord, and MarkAllViewportsDirty().
Referenced by Vehicle::Crash(), CreateEffectVehicle(), InitializeDisasterVehicle(), and Vehicle::~Vehicle().
void ReleaseDisastersTargetingVehicle | ( | VehicleID | vehicle | ) |
Notify disasters that we are about to delete a vehicle.
So make them head elsewhere.
vehicle | deleted vehicle |
Definition at line 971 of file disaster_cmd.cpp.
References Vehicle::age, Vehicle::current_order, Vehicle::dest_tile, FOR_ALL_DISASTERVEHICLES, Order::GetDestination(), INITIAL_DISASTER_VEHICLE_ZPOS, RandomTile, Order::SetDestination(), 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.
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 210 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(), GRFConfig::GetName(), GRFConfig::grf_bugs, Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), lastof, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, SetBit(), SetDParam(), SetDParamStr(), ShowErrorMessage(), and WL_CRITICAL.
Referenced by CheckConsistencyOfArticulatedVehicle(), RailVehicleLengthChanged(), and Vehicle::UpdateVisualEffect().
CommandCost TunnelBridgeIsFree | ( | TileIndex | tile, | |
TileIndex | endtile, | |||
const Vehicle * | ignore | |||
) |
Finds vehicle in tunnel / bridge.
tile | first end | |
endtile | second end | |
ignore | Ignore this vehicle when searching |
Definition at line 459 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.
v | Vehicle that entered a depot. |
Definition at line 1210 of file vehicle.cpp.
References _current_company, _local_company, _settings_client, AddVehicleNewsItem(), ClrBit(), Train::ConsistChanged(), Vehicle::cur_real_order_index, Vehicle::cur_speed, Vehicle::current_order, DC_EXEC, Vehicle::DeleteUnreachedImplicitOrders(), Vehicle::dest_tile, DoCommand(), CommandCost::Failed(), Vehicle::First(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Ship, VEH_SHIP >::From(), SpecializedVehicle< Train, Type >::From(), CommandCost::GetCost(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetDestination(), Vehicle::GetOrder(), Order::GetRefitCargo(), Order::GetRefitSubtype(), 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(), Order::MakeDummy(), MarkTileDirtyByTile(), AI::NewEvent(), NS_ADVICE, 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, Vehicle::vehstatus, VRF_TOGGLE_REVERSE, VS_HIDDEN, Train::wait_counter, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by AircraftEventHandler_EnterHangar(), AircraftEventHandler_InHangar(), and VehicleEnter_Track().
void VehicleEnteredDepotThisTick | ( | Vehicle * | v | ) |
Adds a vehicle to the list of vehicles that visited a depot this tick.
*v | vehicle to add |
Definition at line 760 of file vehicle.cpp.
References Vehicle::vehstatus, and VS_STOPPED.
void VehicleMove | ( | Vehicle * | v, | |
bool | update_viewport | |||
) |
Move a vehicle in the game state; that is moving its position in the position hashes and marking its location in the viewport dirty if requested.
v | vehicle to move | |
update_viewport | whether to dirty the viewport |
Definition at line 1329 of file vehicle.cpp.
References Vehicle::coord, Vehicle::cur_image, Sprite::height, MarkAllViewportsDirty(), max(), min(), RemapCoords(), ST_NORMAL, Sprite::width, Sprite::x_offs, Vehicle::x_offs, Vehicle::x_pos, Sprite::y_offs, Vehicle::y_offs, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by AddArticulatedParts(), AfterLoadVehicles(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CreateEffectVehicle(), DisasterTick_Helicopter_Rotors(), InitializeDisasterVehicle(), SetAircraftPosition(), and SpecializedVehicle< RoadVehicle, Type >::UpdateViewport().
byte VehicleRandomBits | ( | ) |
Get a value for a vehicle's random_bits.
Definition at line 254 of file vehicle.cpp.
References GB().
Referenced by AddArticulatedParts(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), and CmdBuildShip().
void ViewportAddVehicles | ( | DrawPixelInfo * | dpi | ) |
Add the vehicle sprites that should be drawn at a part of the screen.
dpi | Rectangle being drawn. |
Definition at line 911 of file vehicle.cpp.
References Vehicle::coord, DoDrawVehicle(), GB(), Vehicle::next_hash, Vehicle::vehstatus, and VS_HIDDEN.