OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
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);
100 default:
return false;
120 extern const StringID _veh_build_msg_table[];
121 extern const StringID _veh_sell_msg_table[];
122 extern const StringID _veh_refit_msg_table[];
123 extern const StringID _send_to_depot_msg_table[];
128 return _veh_build_msg_table[type];
133 return GetCmdBuildVehMsg(v->
type);
138 return _veh_sell_msg_table[type];
143 return GetCmdSellVehMsg(v->
type);
148 return _veh_refit_msg_table[type];
153 return GetCmdRefitVehMsg(v->
type);
158 return _send_to_depot_msg_table[type];
163 return GetCmdSendToDepotMsg(v->
type);
175 typedef std::vector<VehicleID> VehicleSet;
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.
uint16_t UnitID
Type for the company global vehicle unit number.
void ViewportAddVehicles(DrawPixelInfo *dpi)
Add the vehicle sprites that should be drawn at a part of the screen.
SpriteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype=0)
Check whether we can build infrastructure for the given vehicle type.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8_t num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
Owner
Enum for all companies/owners.
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicle chains have the same list of engines.
@ VEH_TRAIN
Train vehicle type.
bool IsValidImageIndex(uint8_t 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.
@ VEH_ROAD
Road vehicle type.
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.
GRFBugs
Encountered GRF bugs.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore=nullptr)
Finds vehicle in tunnel / bridge.
void RunVehicleCalendarDayProc()
Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.
void CheckCargoCapacity(Vehicle *v)
Check the capacity of all vehicles in a chain and spread cargo if needed.
Common return value for all commands.
TrackBits
Allow incrementing of Track variables.
LiveryScheme
List of different livery schemes.
@ VEH_SHIP
Ship vehicle type.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
UnitID GetFreeUnitNumber(VehicleType type)
Get an unused unit number for a vehicle (if allowed).
TileIndex new_tile
Tile of the vehicle after moving.
StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
Get reason string why this station can't be used by the given vehicle.
uint32_t VehicleID
The type all our vehicle IDs have.
void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
void ReleaseDisasterVehicle(VehicleID vehicle)
Notify disasters that we are about to delete a vehicle.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
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.
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.
void EconomyAgeVehicle(Vehicle *v)
Update economy age of a vehicle.
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.
uint8_t CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
Calculates how full a vehicle is.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Direction
Defines the 8 directions on the map.
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.
VehicleType
Available vehicle types.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing.
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
@ VEH_AIRCRAFT
Aircraft vehicle type.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
uint16_t EngineID
Unique identification number of an engine.
VehicleType type
Type of vehicle.
void DecreaseVehicleValue(Vehicle *v)
Decrease the value of a vehicle.
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
bool IsUniqueVehicleName(const std::string &name)
Test if a name is unique among vehicle names.
static constexpr int DAYS_IN_YEAR
days per year
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
Information about a particular livery.
static const TimerGameEconomy::Date VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
Data about how and where to blit pixels.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.