#include "tile_type.h"
#include "strings_type.h"
#include "gfx_type.h"
#include "direction_type.h"
#include "cargo_type.h"
#include "command_type.h"
#include "vehicle_type.h"
#include "engine_type.h"
#include "transport_type.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) |
Functions | |
void | VehicleServiceInDepot (Vehicle *v) |
void | VehiclePositionChanged (Vehicle *v) |
Vehicle * | GetLastVehicleInChain (Vehicle *v) |
const Vehicle * | GetLastVehicleInChain (const Vehicle *v) |
uint | CountVehiclesInChain (const Vehicle *v) |
bool | IsEngineCountable (const Vehicle *v) |
Check if a vehicle is counted in num_engines in each company struct. | |
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 in on a specific location. | |
bool | HasVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc) |
Checks whether a vehicle in on a specific location. | |
void | CallVehicleTicks () |
uint8 | CalcPercentVehicleFilled (const Vehicle *v, StringID *colour) |
Calculates how full a vehicle is. | |
void | InitializeTrains () |
byte | VehicleRandomBits () |
Get a value for a vehicle's random_bits. | |
void | ResetVehiclePosHash () |
void | ResetVehicleColourMap () |
bool | CanRefitTo (EngineID engine_type, CargoID cid_to) |
Check if a given engine type can be refitted to a given cargo. | |
CargoID | FindFirstRefittableCargo (EngineID engine_type) |
Find the first cargo type that an engine can be refitted to. | |
CommandCost | GetRefitCost (EngineID engine_type) |
Learn the price of refitting a certain engine. | |
void | ViewportAddVehicles (DrawPixelInfo *dpi) |
SpriteID | GetRotorImage (const Vehicle *v) |
StringID | VehicleInTheWayErrMsg (const Vehicle *v) |
bool | HasVehicleOnTunnelBridge (TileIndex tile, TileIndex endtile, const Vehicle *ignore=NULL) |
Finds vehicle in tunnel / bridge. | |
void | DecreaseVehicleValue (Vehicle *v) |
void | CheckVehicleBreakdown (Vehicle *v) |
void | AgeVehicle (Vehicle *v) |
void | VehicleEnteredDepotThisTick (Vehicle *v) |
Adds a vehicle to the list of vehicles, that visited a depot this tick. | |
void | BeginVehicleMove (const Vehicle *v) |
Stores the vehicle image coords for later call to EndVehicleMove(). | |
void | EndVehicleMove (const Vehicle *v) |
Marks screen dirty after a vehicle has moved. | |
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) |
void | TrainConsistChanged (Vehicle *v, bool same_length) |
Recalculates the cached stuff of a train. | |
void | TrainPowerChanged (Vehicle *v) |
Recalculates the cached total power of a train. | |
Money | GetTrainRunningCost (const Vehicle *v) |
CommandCost | SendAllVehiclesToDepot (VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id) |
Send all vehicles of type to depots. | |
void | VehicleEnterDepot (Vehicle *v) |
bool | CanBuildVehicleInfrastructure (VehicleType type) |
Check whether we can build infrastructure for the given vehicle type. | |
void | CcCloneVehicle (bool success, TileIndex tile, uint32 p1, uint32 p2) |
This is the Callback method after the cloning attempt of a vehicle. | |
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) |
static bool | IsCompanyBuildableVehicleType (const BaseVehicle *v) |
struct Livery * | GetEngineLivery (EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v) |
SpriteID | GetEnginePalette (EngineID engine_type, CompanyID company) |
Get the colour map for an engine. | |
SpriteID | GetVehiclePalette (const Vehicle *v) |
Get the colour map for a vehicle. | |
static uint32 | GetCmdBuildVeh (VehicleType type) |
static uint32 | GetCmdBuildVeh (const BaseVehicle *v) |
static uint32 | GetCmdSellVeh (VehicleType type) |
static uint32 | GetCmdSellVeh (const BaseVehicle *v) |
static uint32 | GetCmdRefitVeh (VehicleType type) |
static uint32 | GetCmdRefitVeh (const BaseVehicle *v) |
static uint32 | GetCmdSendToDepot (VehicleType type) |
static uint32 | GetCmdSendToDepot (const BaseVehicle *v) |
bool | EnsureNoVehicleOnGround (TileIndex tile) |
void | StopAllVehicles () |
bool | CanVehicleUseStation (EngineID engine_type, const struct Station *st) |
bool | CanVehicleUseStation (const Vehicle *v, const struct Station *st) |
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 | _vehicle_id_ctr_day |
const Vehicle * | _place_clicked_vehicle |
VehicleID | _new_vehicle_id |
uint16 | _returned_refit_capacity |
Definition in file vehicle_func.h.
void BeginVehicleMove | ( | const Vehicle * | v | ) |
Stores the vehicle image coords for later call to EndVehicleMove().
v | vehicle which image's coords to store |
Definition at line 1642 of file vehicle.cpp.
References Rect::bottom, Rect::left, Rect::right, and Rect::top.
uint8 CalcPercentVehicleFilled | ( | const Vehicle * | v, | |
StringID * | colour | |||
) |
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 1442 of file vehicle.cpp.
References Station::goods, HasBit(), max(), and OUFB_UNLOAD.
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 1836 of file vehicle.cpp.
References _settings_client, _settings_game, GUISettings::always_build_infrastructure, ClientSettings::gui, HasBit(), max(), VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, and GameSettings::vehicle.
Check if a given engine type can be refitted to a given cargo.
engine_type | Engine type to check | |
cid_to | check refit to this cargo-type |
Definition at line 716 of file vehicle.cpp.
References HasBit().
Referenced by AIEngine::CanRefitCargo(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), and CmdRefitShip().
void CcCloneVehicle | ( | bool | success, | |
TileIndex | tile, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
This is the Callback method after the cloning attempt of a vehicle.
success | indicates completion (or not) of the operation | |
tile | unused | |
p1 | unused | |
p2 | unused |
Definition at line 138 of file depot_gui.cpp.
References ShowVehicleViewWindow().
void EndVehicleMove | ( | const Vehicle * | v | ) |
Marks screen dirty after a vehicle has moved.
v | vehicle which is marked dirty |
Definition at line 1656 of file vehicle.cpp.
References Rect::bottom, Rect::left, MarkAllViewportsDirty(), max(), min(), Rect::right, and Rect::top.
Find the first cargo type that an engine can be refitted to.
engine_type | Which engine to find cargo for. |
Definition at line 725 of file vehicle.cpp.
References HasBit().
Referenced by CalculateRefitMasks().
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!
Use this when you have the intention that all vehicles should be iterated over.
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 371 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CheckTrainCollision(), CmdConvertRail(), DeleteLastWagon(), FloodVehicles(), GetTrainForReservation(), 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!
Use this when you have the intention that all vehicles should be iterated over.
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 311 of file vehicle.cpp.
References VehicleFromPosXY().
Referenced by CheckTrainCollision().
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 2014 of file vehicle.cpp.
Referenced by DrawEngineList().
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 1683 of file vehicle.cpp.
References GetNewVehiclePosResult::new_tile, GetNewVehiclePosResult::old_tile, GetNewVehiclePosResult::x, and GetNewVehiclePosResult::y.
Referenced by AircraftController(), DisasterTick_Airplane(), DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Helicopter(), DisasterTick_Submarine(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), UpdateAirplanesOnNewStation(), and UpdateOldAircraft().
CommandCost GetRefitCost | ( | EngineID | engine_type | ) |
Learn the price of refitting a certain engine.
engine_type | Which engine to refit |
Definition at line 742 of file vehicle.cpp.
References RAILVEH_WAGON.
Referenced by CmdCloneVehicle(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), and CmdRefitShip().
SpriteID GetVehiclePalette | ( | const Vehicle * | v | ) |
Get the colour map for a vehicle.
v | Vehicle to get colour map for |
Definition at line 2019 of file vehicle.cpp.
bool HasVehicleOnPos | ( | TileIndex | tile, | |
void * | data, | |||
VehicleFromPosProc * | proc | |||
) |
Checks whether a vehicle in 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 386 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CheckRoadBlockedForOvertaking(), EnsureNoTrainOnTrack(), ExploreSegment(), FollowTrainReservation(), HasVehicleOnTunnelBridge(), 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 327 of file vehicle.cpp.
References VehicleFromPosXY().
Finds vehicle in tunnel / bridge.
tile | first end | |
endtile | second end | |
ignore | Ignore this vehicle when searching |
Definition at line 180 of file vehicle.cpp.
References GetVehicleTunnelBridgeProc(), and HasVehicleOnPos().
Referenced by ClearPathReservation(), CmdBuildRoad(), CmdConvertRail(), and RemoveRoad().
bool IsEngineCountable | ( | const Vehicle * | v | ) |
Check if a vehicle is counted in num_engines in each company struct.
*v | Vehicle to test |
Definition at line 527 of file vehicle.cpp.
References IsArticulatedPart(), IsNormalAircraft(), and IsRearDualheaded().
Referenced by CmdAddVehicleGroup(), SetCachedEngineCounts(), SetTrainGroupID(), and UpdateTrainGroupID().
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 1674 of file vehicle.cpp.
References MarkAllViewportsDirty().
Referenced by DisasterTick_Helicopter_Rotors(), DisasterTick_Submarine(), DisasterTick_Ufo(), and InitializeDisasterVehicle().
CommandCost SendAllVehiclesToDepot | ( | VehicleType | type, | |
DoCommandFlag | flags, | |||
bool | service, | |||
Owner | owner, | |||
uint16 | vlw_flag, | |||
uint32 | id | |||
) |
Send all vehicles of type to depots.
type | type of vehicle | |
flags | the flags used for DoCommand() | |
service | should the vehicles only get service in the depots | |
owner | owner of the vehicles to send | |
vlw_flag | tells what kind of list requested the goto depot |
Definition at line 1413 of file vehicle.cpp.
References CMD_ERROR, CmdSucceeded(), DC_EXEC, DEPOT_DONT_CANCEL, DoCommand(), GenerateVehicleSortList(), and SmallVector< T, S >::Length().
Referenced by CmdSendAircraftToHangar(), CmdSendRoadVehToDepot(), CmdSendShipToDepot(), and CmdSendTrainToDepot().
void TrainConsistChanged | ( | Vehicle * | v, | |
bool | same_length | |||
) |
Recalculates the cached stuff of a train.
Should be called each time a vehicle is added to/removed from the chain, and when the game is loaded. Note: this needs to be called too for 'wagon chains' (in the depot, without an engine)
v | First vehicle of the chain. | |
same_length | should length of vehicles stay the same? |
Definition at line 232 of file train_cmd.cpp.
References _settings_game, CALLBACK_FAILED, CBID_TRAIN_WAGON_POWER, CBID_VEHICLE_LENGTH, CBM_TRAIN_WAGON_POWER, CBM_VEHICLE_LENGTH, Clamp(), ClrBit(), EF_RAIL_TILTS, GB(), GetRailTypeInfo(), GetVehicleCallback(), HasBit(), InvalidateWindow(), IsArticulatedPart(), IsFreeWagon(), IsFrontEngine(), IsTrainEngine(), IsTrainWagon(), min(), RailtypeInfo::powered_railtypes, RAILTYPE_RAIL, RAILTYPES_NONE, RAILTYPES_RAIL, RAILVEH_WAGON, RailVehicleLengthChanged(), SetBit(), TrainCargoChanged(), UsesWagonOverride(), GameSettings::vehicle, and VehicleSettings::wagon_speed_limits.
Referenced by AfterLoadVehicles(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdMoveRailVehicle(), CmdRefitRailVehicle(), CmdSellRailWagon(), DeleteLastWagon(), StateGameLoop(), and TransferCargo().
void TrainPowerChanged | ( | Vehicle * | v | ) |
Recalculates the cached total power of a train.
Should be called when the consist is changed
v | First vehicle of the consist. |
Definition at line 88 of file train_cmd.cpp.
References GetRailType(), HasBit(), HasPowerOnRail(), InvalidateWindow(), InvalidateWindowWidget(), IsArticulatedPart(), and IsMultiheaded().
Referenced by SettingsDisableElrail(), TrainCargoChanged(), and UpdateTrainPowerProc().
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 617 of file vehicle.cpp.
References ODATFB_HALT.
byte VehicleRandomBits | ( | ) |
Get a value for a vehicle's random_bits.
Definition at line 220 of file vehicle.cpp.
References GB().
Referenced by CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVeh(), and CmdBuildShip().