10 #ifndef VEHICLE_FUNC_H
11 #define VEHICLE_FUNC_H
24 #define is_custom_sprite(x) (x >= 0xFD)
25 #define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
26 #define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
37 template <VehicleType T>
43 uint CountVehiclesInChain(
const Vehicle *v);
48 void CallVehicleTicks();
53 void ResetVehicleHash();
54 void ResetVehicleColourMap();
64 void CheckVehicleBreakdown(
Vehicle *v);
112 extern const StringID _veh_build_msg_table[];
113 extern const StringID _veh_sell_msg_table[];
114 extern const StringID _veh_refit_msg_table[];
115 extern const StringID _send_to_depot_msg_table[];
120 return _veh_build_msg_table[type];
125 return GetCmdBuildVehMsg(v->
type);
130 return _veh_sell_msg_table[type];
135 return GetCmdSellVehMsg(v->
type);
140 return _veh_refit_msg_table[type];
145 return GetCmdRefitVehMsg(v->
type);
150 return _send_to_depot_msg_table[type];
155 return GetCmdSendToDepotMsg(v->
type);
167 typedef std::vector<VehicleID> VehicleSet;
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Common return value for all commands.
static constexpr int DAYS_IN_YEAR
days per year
Types related to commands.
Owner
Enum for all companies/owners.
Different types to 'show' directions.
Direction
Defines the 8 directions on the map.
Types related to engines.
uint16_t EngineID
Unique identification number of an engine.
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Functions/types related to livery colours.
LiveryScheme
List of different livery schemes.
Functions to find and configure NewGRFs.
GRFBugs
Encountered GRF bugs.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
VehicleType type
Type of vehicle.
Data about how and where to blit pixels.
Position information of a vehicle after it moved.
TileIndex new_tile
Tile of the vehicle after moving.
int y
x and y position of the vehicle after moving
TileIndex old_tile
Current tile of the vehicle.
Information about a particular livery.
Definition of the game-economy-timer.
All types related to tracks.
TrackBits
Allow incrementing of Track variables.
Base types related to transport.
uint16_t UnitID
Type for the company global vehicle unit number.
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.
bool IsUniqueVehicleName(const std::string &name)
Test if a name is unique among vehicle names.
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicle chains have the same list of engines.
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
SpriteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
const struct Livery * GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, uint8_t livery_setting)
Determines the livery for a vehicle.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
static const TimerGameEconomy::Date VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8_t num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle in on a specific location.
void CheckCargoCapacity(Vehicle *v)
Check the capacity of all vehicles in a chain and spread cargo if needed.
UnitID GetFreeUnitNumber(VehicleType type)
Get an unused unit number for a vehicle (if allowed).
void RunVehicleCalendarDayProc()
Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.
void VehicleLengthChanged(const Vehicle *u)
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
bool IsValidImageIndex(uint8_t image_index)
Helper to check whether an image index is valid for a particular vehicle.
uint8_t 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 VehicleServiceInDepot(Vehicle *v)
Service a vehicle and all subsequent vehicles in the consist.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
Determines the LiveryScheme for a vehicle.
void ViewportAddVehicles(DrawPixelInfo *dpi)
Add the vehicle sprites that should be drawn at a part of the screen.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing.
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
Get reason string why this station can't be used by the given vehicle.
void ReleaseDisasterVehicle(VehicleID vehicle)
Notify disasters that we are about to delete a vehicle.
void DecreaseVehicleValue(Vehicle *v)
Decrease the value of a vehicle.
void EconomyAgeVehicle(Vehicle *v)
Update economy age of a vehicle.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore=nullptr)
Finds vehicle in tunnel / bridge.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype=0)
Check whether we can build infrastructure for the given vehicle type.
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.
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
void VehicleEnteredDepotThisTick(Vehicle *v)
Adds a vehicle to the list of vehicles that visited a depot this tick.
SpriteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
uint8_t CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
Calculates how full a vehicle is.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Types related to vehicles.
VehicleType
Available vehicle types.
@ VEH_COMPANY_END
Last company-ownable type.
uint32_t VehicleID
The type all our vehicle IDs have.