OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef VEHICLE_FUNC_H
11 #define VEHICLE_FUNC_H
23 #define is_custom_sprite(x) (x >= 0xFD)
24 #define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
25 #define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
36 template <VehicleType T>
42 uint CountVehiclesInChain(
const Vehicle *v);
47 void CallVehicleTicks();
53 void ResetVehicleHash();
54 void ResetVehicleColourMap();
64 void CheckVehicleBreakdown(
Vehicle *v);
98 default:
return false;
118 extern const uint32 _veh_build_proc_table[];
119 extern const uint32 _veh_sell_proc_table[];
120 extern const uint32 _veh_refit_proc_table[];
121 extern const uint32 _send_to_depot_proc_table[];
124 static inline uint32 GetCmdBuildVeh(
VehicleType type)
126 return _veh_build_proc_table[type];
129 static inline uint32 GetCmdBuildVeh(
const BaseVehicle *v)
131 return GetCmdBuildVeh(v->
type);
134 static inline uint32 GetCmdSellVeh(
VehicleType type)
136 return _veh_sell_proc_table[type];
139 static inline uint32 GetCmdSellVeh(
const BaseVehicle *v)
141 return GetCmdSellVeh(v->
type);
144 static inline uint32 GetCmdRefitVeh(
VehicleType type)
146 return _veh_refit_proc_table[type];
149 static inline uint32 GetCmdRefitVeh(
const BaseVehicle *v)
151 return GetCmdRefitVeh(v->
type);
154 static inline uint32 GetCmdSendToDepot(
VehicleType type)
156 return _send_to_depot_proc_table[type];
159 static inline uint32 GetCmdSendToDepot(
const BaseVehicle *v)
161 return GetCmdSendToDepot(v->
type);
176 typedef std::vector<VehicleID> VehicleSet;
@ VEH_AIRCRAFT
Aircraft vehicle type.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
uint32 TileIndex
The index/ID of a Tile.
void ViewportAddVehicles(DrawPixelInfo *dpi)
Add the vehicle sprites that should be drawn at a part of the screen.
Direction
Defines the 8 directions on the map.
SpriteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
uint16 UnitID
Type for the company global vehicle unit number.
bool IsValidImageIndex(uint8 image_index)
Helper to check whether an image index is valid for a particular vehicle.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
SpriteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
@ VEH_ROAD
Road vehicle type.
Owner
Enum for all companies/owners.
GRFBugs
Encountered GRF bugs.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore=nullptr)
Finds vehicle in tunnel / bridge.
uint16 EngineID
Unique identification number of an engine.
void CheckCargoCapacity(Vehicle *v)
Check the capacity of all vehicles in a chain and spread cargo if needed.
Common return value for all commands.
const struct Livery * GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting)
Determines the livery for a vehicle.
UnitID GetFreeUnitNumber(VehicleType type)
Get an unused unit number for a vehicle (if allowed).
TileIndex new_tile
Tile of the vehicle after moving.
byte VehicleRandomBits()
Get a value for a vehicle's random_bits.
void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
VehicleType
Available vehicle types.
bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle in on a specific location.
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.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void VehicleEnteredDepotThisTick(Vehicle *v)
Adds a vehicle to the list of vehicles that visited a depot this tick.
void VehicleServiceInDepot(Vehicle *v)
Service a vehicle and all subsequent vehicles in the consist.
Position information of a vehicle after it moved.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
static const int DAYS_IN_YEAR
days per year
TileIndex old_tile
Current tile of the vehicle.
void VehicleLengthChanged(const Vehicle *u)
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
uint32 VehicleID
The type all our vehicle IDs have.
TrackBits
Bitfield corresponding to Track.
byte CargoID
Cargo slots to indicate a cargo type within a game.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing.
uint _returned_refit_capacity
Stores the capacity after a refit operation.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
LiveryScheme
List of different livery schemes.
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype=0)
Check whether we can build infrastructure for the given vehicle type.
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
@ VEH_TRAIN
Train vehicle type.
VehicleType type
Type of vehicle.
void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
Notify disasters that we are about to delete a vehicle.
void DecreaseVehicleValue(Vehicle *v)
Decrease the value of a vehicle.
uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
Calculates how full a vehicle is.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
Determines the LiveryScheme for a vehicle.
int y
x and y position of the vehicle after moving
@ VEH_SHIP
Ship vehicle type.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
Information about a particular livery.
byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
Data about how and where to blit pixels.
static const int VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.