OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
27 assert(this->
vtype < (1 << 2));
28 assert(this->
index < (1 << 20));
29 assert(this->
type < VLT_END);
30 static_assert(VLT_END <= (1 << 3));
32 return c << 28 | this->
type << 23 | this->
vtype << 26 | this->
index;
42 uint8_t c =
GB(data, 28, 4);
48 return this->
type < VLT_END;
58 [[maybe_unused]]
bool ret = result.UnpackIfValid(data);
81 if (v->
type != bdvld->type || !v->
IsInDepot())
return nullptr;
87 if (bdvld->individual_wagons || t->
IsFreeWagon()) bdvld->wagons->push_back(t);
107 if (wagons !=
nullptr && wagons != engines) wagons->clear();
124 case VL_STATION_LIST:
127 [&vli](
const Order *order) {
return (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) && order->GetDestination() == vli.
index; },
128 [&list](
const Vehicle *v) { list->push_back(v); }
132 case VL_SHARED_ORDERS: {
166 [&vli](
const Order *order) {
return order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() &
ODATFB_NEAREST_DEPOT) && order->GetDestination() == vli.
index; },
167 [&list](
const Vehicle *v) { list->push_back(v); }
171 default:
return false;
std::vector< const Vehicle * > VehicleList
A list of vehicles.
CompanyID company
The company associated with this list.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
The information about a vehicle list.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Owner
Enum for all companies/owners.
@ VEH_TRAIN
Train vehicle type.
GroupID group_id
Index of group Pool array.
bool IsRearDualheaded() const
Tell if we are dealing with the rear end of a multiheaded engine.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Owner owner
Which company owns the vehicle?
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
static const GroupID ALL_GROUP
All vehicles are in this group.
@ OWNER_NONE
The tile has no ownership.
uint32_t index
A vehicle list type specific index.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
uint32_t Pack() const
Pack a VehicleListIdentifier in a single uint32.
void FindVehiclesWithOrder(VehiclePredicate veh_pred, OrderPredicate ord_pred, VehicleFunc veh_func)
Find vehicles matching an order.
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
Generate a list of vehicles based on window type.
'Train' is either a loco or a wagon.
VehicleList * engines
Pointer to list to add vehicles to.
VehicleList * wagons
Pointer to list to add wagons to (can be nullptr).
bool individual_wagons
If true add every wagon to wagons which is not attached to an engine. If false only add the first wag...
Data for building a depot vehicle list.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
VehicleType type
Type of vehicle.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
VehicleType vtype
The vehicle type associated with this list.
VehicleListType
Vehicle List type flags.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
VehicleListType type
The type of vehicle list.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
VehicleType
Available vehicle types.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
VehicleType type
Type of vehicle.
static Vehicle * BuildDepotVehicleListProc(Vehicle *v, void *data)
Add vehicles to a depot vehicle list.
T * First() const
Get the first vehicle in the chain.
static VehicleListIdentifier UnPack(uint32_t data)
Decode a packed vehicle list identifier into a new one.
bool UnpackIfValid(uint32_t data)
Unpack a VehicleListIdentifier from a single uint32.
bool GroupIsInGroup(GroupID search, GroupID group)
Test if GroupID group is a descendant of (or is) GroupID search.