OpenTTD Source
1.11.0-beta2
|
#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 "date_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 "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 "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Macros | |
#define | GEN_HASHX(x) GB((x), GEN_HASHX_BUCKET_BITS + ZOOM_LVL_SHIFT, GEN_HASHX_BITS) |
#define | GEN_HASHY(y) (GB((y), GEN_HASHY_BUCKET_BITS + ZOOM_LVL_SHIFT, GEN_HASHY_BITS) << GEN_HASHX_BITS) |
#define | GEN_HASH(x, y) (GEN_HASHY(y) + GEN_HASHX(x)) |
Typedefs | |
typedef SmallMap< Vehicle *, bool > | AutoreplaceMap |
List of vehicles that should check for autoreplace this tick. More... | |
Functions | |
void | VehicleServiceInDepot (Vehicle *v) |
Service a vehicle and all subsequent vehicles in the consist. 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... | |
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... | |
byte | VehicleRandomBits () |
Get a value for a vehicle's random_bits. More... | |
static Vehicle * | VehicleFromTileHash (int xl, int yl, int xu, int yu, void *data, VehicleFromPosProc *proc, bool find_first) |
static Vehicle * | VehicleFromPosXY (int x, int y, void *data, VehicleFromPosProc *proc, bool find_first) |
Helper function for FindVehicleOnPos/HasVehicleOnPos. More... | |
void | FindVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc) |
Find a vehicle from a specific location. More... | |
bool | HasVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc) |
Checks whether a vehicle in on a specific location. More... | |
static Vehicle * | VehicleFromPos (TileIndex tile, void *data, VehicleFromPosProc *proc, bool find_first) |
Helper function for FindVehicleOnPos/HasVehicleOnPos. More... | |
void | FindVehicleOnPos (TileIndex tile, 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... | |
static Vehicle * | EnsureNoVehicleProcZ (Vehicle *v, void *data) |
Callback that returns 'real' vehicles lower or at height * (int*)data . More... | |
CommandCost | EnsureNoVehicleOnGround (TileIndex tile) |
Ensure there is no vehicle at the ground at the given position. More... | |
static Vehicle * | GetVehicleTunnelBridgeProc (Vehicle *v, void *data) |
Procedure called for every vehicle found in tunnel/bridge in the hash map. | |
CommandCost | TunnelBridgeIsFree (TileIndex tile, TileIndex endtile, const Vehicle *ignore) |
Finds vehicle in tunnel / bridge. More... | |
static Vehicle * | EnsureNoTrainOnTrackProc (Vehicle *v, void *data) |
CommandCost | EnsureNoTrainOnTrackBits (TileIndex tile, TrackBits track_bits) |
Tests if a vehicle interacts with the specified track bits. More... | |
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) |
void | VehicleEnteredDepotThisTick (Vehicle *v) |
Adds a vehicle to the list of vehicles that visited a depot this tick. More... | |
static void | RunVehicleDayProc () |
Increases the day counter for all vehicles and calls 1-day and 32-day handlers. More... | |
void | CallVehicleTicks () |
static void | DoDrawVehicle (const Vehicle *v) |
Add vehicle sprite for drawing to the screen. More... | |
void | ViewportAddVehicles (DrawPixelInfo *dpi) |
Add the vehicle sprites that should be drawn at a part of the screen. More... | |
Vehicle * | CheckClickOnVehicle (const Viewport *vp, int x, int y) |
Find the vehicle close to the clicked coordinates. More... | |
void | DecreaseVehicleValue (Vehicle *v) |
Decrease the value of a vehicle. More... | |
void | CheckVehicleBreakdown (Vehicle *v) |
void | AgeVehicle (Vehicle *v) |
Update age of a vehicle. More... | |
uint8 | CalcPercentVehicleFilled (const Vehicle *front, StringID *colour) |
Calculates how full a vehicle is. More... | |
void | VehicleEnterDepot (Vehicle *v) |
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc. 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) |
VehicleEnterTileStatus | VehicleEnterTile (Vehicle *v, TileIndex tile, int x, int y) |
Call the tile callback function for a vehicle entering a tile. More... | |
UnitID | GetFreeUnitNumber (VehicleType type) |
Get an unused unit number for a vehicle (if allowed). More... | |
bool | CanBuildVehicleInfrastructure (VehicleType type, byte subtype) |
Check whether we can build infrastructure for the given vehicle type. More... | |
LiveryScheme | GetEngineLiveryScheme (EngineID engine_type, EngineID parent_engine_type, const Vehicle *v) |
Determines the LiveryScheme for a vehicle. More... | |
const Livery * | GetEngineLivery (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting) |
Determines the livery for a vehicle. More... | |
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. More... | |
PaletteID | GetVehiclePalette (const Vehicle *v) |
Get the colour map for a vehicle. More... | |
static void | SpawnAdvancedVisualEffect (const Vehicle *v) |
Call CBID_VEHICLE_SPAWN_VISUAL_EFFECT and spawn requested effects. More... | |
void | VehiclesYearlyLoop () |
bool | CanVehicleUseStation (EngineID engine_type, const Station *st) |
Can this station be used by the given engine type? More... | |
bool | CanVehicleUseStation (const Vehicle *v, const Station *st) |
Can this station be used by the given vehicle? More... | |
void | GetVehicleSet (VehicleSet &set, Vehicle *v, uint8 num_vehicles) |
Calculates the set of vehicles that will be affected by a given selection. More... | |
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 int | GEN_HASHX_SIZE = 1 << (GEN_HASHX_BUCKET_BITS + GEN_HASHX_BITS + ZOOM_LVL_SHIFT) |
static const int | GEN_HASHY_SIZE = 1 << (GEN_HASHY_BUCKET_BITS + GEN_HASHY_BITS + ZOOM_LVL_SHIFT) |
static const int | GEN_HASHX_INC = 1 |
static const int | 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 |
VehicleID | _new_vehicle_id |
uint | _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). | |
VehiclePool | _vehicle_pool ("Vehicle") |
The pool with all our precious vehicles. | |
const int | HASH_BITS = 7 |
const int | HASH_SIZE = 1 << HASH_BITS |
const int | HASH_MASK = HASH_SIZE - 1 |
const int | TOTAL_HASH_SIZE = 1 << (HASH_BITS * 2) |
const int | TOTAL_HASH_MASK = TOTAL_HASH_SIZE - 1 |
const int | HASH_RES = 0 |
static Vehicle * | _vehicle_tile_hash [TOTAL_HASH_SIZE] |
static Vehicle * | _vehicle_viewport_hash [1<<(GEN_HASHX_BITS+GEN_HASHY_BITS)] |
static AutoreplaceMap | _vehicles_to_autoreplace |
static const byte | _breakdown_chance [64] |
static const Direction | _new_direction_table [] |
static const int8 | _vehicle_smoke_pos [8] |
Base implementations of all vehicles.
Definition in file vehicle.cpp.
typedef SmallMap<Vehicle *, bool> AutoreplaceMap |
List of vehicles that should check for autoreplace this tick.
Mapping of vehicle -> leave depot immediately after autoreplace.
Definition at line 687 of file vehicle.cpp.
void AgeVehicle | ( | Vehicle * | v | ) |
Update age of a vehicle.
v | Vehicle to update. |
Definition at line 1363 of file vehicle.cpp.
References _local_company, AddVehicleAdviceNewsItem(), Vehicle::age, Engine::company_avail, DAYS_IN_LEAP_YEAR, CompanySettings::engine_renew, Vehicle::engine_type, EngineHasReplacementForCompany(), SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Vehicle::GetEngine(), Vehicle::group_id, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, GroundVehicle< T, Type >::IsEngine(), Vehicle::IsPrimaryVehicle(), Vehicle::max_age, MAX_DAY, Vehicle::owner, Vehicle::Previous(), Vehicle::reliability_spd_dec, SetDParam(), Company::settings, SetWindowDirty(), BaseVehicle::type, VEH_TRAIN, VEHICLE_PROFIT_MIN_AGE, GroupStatistics::VehicleReachedProfitAge(), Vehicle::vehstatus, VS_CRASHED, and WC_VEHICLE_DETAILS.
Referenced by Train::OnNewDay(), and RoadVehicle::OnNewDay().
Calculates how full a vehicle is.
front | The front vehicle of the consist to check. |
colour | The string to show depending on if we are unloading or loading |
Definition at line 1413 of file vehicle.cpp.
References Vehicle::current_order, and Order::IsType().
bool CanBuildVehicleInfrastructure | ( | VehicleType | type, |
byte | 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.
type | the vehicle type to check this for |
Definition at line 1814 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(), and BuildDocksToolbarWindow::OnInvalidateData().
Can this station be used by the given vehicle?
v | the vehicle to test |
st | the station to test for |
Definition at line 2871 of file vehicle.cpp.
References CanVehicleUseStation(), Vehicle::engine_type, SpecializedVehicle< RoadVehicle, Type >::From(), BaseVehicle::type, and VEH_ROAD.
Can this station be used by the given engine type?
engine_type | the type of vehicles to test |
st | the station to test for |
Definition at line 2838 of file vehicle.cpp.
References AIR_CTOL, AirportFTAClass::AIRPLANES, Station::airport, FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, BaseStation::facilities, AirportFTAClass::flags, Airport::GetFTA(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), AirportFTAClass::HELICOPTERS, AircraftVehicleInfo::subtype, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CanVehicleUseStation(), CmdBuildAircraft(), and Aircraft::FindClosestDepot().
Find the vehicle close to the clicked coordinates.
vp | Viewport clicked in. |
x | X coordinate in the viewport. |
y | Y coordinate in the viewport. |
nullptr
if none found. Definition at line 1201 of file vehicle.cpp.
void DecreaseVehicleValue | ( | Vehicle * | v | ) |
Decrease the value of a vehicle.
v | Vehicle to devaluate. |
Definition at line 1235 of file vehicle.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SetWindowDirty(), Vehicle::value, and WC_VEHICLE_DETAILS.
Referenced by Ship::OnNewDay(), Aircraft::OnNewDay(), Train::OnNewDay(), and RoadVehicle::OnNewDay().
|
static |
Add vehicle sprite for drawing to the screen.
v | Vehicle to draw. |
Definition at line 1077 of file vehicle.cpp.
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 601 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CmdConvertRail(), and EnsureNoTrainOnTrack().
CommandCost EnsureNoVehicleOnGround | ( | TileIndex | tile | ) |
Ensure there is no vehicle at the ground at the given position.
tile | Position to examine. |
Definition at line 539 of file vehicle.cpp.
References EnsureNoVehicleProcZ(), GetTileMaxPixelZ(), return_cmd_error, BaseVehicle::type, and VehicleFromPos().
Referenced by CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdConvertRail(), DoBuildLock(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), and RemoveLock().
Callback that returns 'real' vehicles lower or at height *
(int*)data .
v | Vehicle to examine. |
data | Pointer to height data. |
nullptr
. Definition at line 524 of file vehicle.cpp.
References AIR_SHADOW, Vehicle::subtype, BaseVehicle::type, VEH_AIRCRAFT, VEH_DISASTER, and Vehicle::z_pos.
Referenced by EnsureNoVehicleOnGround().
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 498 of file vehicle.cpp.
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 438 of file vehicle.cpp.
Referenced by CheckTrainCollision().
const Livery* GetEngineLivery | ( | EngineID | engine_type, |
CompanyID | company, | ||
EngineID | parent_engine_type, | ||
const Vehicle * | v, | ||
byte | livery_setting | ||
) |
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. nullptr if in purchase list etc. |
livery_setting | The livery settings to use for acquiring the livery information. |
Definition at line 1953 of file vehicle.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().
Referenced by LiveryHelper().
LiveryScheme GetEngineLiveryScheme | ( | EngineID | engine_type, |
EngineID | parent_engine_type, | ||
const Vehicle * | v | ||
) |
Determines the LiveryScheme for a vehicle.
engine_type | Engine of the vehicle. |
parent_engine_type | Engine of the front vehicle, INVALID_ENGINE if vehicle is at front itself. |
v | the vehicle, nullptr if in purchase list etc. |
Definition at line 1862 of file vehicle.cpp.
References Vehicle::cargo_type, CT_INVALID, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get().
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 2031 of file vehicle.cpp.
UnitID GetFreeUnitNumber | ( | VehicleType | type | ) |
Get an unused unit number for a vehicle (if allowed).
type | Type of vehicle |
UINT16_MAX
. Definition at line 1785 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().
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 1680 of file vehicle.cpp.
Referenced by DisasterTick_Aircraft(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Submarine(), DisasterTick_Zeppeliner(), and TrainController().
Get the colour map for a vehicle.
v | Vehicle to get colour map for |
Definition at line 2041 of file vehicle.cpp.
References Vehicle::IsGroundVehicle().
void GetVehicleSet | ( | VehicleSet & | set, |
Vehicle * | v, | ||
uint8 | num_vehicles | ||
) |
Calculates the set of vehicles that will be affected by a given selection.
[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). |
Definition at line 2946 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().
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.
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 513 of file vehicle.cpp.
Referenced by CYapfCostShipT< Types >::PfCalcCost(), 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-nullptr.
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 454 of file vehicle.cpp.
|
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 == _date_fract", so each day, all vehicles are processes in DAY_TICKS steps.
Definition at line 910 of file vehicle.cpp.
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 297 of file vehicle.cpp.
References _networking, CMD_PAUSE, DC_EXEC, DoCommand(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetGRFConfig(), Engine::GetGRFID(), GRFConfig::GetName(), GRFConfig::grf_bugs, HasBit(), PM_PAUSED_ERROR, PM_PAUSED_NORMAL, SetBit(), SetDParam(), SetDParamStr(), ShowErrorMessage(), and WL_CRITICAL.
Referenced by Vehicle::UpdateVisualEffect(), and VehicleLengthChanged().
|
static |
Call CBID_VEHICLE_SPAWN_VISUAL_EFFECT and spawn requested effects.
v | Vehicle to create effects for. |
Definition at line 2513 of file vehicle.cpp.
References CBID_VEHICLE_SPAWN_VISUAL_EFFECT, and GetVehicleCallback().
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 568 of file vehicle.cpp.
References GetVehicleTunnelBridgeProc(), return_cmd_error, BaseVehicle::type, and VehicleFromPos().
Referenced by ClearPathReservation(), CmdConvertRail(), DoClearBridge(), and DoClearTunnel().
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 1472 of file vehicle.cpp.
References _settings_client, CCF_ARRANGE, ClrBit(), Train::ConsistChanged(), Vehicle::First(), SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Ship, VEH_SHIP >::From(), ClientSettings::gui, HandleAircraftEnterHangar(), INVALID_DIAGDIR, MarkTileDirtyByTile(), Vehicle::owner, SetDepotReservation(), SetWindowClassesDirty(), SetWindowDirty(), GUISettings::show_track_reservation, Ship::state, TFP_NONE, Vehicle::tile, TRACK_BIT_DEPOT, BaseVehicle::type, Ship::UpdateCache(), UpdateSignalsOnSegment(), SpecializedVehicle< T, Type >::UpdateViewport(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, VRF_TOGGLE_REVERSE, Train::wait_counter, WC_AIRCRAFT_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_TRAINS_LIST, and WC_VEHICLE_DEPOT.
Referenced by AircraftEventHandler_EnterHangar().
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 892 of file vehicle.cpp.
VehicleEnterTileStatus VehicleEnterTile | ( | Vehicle * | v, |
TileIndex | tile, | ||
int | x, | ||
int | y | ||
) |
Call the tile callback function for a vehicle entering a tile.
Definition at line 1734 of file vehicle.cpp.
Referenced by TrainController(), and UpdateStatusAfterSwap().
|
static |
Helper function for FindVehicleOnPos/HasVehicleOnPos.
tile | The location on the map |
data | Arbitrary data passed to proc. |
proc | The proc that determines whether a vehicle will be "found". |
find_first | Whether to return on the first found or iterate over all vehicles |
Definition at line 469 of file vehicle.cpp.
Referenced by EnsureNoTrainOnTrackBits(), EnsureNoVehicleOnGround(), and TunnelBridgeIsFree().
|
static |
Helper function for FindVehicleOnPos/HasVehicleOnPos.
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". |
find_first | Whether to return on the first found or iterate over all vehicles |
Definition at line 411 of file vehicle.cpp.
void VehicleLengthChanged | ( | const Vehicle * | u | ) |
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
u | first vehicle of chain |
Definition at line 330 of file vehicle.cpp.
References Vehicle::engine_type, GamelogGRFBugReverse(), GBUG_VEH_LENGTH, Vehicle::GetEngine(), GetGRFConfig(), GRFConfig::grf_bugs, Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), GRFFilePropsBase< Tcnt >::local_id, and ShowNewGrfVehicleError().
Referenced by RoadVehUpdateCache().
byte VehicleRandomBits | ( | ) |
Get a value for a vehicle's random_bits.
Definition at line 363 of file vehicle.cpp.
References GB().
void VehicleServiceInDepot | ( | Vehicle * | v | ) |
Service a vehicle and all subsequent vehicles in the consist.
*v | The vehicle or vehicle chain being serviced |
Definition at line 162 of file vehicle.cpp.
References _date, _settings_game, Vehicle::breakdown_chance, Vehicle::breakdowns_since_last_service, Vehicle::date_of_last_service, GameSettings::difficulty, Vehicle::GetEngine(), Vehicle::HasEngineType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::Next(), Engine::reliability, Vehicle::reliability, SetWindowDirty(), DifficultySettings::vehicle_breakdowns, and WC_VEHICLE_DETAILS.
Referenced by AircraftLeaveHangar(), and CheckIfTrainNeedsService().
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 1107 of file vehicle.cpp.
References MAX_VEHICLE_PIXEL_X.
|
static |
Definition at line 1241 of file vehicle.cpp.
|
static |
|
static |
Definition at line 2505 of file vehicle.cpp.