12 #ifndef VEHICLE_FUNC_H 13 #define VEHICLE_FUNC_H 25 #define is_custom_sprite(x) (x >= 0xFD) 26 #define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD) 27 #define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE) 38 template <VehicleType T>
44 uint CountVehiclesInChain(
const Vehicle *v);
49 void CallVehicleTicks();
55 void ResetVehicleHash();
56 void ResetVehicleColourMap();
66 void CheckVehicleBreakdown(
Vehicle *v);
100 default:
return false;
120 extern const uint32 _veh_build_proc_table[];
121 extern const uint32 _veh_sell_proc_table[];
122 extern const uint32 _veh_refit_proc_table[];
123 extern const uint32 _send_to_depot_proc_table[];
126 static inline uint32 GetCmdBuildVeh(
VehicleType type)
128 return _veh_build_proc_table[type];
131 static inline uint32 GetCmdBuildVeh(
const BaseVehicle *v)
133 return GetCmdBuildVeh(v->
type);
136 static inline uint32 GetCmdSellVeh(
VehicleType type)
138 return _veh_sell_proc_table[type];
141 static inline uint32 GetCmdSellVeh(
const BaseVehicle *v)
143 return GetCmdSellVeh(v->
type);
146 static inline uint32 GetCmdRefitVeh(
VehicleType type)
148 return _veh_refit_proc_table[type];
151 static inline uint32 GetCmdRefitVeh(
const BaseVehicle *v)
153 return GetCmdRefitVeh(v->
type);
156 static inline uint32 GetCmdSendToDepot(
VehicleType type)
158 return _send_to_depot_proc_table[type];
161 static inline uint32 GetCmdSendToDepot(
const BaseVehicle *v)
163 return GetCmdSendToDepot(v->
type);
All types related to tracks.
void CheckCargoCapacity(Vehicle *v)
Check the capacity of all vehicles in a chain and spread cargo if needed.
Different types to 'show' directions.
static const int DAYS_IN_YEAR
days per year
Data about how and where to blit pixels.
static const int VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
LiveryScheme
List of different livery schemes.
uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
Calculates how full a vehicle is.
bool IsValidImageIndex(uint8 image_index)
Helper to check whether an image index is valid for a particular vehicle.
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.
Types related to engines.
Base types related to transport.
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 FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
SpriteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
Simple vector template class.
Common return value for all commands.
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.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing...
Direction
Defines the 8 directions on the map.
Types related to commands.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore=NULL)
Finds vehicle in tunnel / bridge.
TrackBits
Bitfield corresponding to Track.
void VehicleServiceInDepot(Vehicle *v)
Service a vehicle and all subsequent vehicles in the consist.
int y
x and y position of the vehicle after moving
byte VehicleRandomBits()
Get a value for a vehicle's random_bits.
VehicleType
Available vehicle types.
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
Determines the LiveryScheme for a vehicle.
uint32 VehicleID
The type all our vehicle IDs have.
SpriteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
Information about a particular livery.
void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
void VehicleLengthChanged(const Vehicle *u)
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
GRFBugs
Encountered GRF bugs.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
UnitID GetFreeUnitNumber(VehicleType type)
Get an unused unit number for a vehicle (if allowed).
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool CanBuildVehicleInfrastructure(VehicleType type)
Check whether we can build infrastructure for the given vehicle type.
Functions to find and configure NewGRFs.
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
TileIndex old_tile
Current tile of the vehicle.
void DecreaseVehicleValue(Vehicle *v)
Decrease the value of a vehicle.
Functions/types related to livery colours.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
void ViewportAddVehicles(DrawPixelInfo *dpi)
Add the vehicle sprites that should be drawn at a part of the screen.
uint16 EngineID
Unique identification number of an engine.
uint32 TileIndex
The index/ID of a Tile.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
Position information of a vehicle after it moved.
Types related to vehicles.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
uint16 _returned_refit_capacity
Stores the capacity after a refit operation.
uint16 UnitID
Type for the company global vehicle unit number.
void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
Notify disasters that we are about to delete a vehicle.
byte CargoID
Cargo slots to indicate a cargo type within a game.
bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle in on a specific location.
void VehicleEnteredDepotThisTick(Vehicle *v)
Adds a vehicle to the list of vehicles that visited a depot this tick.
Owner
Enum for all companies/owners.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
TileIndex new_tile
Tile of the vehicle after moving.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
VehicleTypeByte type
Type of vehicle.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it...
Types related to the graphics and/or input devices.