OpenTTD Source 20241224-master-gf74b0cf984
|
Functions related to articulated vehicles. More...
Go to the source code of this file.
Functions | |
uint | CountArticulatedParts (EngineID engine_type, bool purchase_window) |
Count the number of articulated parts of an engine. | |
CargoArray | GetCapacityOfArticulatedParts (EngineID engine) |
Get the capacity of the parts of a given engine. | |
CargoTypes | GetCargoTypesOfArticulatedParts (EngineID engine) |
Get the cargo mask of the parts of a given engine. | |
void | AddArticulatedParts (Vehicle *first) |
Add the remaining articulated parts to the given vehicle. | |
void | GetArticulatedRefitMasks (EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask) |
Merges the refit_masks of all articulated parts. | |
CargoTypes | GetUnionOfArticulatedRefitMasks (EngineID engine, bool include_initial_cargo_type) |
Ors the refit_masks of all articulated parts. | |
CargoTypes | GetCargoTypesOfArticulatedVehicle (const Vehicle *v, CargoID *cargo_type) |
Get cargo mask of all cargoes carried by an articulated vehicle. | |
bool | IsArticulatedVehicleRefittable (EngineID engine) |
Checks whether any of the articulated parts is refittable. | |
bool | IsArticulatedEngine (EngineID engine_type) |
Does a NewGRF report that this should be an articulated vehicle? | |
void | CheckConsistencyOfArticulatedVehicle (const Vehicle *v) |
Checks whether the specs of freshly build articulated vehicles are consistent with the information specified in the purchase list. | |
Functions related to articulated vehicles.
Definition in file articulated_vehicles.h.
void AddArticulatedParts | ( | Vehicle * | first | ) |
Add the remaining articulated parts to the given vehicle.
first | The head of the articulated bit. |
Definition at line 338 of file articulated_vehicles.cpp.
References Vehicle::build_year, GroundVehicleCache::cached_veh_length, EngineInfo::callback_mask, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::CanAllocateItem(), Engine::CanCarryCargo(), RailVehicleInfo::capacity, Vehicle::cargo_cap, Vehicle::cargo_subtype, Vehicle::cargo_type, CBM_VEHICLE_ARTIC_ENGINE, RoadVehicle::compatible_roadtypes, Vehicle::date_of_last_service, Vehicle::date_of_last_service_newgrf, Vehicle::direction, Vehicle::engine_type, GroundVehicleCache::first_engine, SpecializedVehicle< T, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetDefaultCargoType(), Vehicle::GetGroundVehicleCache(), GetNextArticulatedPart(), HasBit(), INVALID_ENGINE, IsValidCargoID(), Vehicle::max_age, MAX_ARTICULATED_PARTS, Vehicle::owner, Vehicle::random_bits, Vehicle::refit_cap, RoadVehicle::roadtype, RVSB_IN_DEPOT, VehicleSpriteSeq::Set(), GroundVehicle< T, Type >::SetArticulatedPart(), SetBit(), Vehicle::SetNext(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::spritenum, RoadVehicle::state, Vehicle::subtype, TestVehicleBuildProbability(), Vehicle::tile, BaseVehicle::type, Vehicle::UpdatePosition(), Vehicle::value, VEH_ROAD, VEH_TRAIN, VEHICLE_LENGTH, Vehicle::vehstatus, VRF_REVERSE_DIRECTION, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildRailVehicle(), CmdBuildRailWagon(), and CmdBuildRoadVehicle().
void CheckConsistencyOfArticulatedVehicle | ( | const Vehicle * | v | ) |
Checks whether the specs of freshly build articulated vehicles are consistent with the information specified in the purchase list.
Only essential information is checked to leave room for magic tricks/workarounds to grfcoders. It checks: For autoreplace/-renew:
Definition at line 296 of file articulated_vehicles.cpp.
References Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::engine_type, GBUG_VEH_REFIT, GetArticulatedRefitMasks(), GetAvailableVehicleCargoTypes(), GetCapacityOfArticulatedParts(), Vehicle::GetEngine(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, NUM_CARGO, SetBit(), and ShowNewGrfVehicleError().
Referenced by CmdBuildRailVehicle(), CmdBuildRailWagon(), and CmdBuildRoadVehicle().
uint CountArticulatedParts | ( | EngineID | engine_type, |
bool | purchase_window | ||
) |
Count the number of articulated parts of an engine.
engine_type | The engine to get the number of parts of. |
purchase_window | Whether we are in the scope of the purchase window or not, i.e. whether we cannot allocate vehicles. |
Definition at line 75 of file articulated_vehicles.cpp.
References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::CanAllocateItem(), CBM_VEHICLE_ARTIC_ENGINE, Vehicle::engine_type, GetNextArticulatedPart(), HasBit(), INVALID_ENGINE, MAX_ARTICULATED_PARTS, and Vehicle::owner.
Referenced by CmdBuildVehicle().
void GetArticulatedRefitMasks | ( | EngineID | engine, |
bool | include_initial_cargo_type, | ||
CargoTypes * | union_mask, | ||
CargoTypes * | intersection_mask | ||
) |
Merges the refit_masks of all articulated parts.
engine | the first part |
include_initial_cargo_type | if true the default cargo type of the vehicle is included; if false only the refit_mask |
union_mask | returns bit mask of CargoIDs which are a refit option for at least one articulated part |
intersection_mask | returns bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0) |
Definition at line 224 of file articulated_vehicles.cpp.
References EngineInfo::callback_mask, CBM_VEHICLE_ARTIC_ENGINE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetAvailableVehicleCargoTypes(), GetNextArticulatedPart(), HasBit(), INVALID_ENGINE, Engine::IsGroundVehicle(), and MAX_ARTICULATED_PARTS.
Referenced by CheckConsistencyOfArticulatedVehicle(), GetNewCargoTypeForReplace(), GetUnionOfArticulatedRefitMasks(), and Vehicle::NeedsServicing().
CargoArray GetCapacityOfArticulatedParts | ( | EngineID | engine | ) |
Get the capacity of the parts of a given engine.
engine | The engine to get the capacities from. |
Definition at line 138 of file articulated_vehicles.cpp.
References EngineInfo::callback_mask, CBM_VEHICLE_ARTIC_ENGINE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetNextArticulatedPart(), GetVehicleDefaultCapacity(), HasBit(), INVALID_ENGINE, Engine::IsGroundVehicle(), IsValidCargoID(), and MAX_ARTICULATED_PARTS.
Referenced by CheckConsistencyOfArticulatedVehicle(), CmdBuildVehicle(), and GetTotalCapacityOfArticulatedParts().
CargoTypes GetCargoTypesOfArticulatedParts | ( | EngineID | engine | ) |
Get the cargo mask of the parts of a given engine.
engine | The engine to get the capacities from. |
Definition at line 168 of file articulated_vehicles.cpp.
References EngineInfo::callback_mask, CBM_VEHICLE_ARTIC_ENGINE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetNextArticulatedPart(), GetVehicleDefaultCapacity(), HasBit(), INVALID_ENGINE, Engine::IsGroundVehicle(), IsValidCargoID(), MAX_ARTICULATED_PARTS, and SetBit().
Referenced by GetNewCargoTypeForReplace(), and Vehicle::NeedsServicing().
Get cargo mask of all cargoes carried by an articulated vehicle.
Note: Vehicles not carrying anything are ignored
v | the first vehicle in the chain |
cargo_type | returns the common CargoID if needed. (INVALID_CARGO if no part is carrying something or they are carrying different things) |
Definition at line 264 of file articulated_vehicles.cpp.
References Engine::CanCarryCargo(), Vehicle::cargo_type, Vehicle::GetEngine(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), IsValidCargoID(), and SetBit().
Referenced by GetNewCargoTypeForReplace(), and Vehicle::NeedsServicing().
CargoTypes GetUnionOfArticulatedRefitMasks | ( | EngineID | engine, |
bool | include_initial_cargo_type | ||
) |
Ors the refit_masks of all articulated parts.
engine | the first part |
include_initial_cargo_type | if true the default cargo type of the vehicle is included; if false only the refit_mask |
Definition at line 250 of file articulated_vehicles.cpp.
References GetArticulatedRefitMasks().
Referenced by CargoAndEngineFilter(), EnginesHaveCargoInCommon(), GetIncompatibleRefitOrderIdForAutoreplace(), GetPreviewCompany(), ShowRefitOptionsList(), and VerifyAutoreplaceRefitForOrders().
bool IsArticulatedEngine | ( | EngineID | engine_type | ) |
Does a NewGRF report that this should be an articulated vehicle?
engine_type | The engine to check. |
Definition at line 64 of file articulated_vehicles.cpp.
References CBM_VEHICLE_ARTIC_ENGINE, and HasBit().
bool IsArticulatedVehicleRefittable | ( | EngineID | engine | ) |
Checks whether any of the articulated parts is refittable.
engine | the first part |
Definition at line 198 of file articulated_vehicles.cpp.
References EngineInfo::callback_mask, CBM_VEHICLE_ARTIC_ENGINE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetNextArticulatedPart(), HasBit(), INVALID_ENGINE, IsEngineRefittable(), Engine::IsGroundVehicle(), and MAX_ARTICULATED_PARTS.
Referenced by DrawVehiclePurchaseInfo().