|
OpenTTD Source 20260311-master-g511d3794ce
|
Functions related to vehicles. More...
#include "gfx_type.h"#include "direction_type.h"#include "timer/timer_game_economy.h"#include "command_type.h"#include "vehicle_type.h"#include "engine_type.h"#include "transport_type.h"#include "newgrf_config.h"#include "track_type.h"#include "livery.h"Go to the source code of this file.
Data Structures | |
| class | VehiclesOnTile |
| Iterate over all vehicles on a tile. More... | |
| class | VehiclesOnTile::Iterator |
| Forward iterator. More... | |
| class | VehiclesNearTileXY |
| Iterate over all vehicles near a given world coordinate. More... | |
| class | VehiclesNearTileXY::Iterator |
| Forward iterator. More... | |
| struct | GetNewVehiclePosResult |
| Position information of a vehicle after it moved. More... | |
Typedefs | |
| typedef std::vector< VehicleID > | VehicleSet |
Enumerations | |
| enum | CustomVehicleSpriteNum { CUSTOM_VEHICLE_SPRITENUM = 0xFD , CUSTOM_VEHICLE_SPRITENUM_REVERSED = 0xFE } |
| Special values for Vehicle::spritenum and (Aircraft|Rail|Road|Ship)VehicleInfo::image_index. More... | |
Functions | |
| static bool | IsCustomVehicleSpriteNum (uint8_t spritenum) |
| template<VehicleType T> | |
| bool | IsValidImageIndex (uint8_t image_index) |
| Helper to check whether an image index is valid for a particular vehicle. | |
| template<class UnaryPred> | |
| bool | HasVehicleOnTile (TileIndex tile, UnaryPred &&predicate) |
| Loop over vehicles on a tile, and check whether a predicate is true for any of them. | |
| template<class UnaryPred> | |
| 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 them. | |
| void | VehicleServiceInDepot (Vehicle *v) |
| Service a vehicle and all subsequent vehicles in the consist. | |
| uint | CountVehiclesInChain (const Vehicle *v) |
| void | CallVehicleTicks () |
| uint8_t | CalcPercentVehicleFilled (const Vehicle *v, StringID *colour) |
| Calculates how full a vehicle is. | |
| void | VehicleLengthChanged (const Vehicle *u) |
| Logs a bug in GRF and shows a warning message if this is for the first time this happened. | |
| void | ResetVehicleHash () |
| void | ResetVehicleColourMap () |
| 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. | |
| 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. | |
| CommandCost | TunnelBridgeIsFree (TileIndex tile, TileIndex endtile, const Vehicle *ignore=nullptr) |
| Finds vehicle in tunnel / bridge. | |
| void | DecreaseVehicleValue (Vehicle *v) |
| Decrease the value of a vehicle. | |
| void | CheckVehicleBreakdown (Vehicle *v) |
| Periodic check for a vehicle to maybe break down. | |
| void | EconomyAgeVehicle (Vehicle *v) |
| Update economy age of a vehicle. | |
| void | AgeVehicle (Vehicle *v) |
| Update age of a vehicle. | |
| void | RunVehicleCalendarDayProc () |
| Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract. | |
| UnitID | GetFreeUnitNumber (VehicleType type) |
| Get an unused unit number for a vehicle (if allowed). | |
| void | VehicleEnterDepot (Vehicle *v) |
| Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc. | |
| bool | CanBuildVehicleInfrastructure (VehicleType type, uint8_t subtype=0) |
| Check whether we can build infrastructure for the given vehicle type. | |
| GetNewVehiclePosResult | GetNewVehiclePos (const Vehicle *v) |
| Get position information of a vehicle when moving one pixel in the direction it is facing. | |
| Direction | GetDirectionTowards (const Vehicle *v, int x, int y) |
| bool | IsCompanyBuildableVehicleType (VehicleType type) |
| Is the given vehicle type buildable by a company? | |
| bool | IsCompanyBuildableVehicleType (const BaseVehicle *v) |
| Is the given vehicle buildable by a company? | |
| LiveryScheme | GetEngineLiveryScheme (EngineID engine_type, EngineID parent_engine_type, const Vehicle *v) |
| Determines the LiveryScheme for 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. | |
| SpriteID | GetEnginePalette (EngineID engine_type, CompanyID company) |
| Get the colour map for an engine. | |
| SpriteID | GetVehiclePalette (const Vehicle *v) |
| Get the colour map for a vehicle. | |
| StringID | GetCmdBuildVehMsg (VehicleType type) |
| StringID | GetCmdBuildVehMsg (const BaseVehicle *v) |
| StringID | GetCmdSellVehMsg (VehicleType type) |
| StringID | GetCmdSellVehMsg (const BaseVehicle *v) |
| StringID | GetCmdSellAllVehMsg (VehicleType type) |
| StringID | GetCmdAutoreplaceVehMsg (VehicleType type) |
| StringID | GetCmdRefitVehMsg (VehicleType type) |
| StringID | GetCmdRefitVehMsg (const BaseVehicle *v) |
| StringID | GetCmdSendToDepotMsg (VehicleType type) |
| StringID | GetCmdSendToDepotMsg (const BaseVehicle *v) |
| CommandCost | EnsureNoVehicleOnGround (TileIndex tile) |
| Ensure there is no vehicle at the ground at the given position. | |
| CommandCost | EnsureNoTrainOnTrackBits (TileIndex tile, TrackBits track_bits) |
| Tests if a vehicle interacts with the specified track bits. | |
| bool | CanVehicleUseStation (EngineID engine_type, const struct Station *st) |
| bool | CanVehicleUseStation (const Vehicle *v, const struct Station *st) |
| 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 | 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. | |
| 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. | |
| bool | IsUniqueVehicleName (const std::string &name) |
| Test if a name is unique among vehicle names. | |
Variables | |
| static const TimerGameEconomy::Date | VEHICLE_PROFIT_MIN_AGE {CalendarTime::DAYS_IN_YEAR * 2} |
| Only vehicles older than this have a meaningful profit. | |
| static const Money | VEHICLE_PROFIT_THRESHOLD = 10000 |
| Threshold for a vehicle to be considered making good profit. | |
| const StringID | _veh_build_msg_table [] |
| When can't buy such vehicle. | |
| const StringID | _veh_sell_msg_table [] |
| When can't sell such vehicle. | |
| const StringID | _veh_sell_all_msg_table [] |
| When can't sell all vehicles in depot. | |
| const StringID | _veh_autoreplace_msg_table [] |
| When can't autoreplace such vehicle. | |
| const StringID | _veh_refit_msg_table [] |
| When can't refit such vehicle. | |
| const StringID | _send_to_depot_msg_table [] |
| When can't send to depot such vehicle. | |
Functions related to vehicles.
Definition in file vehicle_func.h.
| typedef std::vector<VehicleID> VehicleSet |
Definition at line 324 of file vehicle_func.h.
Special values for Vehicle::spritenum and (Aircraft|Rail|Road|Ship)VehicleInfo::image_index.
| Enumerator | |
|---|---|
| CUSTOM_VEHICLE_SPRITENUM | Vehicle sprite from NewGRF. |
| CUSTOM_VEHICLE_SPRITENUM_REVERSED | Vehicle sprite from NewGRF with reverse driving direction (from articulation callback). |
Definition at line 27 of file vehicle_func.h.
| void AgeVehicle | ( | Vehicle * | v | ) |
Update age of a vehicle.
| v | Vehicle to update. |
Definition at line 1454 of file vehicle.cpp.
References _local_company, _settings_client, AddVehicleAdviceNewsItem(), Vehicle::age, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Engine::company_avail, TimerGame< struct Calendar >::DateAtStartOfYear(), TimerGameConst< struct Calendar >::DAYS_IN_LEAP_YEAR, CompanySettings::engine_renew, Vehicle::engine_type, EngineHasReplacementForCompany(), SpecializedVehicle< Train, Type >::From(), GetEncodedString(), Vehicle::GetEngine(), Vehicle::group_id, Vehicle::IsPrimaryVehicle(), Vehicle::max_age, TimerGameConst< struct Calendar >::MAX_DATE, Vehicle::owner, Vehicle::Previous(), Vehicle::reliability_spd_dec, CompanyProperties::settings, SetWindowDirty(), BaseVehicle::type, VEH_TRAIN, VehicleOld, Vehicle::vehstatus, and WC_VEHICLE_DETAILS.
Referenced by Aircraft::OnNewCalendarDay(), RoadVehicle::OnNewCalendarDay(), Ship::OnNewCalendarDay(), and Train::OnNewCalendarDay().
Calculates how full a vehicle is.
| front | The front vehicle of the consist to check. |
| colour | The string to show depending on if we are unloading or loading |
Definition at line 1505 of file vehicle.cpp.
References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoUnloading, CeilDiv(), Vehicle::current_order, SpecializedStation< Station, false >::GetIfValid(), Order::GetLoadType(), Station::goods, Order::IsFullLoadOrder(), Order::IsType(), Vehicle::last_station_visited, LoadingFinished, Vehicle::Next(), NoLoad, StopLoading, VehicleCargoList::StoredCount(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and BaseConsist::vehicle_flags.
Referenced by AfterLoadVehiclesPhase2(), Vehicle::LeaveStation(), LoadUnloadVehicle(), and ProcessConditionalOrder().
| void CallVehicleTicks | ( | ) |
Definition at line 983 of file vehicle.cpp.
| bool CanBuildVehicleInfrastructure | ( | VehicleType | type, |
| uint8_t | subtype ) |
Check whether we can build infrastructure for the given vehicle type.
This to disable building stations etc. when you are not allowed/able to have the vehicle type yet.
| type | the vehicle type to check this for |
| subtype | The vehicle's sub to to check this for. |
Definition at line 1944 of file vehicle.cpp.
References _local_company, _settings_game, SpecializedVehicle< RoadVehicle, Type >::From(), HasAnyRailTypesAvail(), HasAnyRoadTypesAvail(), IsCompanyBuildableVehicleType(), Engine::IterateType(), Vehicle::owner, RoadVehicleInfo::roadtype, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by BuildAirToolbarWindow::OnInvalidateData(), BuildDocksToolbarWindow::OnInvalidateData(), BuildRailToolbarWindow::OnInvalidateData(), BuildRoadToolbarWindow::OnInvalidateData(), and BuildRailToolbarWindow::OnTooltip().
| void CheckCargoCapacity | ( | Vehicle * | v | ) |
Check the capacity of all vehicles in a chain and spread cargo if needed.
| v | The vehicle to check. |
Definition at line 107 of file autoreplace_cmd.cpp.
References Vehicle::First(), CargoList< VehicleCargoList, CargoPacketList >::MTA_KEEP, and Vehicle::Next().
Referenced by CmdMoveRailVehicle(), and ReplaceChain().
| void CheckVehicleBreakdown | ( | Vehicle * | v | ) |
Periodic check for a vehicle to maybe break down.
| v | The vehicle to consider breaking. |
Definition at line 1320 of file vehicle.cpp.
References _settings_game, Vehicle::breakdown_chance, Vehicle::breakdown_ctr, Vehicle::breakdown_delay, Chance16I(), ClampTo(), Vehicle::cur_speed, Vehicle::current_order, GB(), Order::IsType(), Vehicle::reliability, Vehicle::reliability_spd_dec, SetWindowDirty(), Stopped, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), BaseVehicle::type, VEH_SHIP, Vehicle::vehstatus, and WC_VEHICLE_DETAILS.
Referenced by Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), and Train::OnNewEconomyDay().
| uint CountVehiclesInChain | ( | const Vehicle * | v | ) |
Definition at line 703 of file vehicle.cpp.
| void DecreaseVehicleValue | ( | Vehicle * | v | ) |
Decrease the value of a vehicle.
| v | Vehicle to devaluate. |
Definition at line 1299 of file vehicle.cpp.
References SetWindowDirty(), Vehicle::value, and WC_VEHICLE_DETAILS.
Referenced by Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), and Train::OnNewEconomyDay().
| void EconomyAgeVehicle | ( | Vehicle * | v | ) |
Update economy age of a vehicle.
| v | Vehicle to update. |
Definition at line 1442 of file vehicle.cpp.
References Vehicle::economy_age, Vehicle::IsPrimaryVehicle(), TimerGameConst< struct Economy >::MAX_DATE, VEHICLE_PROFIT_MIN_AGE, and GroupStatistics::VehicleReachedMinAge().
Referenced by Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), and Train::OnNewEconomyDay().
| CommandCost EnsureNoTrainOnTrackBits | ( | TileIndex | tile, |
| TrackBits | track_bits ) |
Tests if a vehicle interacts with the specified track bits.
All track bits interact except parallel TRACK_BIT_HORZ or TRACK_BIT_VERT.
| tile | The tile. |
| track_bits | The track bits. |
true if no train that interacts, is found. false if a train is found. Definition at line 604 of file vehicle.cpp.
References SpecializedVehicle< Train, Type >::From(), Train::track, TracksOverlap(), and VEH_TRAIN.
Referenced by CmdConvertRail(), EnsureNoTrainOnTrack(), and ExploreSegment().
| CommandCost EnsureNoVehicleOnGround | ( | TileIndex | tile | ) |
Ensure there is no vehicle at the ground at the given position.
| tile | Position to examine. |
Definition at line 556 of file vehicle.cpp.
References AIR_SHADOW, GetTileMaxPixelZ(), VEH_AIRCRAFT, and VEH_DISASTER.
Referenced by CheckBuildableTile(), CheckIfIndustryTilesAreFree(), ClearTile_Rail(), ClearTile_Water(), CmdBuildObject(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdConvertRail(), CmdConvertRoad(), CmdRemoveSingleRail(), DoBuildLock(), IsValidTileForWaypoint(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRoad(), RemoveRoadStop(), RemoveRoadWaypointStop(), and TileLoop_Road().
Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
All articulated parts of both vehicles are tested to find a possibly shared subtype. For v_for only vehicle refittable to dest_cargo_type are considered.
| v_from | the vehicle to match the subtype from |
| v_for | the vehicle to get the subtype for |
| dest_cargo_type | Destination cargo type. |
Definition at line 607 of file vehicle_gui.cpp.
References EngineInfo::callback_mask, Engine::CanCarryCargo(), CargoSuffix, GetCargoSubtypeText(), Vehicle::GetEngine(), Vehicle::GetFirstEnginePart(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), HasBit(), include(), MAX_REFIT_CYCLE, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by BuildReplacementVehicle(), CmdCloneVehicle(), LinkRefresher::HandleRefit(), and RefitVehicle().
|
inline |
Definition at line 290 of file vehicle_func.h.
|
inline |
Definition at line 270 of file vehicle_func.h.
|
inline |
Definition at line 265 of file vehicle_func.h.
|
inline |
Definition at line 300 of file vehicle_func.h.
|
inline |
Definition at line 295 of file vehicle_func.h.
|
inline |
Definition at line 285 of file vehicle_func.h.
|
inline |
Definition at line 280 of file vehicle_func.h.
|
inline |
Definition at line 275 of file vehicle_func.h.
|
inline |
Definition at line 310 of file vehicle_func.h.
|
inline |
Definition at line 305 of file vehicle_func.h.
Definition at line 1829 of file vehicle.cpp.
| 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.
| engine_type | EngineID of the vehicle |
| company | Owner of the vehicle |
| parent_engine_type | EngineID of the front vehicle. VehicleID::Invalid() if vehicle is at front itself. |
| v | the vehicle. nullptr if in purchase list etc. |
| livery_setting | The livery settings to use for acquiring the livery information. |
Definition at line 2086 of file vehicle.cpp.
References _local_company, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Vehicle::First(), GetEngineLiveryScheme(), Vehicle::group_id, Livery::in_use, LIT_ALL, LIT_COMPANY, Group::livery, and Group::parent.
Referenced by LiveryHelper().
| LiveryScheme GetEngineLiveryScheme | ( | EngineID | engine_type, |
| EngineID | parent_engine_type, | ||
| const Vehicle * | v ) |
Determines the LiveryScheme for a vehicle.
| engine_type | Engine of the vehicle. |
| parent_engine_type | Engine of the front vehicle, EngineID::Invalid() if vehicle is at front itself. |
| v | the vehicle, nullptr if in purchase list etc. |
Definition at line 1992 of file vehicle.cpp.
References AIR_CTOL, Vehicle::cargo_type, EC_DIESEL, EC_ELECTRIC, EC_MAGLEV, EC_MONORAIL, EC_STEAM, RailVehicleInfo::engclass, Vehicle::First(), CargoSpec::Get(), Engine::GetDefaultCargoType(), Vehicle::IsArticulatedPart(), IsCargoInClass(), IsValidCargoType(), EngineInfo::misc_flags, Passengers, RailIsMU, RAILVEH_WAGON, RoadIsTram, AircraftVehicleInfo::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Engine::type, UsesWagonOverride(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by FinaliseEngineArray(), and GetEngineLivery().
Get the colour map for an engine.
This used for unbuilt engines in the user interface.
| engine_type | ID of engine |
| company | ID of company |
Definition at line 2164 of file vehicle.cpp.
Referenced by DrawEngineList(), EnginePreviewWindow::DrawWidget(), and NewsWindow::DrawWidget().
| UnitID GetFreeUnitNumber | ( | VehicleType | type | ) |
Get an unused unit number for a vehicle (if allowed).
| type | Type of vehicle |
UINT16_MAX. Definition at line 1916 of file vehicle.cpp.
References _current_company, _settings_game, Company::group_all, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CheckNewTrain(), CmdBuildVehicle(), and NormaliseTrainHead().
| GetNewVehiclePosResult GetNewVehiclePos | ( | const Vehicle * | v | ) |
Get position information of a vehicle when moving one pixel in the direction it is facing.
| v | Vehicle to move |
Definition at line 1805 of file vehicle.cpp.
References Vehicle::direction, GetNewVehiclePosResult::new_tile, GetNewVehiclePosResult::old_tile, Vehicle::tile, TileVirtXY(), Vehicle::x_pos, GetNewVehiclePosResult::y, and Vehicle::y_pos.
Referenced by AircraftController(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Submarine(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), TrainController(), and UpdateOldAircraft().
Get reason string why this station can't be used by the given vehicle.
| v | The vehicle to test. |
| st | The station to test for. |
Definition at line 3135 of file vehicle.cpp.
References AIR_CTOL, Airport, Bus, RoadVehicle::compatible_roadtypes, BaseStation::facilities, SpecializedVehicle< RoadVehicle, Type >::From(), Vehicle::GetEngine(), Vehicle::HasArticulatedPart(), HasTileAnyRoadType(), INVALID_STRING_ID, IsBayRoadStopTile(), RoadVehicle::IsBus(), RoadStop::next, RoadVehicle::roadtype, AircraftVehicleInfo::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Truck, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and RoadStop::xy.
Referenced by CmdCloneOrder(), and CmdInsertOrder().
Get the colour map for a vehicle.
| v | Vehicle to get colour map for |
Definition at line 2174 of file vehicle.cpp.
References Vehicle::engine_type, GroundVehicleCache::first_engine, Vehicle::GetGroundVehicleCache(), Vehicle::IsGroundVehicle(), and Vehicle::owner.
Referenced by DoDrawVehicle(), DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainDetails(), DrawTrainImage(), and SetMouseCursorVehicle().
| void GetVehicleSet | ( | VehicleSet & | set, |
| Vehicle * | v, | ||
| uint8_t | num_vehicles ) |
Calculates the set of vehicles that will be affected by a given selection.
| [in,out] | set | Set of affected vehicles. |
| v | First vehicle of the selection. | |
| num_vehicles | Number of vehicles in the selection (not counting articulated parts). |
Definition at line 3249 of file vehicle.cpp.
References SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< T, Type >::GetFirstEnginePart(), include(), Vehicle::IsArticulatedPart(), GroundVehicle< T, Type >::IsMultiheaded(), SpecializedVehicle< T, Type >::Next(), Train::other_multiheaded_part, BaseVehicle::type, and VEH_TRAIN.
Referenced by RefitWindow::BuildRefitList(), RefitWindow::DrawWidget(), and RefitVehicle().
| 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 them.
The predicate must have the signature: bool Predicate(const Vehicle *);
| x | The world X-coordinate. |
| y | The world Y-coordinate. |
| max_dist | The maximum distance to consider. |
| predicate | The filter to apply to find vehicles. |
true iff a suitable vehicle has been found within the given distance. Definition at line 184 of file vehicle_func.h.
| bool HasVehicleOnTile | ( | TileIndex | tile, |
| UnaryPred && | predicate ) |
Loop over vehicles on a tile, and check whether a predicate is true for any of them.
The predicate must have the signature: bool Predicate(const Vehicle *);
| tile | The tile to search on. |
| predicate | The filter to apply to find vehicles. |
true iff a suitable vehicle has been found within the given distance. Definition at line 109 of file vehicle_func.h.
Referenced by CheckRoadBlockedForOvertaking(), CheckShipStayInDepot(), ExploreSegment(), TerraformTile_Rail(), TrainApproachingCrossing(), TrainController(), and TrainOnCrossing().
|
inline |
Is the given vehicle buildable by a company?
| v | Vehicle being queried. |
Definition at line 246 of file vehicle_func.h.
References IsCompanyBuildableVehicleType(), and BaseVehicle::type.
|
inline |
Is the given vehicle type buildable by a company?
| type | Vehicle type being queried. |
Definition at line 236 of file vehicle_func.h.
References VEH_COMPANY_END.
Referenced by CanBuildVehicleInfrastructure(), ChangeOwnershipOfCompanyItems(), CmdAddSharedVehicleGroup(), CmdCreateGroup(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdMassStartStopVehicle(), CmdRefitVehicle(), Vehicle::FixOldVehicles, IsCompanyBuildableVehicleType(), VEHSChunkHandler::Load(), EngineOverrideManager::ResetToCurrentNewGRFConfig(), and UpdateCompanyRatingAndValue().
|
inlinestatic |
Definition at line 32 of file vehicle_func.h.
| bool IsUniqueVehicleName | ( | const std::string & | name | ) |
Test if a name is unique among vehicle names.
| name | Name to test. |
Definition at line 772 of file vehicle_cmd.cpp.
Referenced by CloneVehicleName(), CmdRenameVehicle(), and OrderBackup::DoRestore().
| bool IsValidImageIndex | ( | uint8_t | image_index | ) |
Helper to check whether an image index is valid for a particular vehicle.
| T | The type of vehicle. |
| image_index | The image index to check. |
Referenced by Aircraft::GetImage(), RoadVehicle::GetImage(), Ship::GetImage(), Train::GetImage(), and IsValidNewGRFImageIndex().
| void ReleaseDisasterVehicle | ( | VehicleID | vehicle | ) |
Notify disasters that we are about to delete a vehicle.
So make them head elsewhere.
| vehicle | deleted vehicle |
Definition at line 1000 of file disaster_vehicle.cpp.
References Vehicle::age, Vehicle::dest_tile, GetAircraftFlightLevelBounds(), TimerGameConst< struct Calendar >::MIN_DATE, RandomTile, ST_SMALL_UFO, DisasterVehicle::state, Vehicle::subtype, and Vehicle::z_pos.
Referenced by Vehicle::PreDestructor().
| void ResetVehicleColourMap | ( | ) |
Definition at line 685 of file vehicle.cpp.
| void ResetVehicleHash | ( | ) |
Definition at line 678 of file vehicle.cpp.
| void RunVehicleCalendarDayProc | ( | ) |
Age all vehicles, spreading out the action using the current TimerGameCalendar::date_fract.
Definition at line 936 of file vehicle.cpp.
References TimerGameCalendar::date_fract, Ticks::DAY_TICKS, and Vehicle::OnNewCalendarDay().
Referenced by StateGameLoop().
| 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.
| engine | The engine that caused the problem |
| part1 | Part 1 of the error message, taking the grfname as parameter 1 |
| part2 | Part 2 of the error message, taking the engine as parameter 2 |
| bug_type | Flag to check and set in grfconfig |
| critical | Shall the "OpenTTD might crash"-message be shown when the player tries to unpause? |
Definition at line 337 of file vehicle.cpp.
References _networking, Debug, Error, Execute, GetEncodedString(), GetGRFConfig(), Engine::GetGRFID(), GRFConfig::GetName(), GetString(), GRFConfig::grf_bugs, Normal, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), ShowErrorMessage(), StrMakeValid(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WL_CRITICAL.
Referenced by CheckConsistencyOfArticulatedVehicle(), Train::ConsistChanged(), Vehicle::UpdateVisualEffect(), and VehicleLengthChanged().
| CommandCost TunnelBridgeIsFree | ( | TileIndex | tile, |
| TileIndex | endtile, | ||
| const Vehicle * | ignore ) |
Finds vehicle in tunnel / bridge.
| tile | first end |
| endtile | second end |
| ignore | Ignore this vehicle when searching |
Definition at line 580 of file vehicle.cpp.
References VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by ClearPathReservation(), CmdBuildRoad(), CmdConvertRail(), CmdConvertRoad(), DoClearBridge(), DoClearTunnel(), and RemoveRoad().
| void VehicleEnterDepot | ( | Vehicle * | v | ) |
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc.
| v | Vehicle that entered a depot. |
Definition at line 1564 of file vehicle.cpp.
References _current_company, _local_company, _settings_client, AddVehicleAdviceNewsItem(), CCF_ARRANGE, Clamp(), ClampTo(), Train::ConsistChanged(), TimerGameTick::counter, BaseConsist::cur_real_order_index, Vehicle::cur_speed, Vehicle::current_order, Vehicle::DeleteUnreachedImplicitOrders(), Depot, BaseConsist::depot_unbunching_last_departure, Vehicle::dest_tile, Execute, CommandCost::Failed(), Vehicle::First(), Train::flags, Train::force_proceed, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Ship, VEH_SHIP >::From(), SpecializedVehicle< Train, Type >::From(), CommandCost::GetCost(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetDestination(), GetEncodedString(), Vehicle::GetOrder(), Order::GetRefitCargo(), GetStationIndex(), Halt, HandleAircraftEnterHangar(), Hidden, Vehicle::IncrementImplicitOrderIndex(), INVALID_DIAGDIR, InvalidateWindowData(), Order::IsRefit(), Order::IsType(), Vehicle::last_loading_station, Order::MakeDummy(), Vehicle::MarkDirty(), MarkTileDirtyByTile(), NearestDepot, AI::NewEvent(), Vehicle::owner, PartOfOrders, Vehicle::profit_this_year, RefitFailed, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseConsist::ResetDepotUnbunching(), Backup< T >::Restore(), Reversed, BaseConsist::round_trip_time, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetDepotReservation(), SetWindowClassesDirty(), SetWindowDirty(), ShowCostOrIncomeAnimation(), Ship::state, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, Vehicle::tile, TRACK_BIT_DEPOT, BaseVehicle::type, Unbunch, Ship::UpdateCache(), UpdateSignalsOnSegment(), UpdateVehicleTimetable(), SpecializedVehicle< T, Type >::UpdateViewport(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, VehicleEnteredDepotThisTick(), VehicleServiceInDepot(), VehicleWaiting, Vehicle::vehstatus, Train::wait_counter, WC_AIRCRAFT_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_TRAINS_LIST, WC_VEHICLE_DEPOT, WC_VEHICLE_VIEW, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by AircraftEventHandler_EnterHangar(), AircraftEventHandler_InHangar(), CheckShipStayInDepot(), CheckTrainStayInDepot(), VehicleEnterTile_Rail(), and VehicleEnterTile_Road().
| void VehicleLengthChanged | ( | const Vehicle * | u | ) |
Logs a bug in GRF and shows a warning message if this is for the first time this happened.
| u | first vehicle of chain |
Definition at line 363 of file vehicle.cpp.
References _gamelog, Vehicle::engine_type, Vehicle::GetEngine(), GetGRFConfig(), GRFConfig::grf_bugs, Engine::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::local_id, ShowNewGrfVehicleError(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and VehLength.
Referenced by Train::ConsistChanged(), and RoadVehUpdateCache().
| void VehicleServiceInDepot | ( | Vehicle * | v | ) |
Service a vehicle and all subsequent vehicles in the consist.
| *v | The vehicle or vehicle chain being serviced |
Definition at line 187 of file vehicle.cpp.
References _settings_game, Vehicle::breakdown_chance, Vehicle::breakdowns_since_last_service, TimerGameCalendar::date, TimerGameEconomy::date, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, Vehicle::GetEngine(), Vehicle::HasEngineType(), Vehicle::Next(), Engine::reliability, Vehicle::reliability, SetWindowDirty(), and WC_VEHICLE_DETAILS.
Referenced by AircraftLeaveHangar(), CheckIfTrainNeedsService(), CheckShipStayInDepot(), CheckTrainStayInDepot(), and VehicleEnterDepot().
Checks if two vehicle chains have the same list of engines.
| v1 | First vehicle chain. |
| v2 | Second vehicle chain. |
Definition at line 3303 of file vehicle.cpp.
References Vehicle::GetEngine(), and Vehicle::GetNextVehicle().
Referenced by DepotWindow::OnVehicleSelect().
Checks if two vehicles have the same list of orders.
| v1 | First vehicles. |
| v2 | Second vehicles. |
Definition at line 3320 of file vehicle.cpp.
Referenced by DepotWindow::OnVehicleSelect(), and OrdersWindow::OnVehicleSelect().
| void ViewportAddVehicles | ( | DrawPixelInfo * | dpi | ) |
Add the vehicle sprites that should be drawn at a part of the screen.
| dpi | Rectangle being drawn. |
Definition at line 1150 of file vehicle.cpp.
References Vehicle::coord, Vehicle::direction, DoDrawVehicle(), EIT_ON_MAP, GEN_HASHX_INC, GEN_HASHX_MASK, GEN_HASHX_SIZE, GEN_HASHY_INC, GEN_HASHY_MASK, GEN_HASHY_SIZE, Vehicle::GetImage(), Vehicle::hash_viewport_next, Hidden, VehicleSpriteSeq::IsValid(), MAX_VEHICLE_PIXEL_X, MAX_VEHICLE_PIXEL_Y, MutableSpriteCache::revalidate_before_draw, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::UpdateBoundingBoxCoordinates(), and Vehicle::vehstatus.
|
extern |
When can't send to depot such vehicle.
Definition at line 92 of file vehicle_cmd.cpp.
|
extern |
When can't autoreplace such vehicle.
Definition at line 76 of file vehicle_cmd.cpp.
|
extern |
When can't buy such vehicle.
Definition at line 52 of file vehicle_cmd.cpp.
|
extern |
When can't refit such vehicle.
Definition at line 84 of file vehicle_cmd.cpp.
|
extern |
When can't sell all vehicles in depot.
Definition at line 68 of file vehicle_cmd.cpp.
|
extern |
When can't sell such vehicle.
Definition at line 60 of file vehicle_cmd.cpp.
|
static |
Only vehicles older than this have a meaningful profit.
Definition at line 37 of file vehicle_func.h.
Referenced by GroupStatistics::CountVehicle(), DrawVehicleProfitButton(), EconomyAgeVehicle(), UpdateCompanyRatingAndValue(), and GroupStatistics::UpdateProfits().
|
static |
Threshold for a vehicle to be considered making good profit.
Definition at line 38 of file vehicle_func.h.
Referenced by DrawVehicleProfitButton(), and VehicleGroupWindow::GetGroupProfitSpriteID().