#include "stdafx.h"
#include "openttd.h"
#include "road_map.h"
#include "roadveh.h"
#include "ship.h"
#include "spritecache.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "timetable.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "news.h"
#include "command_func.h"
#include "saveload.h"
#include "player_func.h"
#include "engine.h"
#include "debug.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "station.h"
#include "rail_type.h"
#include "train.h"
#include "aircraft.h"
#include "industry_map.h"
#include "station_map.h"
#include "water_map.h"
#include "network/network.h"
#include "yapf/yapf.h"
#include "newgrf_callbacks.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "group.h"
#include "order.h"
#include "strings_func.h"
#include "zoom_func.h"
#include "functions.h"
#include "date_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "signal_func.h"
#include "sound_func.h"
#include "variables.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "string_func.h"
#include "settings_type.h"
#include "table/sprites.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | BulldozerMovement |
struct | BubbleMovement |
Defines | |
#define | INVALID_COORD (0x7fffffff) |
#define | GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6)) |
#define | MK(x, y, z, i) { x, y, z, i } |
#define | ME(i) { i, 4, 0, 0 } |
Typedefs | |
typedef void | EffectInitProc (Vehicle *v) |
typedef void | EffectTickProc (Vehicle *v) |
Functions | |
void | VehicleServiceInDepot (Vehicle *v) |
StringID | VehicleInTheWayErrMsg (const Vehicle *v) |
static void * | EnsureNoVehicleProcZ (Vehicle *v, void *data) |
bool | EnsureNoVehicleOnGround (TileIndex tile) |
static void * | GetVehicleTunnelBridgeProc (Vehicle *v, void *data) |
Procedure called for every vehicle found in tunnel/bridge in the hash map. | |
bool | HasVehicleOnTunnelBridge (TileIndex tile, TileIndex endtile) |
Finds vehicle in tunnel / bridge. | |
static void | UpdateVehiclePosHash (Vehicle *v, int x, int y) |
void | VehiclePositionChanged (Vehicle *v) |
void | AfterLoadVehicles (bool clear_te_id) |
Called after load to update coordinates. | |
byte | VehicleRandomBits () |
Get a value for a vehicle's random_bits. | |
static void * | VehicleFromHash (int xl, int yl, int xu, int yu, void *data, VehicleFromPosProc *proc, bool find_first) |
static void * | VehicleFromPosXY (int x, int y, void *data, VehicleFromPosProc *proc, bool find_first) |
Helper function for FindVehicleOnPos/HasVehicleOnPos. | |
void | FindVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc) |
Find a vehicle from a specific location. | |
bool | HasVehicleOnPosXY (int x, int y, void *data, VehicleFromPosProc *proc) |
Checks whether a vehicle in on a specific location. | |
static void * | VehicleFromPos (TileIndex tile, void *data, VehicleFromPosProc *proc, bool find_first) |
Helper function for FindVehicleOnPos/HasVehicleOnPos. | |
void | FindVehicleOnPos (TileIndex tile, 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. | |
static void | UpdateNewVehiclePosHash (Vehicle *v, bool remove) |
void | ResetVehiclePosHash () |
void | ResetVehicleColorMap () |
void | InitializeVehicles () |
Vehicle * | GetLastVehicleInChain (Vehicle *v) |
uint | CountVehiclesInChain (const Vehicle *v) |
bool | IsEngineCountable (const Vehicle *v) |
Check if a vehicle is counted in num_engines in each player struct. | |
void | DeleteVehicleChain (Vehicle *v) |
Deletes all vehicles in a chain. | |
void | VehicleEnteredDepotThisTick (Vehicle *v) |
Adds a vehicle to the list of vehicles, that visited a depot this tick. | |
void | CallVehicleTicks () |
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. | |
static void | DoDrawVehicle (const Vehicle *v) |
void | ViewportAddVehicles (DrawPixelInfo *dpi) |
static void | ChimneySmokeInit (Vehicle *v) |
static void | ChimneySmokeTick (Vehicle *v) |
static void | SteamSmokeInit (Vehicle *v) |
static void | SteamSmokeTick (Vehicle *v) |
static void | DieselSmokeInit (Vehicle *v) |
static void | DieselSmokeTick (Vehicle *v) |
static void | ElectricSparkInit (Vehicle *v) |
static void | ElectricSparkTick (Vehicle *v) |
static void | SmokeInit (Vehicle *v) |
static void | SmokeTick (Vehicle *v) |
static void | ExplosionLargeInit (Vehicle *v) |
static void | ExplosionLargeTick (Vehicle *v) |
static void | BreakdownSmokeInit (Vehicle *v) |
static void | BreakdownSmokeTick (Vehicle *v) |
static void | ExplosionSmallInit (Vehicle *v) |
static void | ExplosionSmallTick (Vehicle *v) |
static void | BulldozerInit (Vehicle *v) |
static void | BulldozerTick (Vehicle *v) |
static void | BubbleInit (Vehicle *v) |
static void | BubbleTick (Vehicle *v) |
Vehicle * | CreateEffectVehicle (int x, int y, int z, EffectVehicle type) |
Vehicle * | CreateEffectVehicleAbove (int x, int y, int z, EffectVehicle type) |
Vehicle * | CreateEffectVehicleRel (const Vehicle *v, int x, int y, int z, EffectVehicle type) |
Vehicle * | CheckClickOnVehicle (const ViewPort *vp, int x, int y) |
void | CheckVehicle32Day (Vehicle *v) |
void | DecreaseVehicleValue (Vehicle *v) |
void | CheckVehicleBreakdown (Vehicle *v) |
static void | ShowVehicleGettingOld (Vehicle *v, StringID msg) |
void | AgeVehicle (Vehicle *v) |
CommandCost | CmdMassStartStopVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Starts or stops a lot of vehicles. | |
CommandCost | CmdDepotSellAllVehicles (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Sells all vehicles in a depot. | |
CommandCost | CmdDepotMassAutoReplace (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Autoreplace all vehicles in the depot. | |
CommandCost | CmdCloneVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Clone a vehicle. | |
static void | ExtendVehicleListSize (const Vehicle ***engine_list, uint16 *engine_list_length, uint16 step_size) |
void | BuildDepotVehicleList (VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count) |
Generates a list of vehicles inside a depot Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0) If one of the lists is not needed (say wagons when finding ships), all the pointers regarding that list should be set to NULL. | |
uint | GenerateVehicleSortList (const Vehicle ***sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type) |
CommandCost | SendAllVehiclesToDepot (VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id) |
send all vehicles of type to depots | |
uint8 | CalcPercentVehicleFilled (Vehicle *v, StringID *color) |
Calculates how full a vehicle is. | |
void | VehicleEnterDepot (Vehicle *v) |
static bool | IsUniqueVehicleName (const char *name) |
CommandCost | CmdNameVehicle (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Give a custom name to your vehicle. | |
CommandCost | CmdChangeServiceInt (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Change the service interval of a vehicle. | |
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);. | |
GetNewVehiclePosResult | GetNewVehiclePos (const Vehicle *v) |
Direction | GetDirectionTowards (const Vehicle *v, int x, int y) |
Trackdir | GetVehicleTrackdir (const Vehicle *v) |
Returns the Trackdir on which the vehicle is currently located. | |
uint32 | VehicleEnterTile (Vehicle *v, TileIndex tile, int x, int y) |
Returns some meta-data over the to be entered tile. | |
UnitID | GetFreeUnitNumber (VehicleType type) |
bool | CanBuildVehicleInfrastructure (VehicleType type) |
Check whether we can build infrastructure for the given vehicle type. | |
const Livery * | GetEngineLivery (EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v) |
static SpriteID | GetEngineColourMap (EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v) |
SpriteID | GetEnginePalette (EngineID engine_type, PlayerID player) |
Get the colour map for an engine. | |
SpriteID | GetVehiclePalette (const Vehicle *v) |
Get the colour map for a vehicle. | |
const SaveLoad * | GetVehicleDescription (VehicleType vt) |
Make it possible to make the saveload tables "friends" of other classes. | |
static void | Save_VEHS () |
Will be called when the vehicles need to be saved. | |
static void | Load_VEHS () |
Will be called when vehicles need to be loaded. | |
void | StopAllVehicles () |
Variables | |
VehicleID | _vehicle_id_ctr_day |
Vehicle * | _place_clicked_vehicle |
VehicleID | _new_vehicle_id |
uint16 | _returned_refit_capacity |
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 [] |
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 * | _new_vehicle_position_hash [TOTAL_HASH_SIZE] |
static Vehicle * | _vehicle_position_hash [0x1000] |
static Vehicle * | _first_veh_in_depot_list |
head of the linked list to tell what vehicles that visited a depot in a tick | |
static const BulldozerMovement | _bulldozer_movement [] |
struct { | |
int8 x | |
int8 y | |
} | _inc_by_dir [] |
static const BubbleMovement | _bubble_float_sw [] |
static const BubbleMovement | _bubble_float_ne [] |
static const BubbleMovement | _bubble_float_se [] |
static const BubbleMovement | _bubble_float_nw [] |
static const BubbleMovement | _bubble_burst [] |
static const BubbleMovement | _bubble_absorb [] |
static const BubbleMovement *const | _bubble_movement [] |
static EffectInitProc *const | _effect_init_procs [] |
static EffectTickProc *const | _effect_tick_procs [] |
static const byte | _breakdown_chance [64] |
static const StringID | _vehicle_type_names [4] |
static Rect | _old_vehicle_coords |
coords of vehicle before it has moved | |
static const Direction | _new_direction_table [] |
static uint8 | _cargo_days |
static uint16 | _cargo_source |
static uint32 | _cargo_source_xy |
static uint16 | _cargo_count |
static uint16 | _cargo_paid_for |
static Money | _cargo_feeder_share |
static uint32 | _cargo_loaded_at_xy |
const ChunkHandler | _veh_chunk_handlers [] |
Definition in file vehicle.cpp.
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 2451 of file vehicle.cpp.
void BuildDepotVehicleList | ( | VehicleType | type, | |
TileIndex | tile, | |||
Vehicle *** | engine_list, | |||
uint16 * | engine_list_length, | |||
uint16 * | engine_count, | |||
Vehicle *** | wagon_list, | |||
uint16 * | wagon_list_length, | |||
uint16 * | wagon_count | |||
) |
Generates a list of vehicles inside a depot Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0) If one of the lists is not needed (say wagons when finding ships), all the pointers regarding that list should be set to NULL.
type | Type of vehicle | |
tile | The tile the depot is located in | |
***engine_list | Pointer to a pointer to an array of vehicles in the depot (old list is freed and a new one is malloced) | |
*engine_list_length | Allocated size of engine_list. Needs to be set to 0 when engine_list points to a NULL array | |
*engine_count | The number of engines stored in the list | |
***wagon_list | Pointer to a pointer to an array of free wagons in the depot (old list is freed and a new one is malloced) | |
*wagon_list_length | Allocated size of wagon_list. Needs to be set to 0 when wagon_list points to a NULL array | |
*wagon_count | The number of engines stored in the list |
Definition at line 2003 of file vehicle.cpp.
References IsFreeWagon(), IsFrontEngine(), IsNormalAircraft(), and TRACK_BIT_DEPOT.
Referenced by CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), and CmdMassStartStopVehicle().
uint8 CalcPercentVehicleFilled | ( | Vehicle * | v, | |
StringID * | color | |||
) |
Calculates how full a vehicle is.
v | The Vehicle to check. For trains, use the first engine. | |
color | The string to show depending on if we are unloading or loading |
Definition at line 2221 of file vehicle.cpp.
References HasBit(), max(), and OFB_UNLOAD.
Referenced by LoadUnloadVehicle().
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 2641 of file vehicle.cpp.
References HasBit().
bool CanRefitTo | ( | EngineID | engine_type, | |
CargoID | cid_to | |||
) |
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 771 of file vehicle.cpp.
References HasBit().
Referenced by CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), and EnginesGotCargoInCommon().
CommandCost CmdChangeServiceInt | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Change the service interval of a vehicle.
tile | unused | |
flags | type of operation | |
p1 | vehicle ID that is being service-interval-changed | |
p2 | new service interval |
Definition at line 2423 of file vehicle.cpp.
References CMD_ERROR, DC_EXEC, GetServiceIntervalClamped(), and IsValidVehicleID().
CommandCost CmdCloneVehicle | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Clone a vehicle.
If it is a train, it will clone all the cars too
tile | tile of the depot where the cloned vehicle is build | |
flags | type of operation | |
p1 | the original vehicle's index | |
p2 | 1 = shared orders, else copied orders |
Definition at line 1822 of file vehicle.cpp.
References CommandCost::AddCost(), CMD_ADD_VEHICLE_GROUP, CMD_CLONE_ORDER, CMD_ERROR, CMD_MOVE_RAIL_VEHICLE, CmdFailed(), CmdSucceeded(), DC_EXEC, DoCommand(), EngineHasArticPart(), GetEngineCargoType(), GetNextArticPart(), GetNextVehicle(), GetRefitCost(), HasBit(), IsFrontEngine(), IsRearDualheaded(), IsValidVehicleID(), return_cmd_error, and SetBit().
CommandCost CmdDepotMassAutoReplace | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Autoreplace all vehicles in the depot.
tile | Tile of the depot where the vehicles are | |
flags | type of operation | |
p1 | Type of vehicle | |
p2 | Unused |
Definition at line 1757 of file vehicle.cpp.
References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, CmdSucceeded(), DC_EXEC, GB(), CommandCost::GetCost(), IsDepotTile(), and IsTileOwner().
CommandCost CmdDepotSellAllVehicles | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Sells all vehicles in a depot.
tile | Tile of the depot where the depot is | |
flags | type of operation | |
p1 | Vehicle type | |
p2 | unused |
Definition at line 1704 of file vehicle.cpp.
References CommandCost::AddCost(), BuildDepotVehicleList(), CMD_ERROR, CMD_SELL_AIRCRAFT, CMD_SELL_RAIL_WAGON, CMD_SELL_ROAD_VEH, CMD_SELL_SHIP, CmdSucceeded(), DoCommand(), GB(), and CommandCost::GetCost().
CommandCost CmdMassStartStopVehicle | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Starts or stops a lot of vehicles.
tile | Tile of the depot where the vehicles are started/stopped (only used for depots) | |
flags | type of operation | |
p1 | Station/Order/Depot ID (only used for vehicle list windows) | |
p2 | bitmask
|
Definition at line 1640 of file vehicle.cpp.
References BuildDepotVehicleList(), CMD_ERROR, CMD_START_STOP_AIRCRAFT, CMD_START_STOP_ROADVEH, CMD_START_STOP_SHIP, CMD_START_STOP_TRAIN, CmdSucceeded(), DC_EXEC, DoCommand(), GB(), GenerateVehicleSortList(), and HasBit().
CommandCost CmdNameVehicle | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Give a custom name to your vehicle.
tile | unused | |
flags | type of operation | |
p1 | vehicle ID to name | |
p2 | unused |
Definition at line 2394 of file vehicle.cpp.
References _cmd_text, CMD_ERROR, DC_EXEC, IsValidVehicleID(), MarkWholeScreenDirty(), and return_cmd_error.
void DeleteVehicleChain | ( | Vehicle * | v | ) |
Deletes all vehicles in a chain.
v | The first vehicle in the chain. |
Definition at line 680 of file vehicle.cpp.
References MarkSingleVehicleDirty().
void EndVehicleMove | ( | const Vehicle * | v | ) |
Marks screen dirty after a vehicle has moved.
v | vehicle which is marked dirty |
Definition at line 2465 of file vehicle.cpp.
References MarkAllViewportsDirty(), max(), and min().
CargoID FindFirstRefittableCargo | ( | EngineID | engine_type | ) |
Find the first cargo type that an engine can be refitted to.
engine_type | Which engine to find cargo for. |
Definition at line 780 of file vehicle.cpp.
References HasBit().
Referenced by CalculateRefitMasks(), and CmdBuildAircraft().
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 457 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CheckTrainCollision(), CmdConvertRail(), FloodVehicles(), 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 397 of file vehicle.cpp.
References VehicleFromPosXY().
Referenced by CheckTrainCollision().
uint GenerateVehicleSortList | ( | const Vehicle *** | sort_list, | |
uint16 * | length_of_array, | |||
VehicleType | type, | |||
PlayerID | owner, | |||
uint32 | index, | |||
uint16 | window_type | |||
) |
sort_list | list to store the list in. Either NULL or the length length_of_array tells | |
length_of_array | informs the length allocated for sort_list. This is not the same as the number of vehicles in the list. Needs to be 0 when sort_list is NULL | |
type | type of vehicle | |
owner | PlayerID of owner to generate a list for | |
index | This parameter has different meanings depending on window_type
| |
window_type | tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h |
Definition at line 2087 of file vehicle.cpp.
References GetFirstVehicleFromSharedList(), and ReallocT().
Referenced by CmdMassStartStopVehicle(), and SendAllVehiclesToDepot().
Get the colour map for an engine.
This used for unbuilt engines in the user interface.
engine_type | ID of engine | |
player | ID of player |
Definition at line 2804 of file vehicle.cpp.
Referenced by DrawEngineList().
CommandCost GetRefitCost | ( | EngineID | engine_type | ) |
Learn the price of refitting a certain engine.
engine_type | Which engine to refit |
Definition at line 797 of file vehicle.cpp.
References RAILVEH_WAGON.
Referenced by CmdCloneVehicle(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), and CmdRefitShip().
const SaveLoad* GetVehicleDescription | ( | VehicleType | vt | ) |
Make it possible to make the saveload tables "friends" of other classes.
vt | the vehicle type. Can be VEH_END for the common vehicle description data |
Save and load of vehicles
Definition at line 2834 of file vehicle.cpp.
References GetVehicleDescription().
Referenced by GetVehicleDescription(), Load_VEHS(), and Save_VEHS().
SpriteID GetVehiclePalette | ( | const Vehicle * | v | ) |
Get the colour map for a vehicle.
v | Vehicle to get colour map for |
Definition at line 2809 of file vehicle.cpp.
References IsArticulatedPart(), RAILVEH_WAGON, and UsesWagonOverride().
Referenced by GroupWndProc().
Trackdir GetVehicleTrackdir | ( | const Vehicle * | v | ) |
Returns the Trackdir on which the vehicle is currently located.
Works for trains and ships. Currently works only sortof for road vehicles, since they have a fuzzy concept of being "on" a trackdir. Dunno really what it returns for a road vehicle that is halfway a tile, never really understood that part. For road vehicles that are at the beginning or end of the tile, should just return the diagonal trackdir on which they are driving. I _think_. For other vehicles types, or vehicles with no clear trackdir (such as those in depots), returns 0xFF.
Definition at line 2536 of file vehicle.cpp.
References DiagdirToDiagTrackdir(), DirToDiagDir(), FindFirstTrack(), GetRailDepotDirection(), GetRoadStopDir(), INVALID_TRACKDIR, IsReversingRoadTrackdir(), TRACK_BIT_DEPOT, TRACK_BIT_WORMHOLE, and TrackDirectionToTrackdir().
Referenced by ChooseShipTrack(), FindClosestTrainDepot(), YapfCheckReverseTrain(), YapfFindNearestRailDepotTwoWay(), and YapfFindNearestRoadDepot().
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 472 of file vehicle.cpp.
References VehicleFromPos().
Referenced by CheckRoadBlockedForOvertaking(), EnsureNoTrainOnTrack(), ExploreSegment(), 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 413 of file vehicle.cpp.
References VehicleFromPosXY().
Finds vehicle in tunnel / bridge.
tile | first end | |
endtile | second end |
Definition at line 187 of file vehicle.cpp.
References GetVehicleTunnelBridgeProc(), and HasVehicleOnPos().
Referenced by CmdBuildRoad(), CmdConvertRail(), and RemoveRoad().
bool IsEngineCountable | ( | const Vehicle * | v | ) |
Check if a vehicle is counted in num_engines in each player struct.
*v | Vehicle to test |
Definition at line 599 of file vehicle.cpp.
References IsArticulatedPart(), IsNormalAircraft(), and IsRearDualheaded().
Referenced by CmdAddVehicleGroup(), InitializeWindowsAndCaches(), SetTrainGroupID(), and UpdateTrainGroupID().
static void Load_VEHS | ( | ) | [static] |
Will be called when vehicles need to be loaded.
Definition at line 3122 of file vehicle.cpp.
References CheckSavegameVersion(), CheckSavegameVersionOldStyle(), CargoPacket::count, CargoPacket::days_in_transit, DEFAULT_GROUP, CargoPacket::feeder_share, GetVehicleDescription(), PoolItem< T, Tid, Tpool >::index, CargoPacket::loaded_at_xy, SlIterateArray(), SlObject(), SlReadByte(), CargoPacket::source, CargoPacket::source_xy, and SpecialVehicle::SpecialVehicle().
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 2483 of file vehicle.cpp.
References MarkAllViewportsDirty().
Referenced by DeleteLastWagon(), DeleteVehicleChain(), DisasterTick_Helicopter_Rotors(), DisasterTick_Submarine(), DisasterTick_Ufo(), and InitializeDisasterVehicle().
static void Save_VEHS | ( | ) | [static] |
Will be called when the vehicles need to be saved.
Definition at line 3111 of file vehicle.cpp.
References GetVehicleDescription(), and SlObject().
CommandCost SendAllVehiclesToDepot | ( | VehicleType | type, | |
uint32 | flags, | |||
bool | service, | |||
PlayerID | 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 | PlayerID of owner of the vehicles to send | |
vlw_flag | tells what kind of list requested the goto depot |
Definition at line 2188 of file vehicle.cpp.
References CMD_ERROR, CmdSucceeded(), DC_EXEC, DoCommand(), and GenerateVehicleSortList().
Referenced by CmdSendAircraftToHangar(), CmdSendRoadVehToDepot(), CmdSendShipToDepot(), and CmdSendTrainToDepot().
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 700 of file vehicle.cpp.
References HasBit().
uint32 VehicleEnterTile | ( | Vehicle * | v, | |
TileIndex | tile, | |||
int | x, | |||
int | y | |||
) |
Returns some meta-data over the to be entered tile.
Definition at line 2581 of file vehicle.cpp.
References GetTileType().
static void* VehicleFromPos | ( | TileIndex | tile, | |
void * | data, | |||
VehicleFromPosProc * | proc, | |||
bool | find_first | |||
) | [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 428 of file vehicle.cpp.
References GB(), TileX(), and TileY().
Referenced by FindVehicleOnPos(), and HasVehicleOnPos().
static void* VehicleFromPosXY | ( | int | x, | |
int | y, | |||
void * | data, | |||
VehicleFromPosProc * | proc, | |||
bool | find_first | |||
) | [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 370 of file vehicle.cpp.
References GB(), and TILE_SIZE.
Referenced by FindVehicleOnPosXY(), and HasVehicleOnPosXY().
byte VehicleRandomBits | ( | ) |
Get a value for a vehicle's random_bits.
Definition at line 302 of file vehicle.cpp.
References GB().
Referenced by CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVeh(), and CmdBuildShip().
const byte _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 1541 of file vehicle.cpp.
const BubbleMovement _bubble_burst[] [static] |
const BubbleMovement _bubble_float_ne[] [static] |
const BubbleMovement _bubble_float_nw[] [static] |
const BubbleMovement _bubble_float_se[] [static] |
const BubbleMovement _bubble_float_sw[] [static] |
const BubbleMovement* const _bubble_movement[] [static] |
Initial value:
{ _bubble_float_sw, _bubble_float_ne, _bubble_float_se, _bubble_float_nw, _bubble_burst, _bubble_absorb, }
Definition at line 1347 of file vehicle.cpp.
const BulldozerMovement _bulldozer_movement[] [static] |
Initial value:
{ { 0, 0, 4 }, { 3, 3, 4 }, { 2, 2, 7 }, { 0, 2, 7 }, { 1, 1, 3 }, { 2, 2, 7 }, { 0, 2, 7 }, { 1, 1, 3 }, { 2, 2, 7 }, { 0, 2, 7 }, { 3, 3, 6 }, { 2, 2, 6 }, { 1, 1, 7 }, { 3, 1, 7 }, { 0, 0, 3 }, { 1, 1, 7 }, { 3, 1, 7 }, { 0, 0, 3 }, { 1, 1, 7 }, { 3, 1, 7 } }
Definition at line 1138 of file vehicle.cpp.
EffectInitProc* const _effect_init_procs[] [static] |
Initial value:
{ ChimneySmokeInit, SteamSmokeInit, DieselSmokeInit, ElectricSparkInit, SmokeInit, ExplosionLargeInit, BreakdownSmokeInit, ExplosionSmallInit, BulldozerInit, BubbleInit, }
Definition at line 1426 of file vehicle.cpp.
EffectTickProc* const _effect_tick_procs[] [static] |
Initial value:
{ ChimneySmokeTick, SteamSmokeTick, DieselSmokeTick, ElectricSparkTick, SmokeTick, ExplosionLargeTick, BreakdownSmokeTick, ExplosionSmallTick, BulldozerTick, BubbleTick, }
Definition at line 1439 of file vehicle.cpp.
const Direction _new_direction_table[] [static] |
const uint32 _send_to_depot_proc_table[] |
Initial value:
{ CMD_SEND_TRAIN_TO_DEPOT, CMD_SEND_ROADVEH_TO_DEPOT, CMD_SEND_SHIP_TO_DEPOT, CMD_SEND_AIRCRAFT_TO_HANGAR, }
Definition at line 85 of file vehicle.cpp.
const uint32 _veh_build_proc_table[] |
Initial value:
Definition at line 65 of file vehicle.cpp.
const ChunkHandler _veh_chunk_handlers[] |
const uint32 _veh_refit_proc_table[] |
Initial value:
Definition at line 78 of file vehicle.cpp.
const uint32 _veh_sell_proc_table[] |
Initial value:
Definition at line 71 of file vehicle.cpp.
const StringID _vehicle_type_names[4] [static] |
Initial value:
{ STR_019F_TRAIN, STR_019C_ROAD_VEHICLE, STR_019E_SHIP, STR_019D_AIRCRAFT, }
Definition at line 1593 of file vehicle.cpp.