32static inline bool IsCustomVehicleSpriteNum(uint8_t spritenum)
46template <VehicleType T>
61 using difference_type = std::ptrdiff_t;
62 using iterator_category = std::forward_iterator_tag;
64 using reference = void;
68 bool operator==(
const Iterator &rhs)
const {
return this->current == rhs.current; }
69 bool operator==(
const std::default_sentinel_t &)
const {
return this->current ==
nullptr; }
71 Vehicle *operator*()
const {
return this->current; }
95 Iterator begin()
const {
return this->start; }
96 std::default_sentinel_t end()
const {
return std::default_sentinel_t(); }
105template <
class UnaryPred>
109 if (predicate(v))
return true;
127 using difference_type = std::ptrdiff_t;
128 using iterator_category = std::forward_iterator_tag;
129 using pointer = void;
130 using reference = void;
132 explicit Iterator(int32_t x, int32_t y, uint max_dist);
134 bool operator==(
const Iterator &rhs)
const {
return this->current_veh == rhs.current_veh; }
135 bool operator==(
const std::default_sentinel_t &)
const {
return this->current_veh ==
nullptr; }
137 Vehicle *operator*()
const {
return this->current_veh; }
154 uint hxmin, hxmax, hymin, hymax;
163 explicit VehiclesNearTileXY(int32_t x, int32_t y, uint max_dist) : start(x, y, max_dist) {}
164 Iterator begin()
const {
return this->start; }
165 std::default_sentinel_t end()
const {
return std::default_sentinel_t(); }
175template <
class UnaryPred>
179 if (predicate(v))
return true;
185uint CountVehiclesInChain(
const Vehicle *v);
186void CallVehicleTicks();
191void ResetVehicleHash();
192void ResetVehicleColourMap();
202void CheckVehicleBreakdown(
Vehicle *v);
249extern const StringID _veh_build_msg_table[];
250extern const StringID _veh_sell_msg_table[];
251extern const StringID _veh_sell_all_msg_table[];
252extern const StringID _veh_autoreplace_msg_table[];
253extern const StringID _veh_refit_msg_table[];
254extern const StringID _send_to_depot_msg_table[];
259 return _veh_build_msg_table[type];
264 return GetCmdBuildVehMsg(v->
type);
269 return _veh_sell_msg_table[type];
274 return GetCmdSellVehMsg(v->
type);
279 return _veh_sell_all_msg_table[type];
284 return _veh_autoreplace_msg_table[type];
289 return _veh_refit_msg_table[type];
294 return GetCmdRefitVehMsg(v->
type);
299 return _send_to_depot_msg_table[type];
304 return GetCmdSendToDepotMsg(v->
type);
316typedef std::vector<VehicleID> VehicleSet;
uint8_t CargoType
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
void SkipEmptyBuckets()
Advance the internal state until we reach a non-empty bucket, or the end.
void Increment()
Advance the internal state to the next potential vehicle.
void SkipFalseMatches()
Advance the internal state until it reaches a vehicle within the search area.
Iterate over all vehicles near a given world coordinate.
void Increment()
Advance the internal state to the next potential vehicle.
void SkipFalseMatches()
Advance the internal state until it reaches a vehicle on the correct tile or the end.
Iterate over all vehicles on a tile.
Types related to commands.
Different types to 'show' directions.
Direction
Defines the 8 directions on the map.
Types related to engines.
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.
GRFBug
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.
Specification of a rectangle with absolute coordinates of all edges.
Templated helper to make a type-safe 'typedef' representing a single POD value.
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?
void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBug bug_type, bool critical)
Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking.
bool HasVehicleNearTileXY(int32_t x, int32_t y, uint max_dist, UnaryPred &&predicate)
Loop over vehicles near a given world coordinate, and check whether a predicate is true for any of th...
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.
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.
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.
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.
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
Determines the LiveryScheme for a vehicle.
uint8_t GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoType dest_cargo_type)
Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
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.
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.
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.
CustomVehicleSpriteNum
Special values for Vehicle::spritenum and (Aircraft|Rail|Road|Ship)VehicleInfo::image_index.
@ CUSTOM_VEHICLE_SPRITENUM
Vehicle sprite from NewGRF.
@ CUSTOM_VEHICLE_SPRITENUM_REVERSED
Vehicle sprite from NewGRF with reverse driving direction (from articulation callback)
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.
bool HasVehicleOnTile(TileIndex tile, UnaryPred &&predicate)
Loop over vehicles on a tile, and check whether a predicate is true for any of them.
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
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.