|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
26 assert(this->
vtype < (1 << 2));
27 assert(this->
index < (1 << 20));
28 assert(this->
type < VLT_END);
29 static_assert(VLT_END <= (1 << 3));
31 return c << 28 | this->
type << 23 | this->
vtype << 26 | this->
index;
41 byte c =
GB(data, 28, 4);
47 return this->
type < VLT_END;
57 [[maybe_unused]]
bool ret = result.UnpackIfValid(data);
73 if (wagons !=
nullptr && wagons != engines) wagons->clear();
77 if (v->type != type)
continue;
78 if (v->tile != tile)
continue;
86 if (individual_wagons || t->
IsFreeWagon()) wagons->push_back(t);
94 if (!v->IsPrimaryVehicle())
continue;
95 if (!v->IsInDepot())
continue;
99 engines->push_back(v);
104 engines->shrink_to_fit();
105 if (wagons !=
nullptr && wagons != engines) wagons->shrink_to_fit();
119 case VL_STATION_LIST:
122 [&vli](
const Order *order) {
return (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) && order->GetDestination() == vli.
index; },
123 [&list](
const Vehicle *v) { list->push_back(v); }
127 case VL_SHARED_ORDERS: {
161 [&vli](
const Order *order) {
return order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() &
ODATFB_NEAREST_DEPOT) && order->GetDestination() == vli.
index; },
162 [&list](
const Vehicle *v) { list->push_back(v); }
166 default:
return false;
169 list->shrink_to_fit();
bool IsInDepot() const override
Check whether the vehicle is in the depot.
VehicleListType
Vehicle List type flags.
bool IsPrimaryVehicle() const override
Whether this is the primary vehicle in the chain.
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.
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?
Owner
Enum for all companies/owners.
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.
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.
VehicleType
Available vehicle types.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
VehicleType vtype
The vehicle type associated with this list.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
@ OWNER_NONE
The tile has no ownership.
VehicleListType type
The type of vehicle list.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
@ VEH_TRAIN
Train vehicle type.
VehicleType type
Type of vehicle.
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.