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;
81 if (v->
type != bdvld->type || !v->
IsInDepot())
return nullptr;
86 if (bdvld->wagons !=
nullptr && t->
First()->IsFreeWagon()) {
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;
debug_inline static constexpr 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.
@ OWNER_NONE
The tile has no ownership.
Base class for groups and group functions.
bool GroupIsInGroup(GroupID search, GroupID group)
Test if GroupID group is a descendant of (or is) GroupID search.
static const GroupID ALL_GROUP
All vehicles are in this group.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
VehicleType type
Type of vehicle.
Data for building a depot vehicle list.
VehicleList * engines
Pointer to list to add vehicles to.
VehicleType type
Type of vehicle.
bool individual_wagons
If true add every wagon to wagons which is not attached to an engine. If false only add the first wag...
VehicleList * wagons
Pointer to list to add wagons to (can be nullptr).
bool IsRearDualheaded() const
Tell if we are dealing with the rear end of a multiheaded engine.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
T * First() const
Get the first vehicle in the chain.
'Train' is either a loco or a wagon.
The information about a vehicle list.
VehicleListType type
The type of vehicle list.
CompanyID company
The company associated with this list.
uint32_t Pack() const
Pack a VehicleListIdentifier in a single uint32.
VehicleType vtype
The vehicle type associated with this list.
static VehicleListIdentifier UnPack(uint32_t data)
Decode a packed vehicle list identifier into a new one.
uint32_t index
A vehicle list type specific index.
bool UnpackIfValid(uint32_t data)
Unpack a VehicleListIdentifier from a single uint32.
GroupID group_id
Index of group Pool array.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
Owner owner
Which company owns the vehicle?
Base for the train class.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
Functions related to vehicles.
VehicleType
Available vehicle types.
@ VEH_TRAIN
Train vehicle type.
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
Generate a list of vehicles based on window type.
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
static Vehicle * BuildDepotVehicleListProc(Vehicle *v, void *data)
Add vehicles to a depot vehicle list.
Functions and type for generating vehicle lists.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
VehicleListType
Vehicle List type flags.
Functions and type for generating vehicle lists.
void FindVehiclesWithOrder(VehiclePredicate veh_pred, OrderPredicate ord_pred, VehicleFunc veh_func)
Find vehicles matching an order.