OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
25 assert(this->
vtype < (1 << 2));
26 assert(this->
index < (1 << 20));
27 assert(this->
type < VLT_END);
28 static_assert(VLT_END <= (1 << 3));
30 return c << 28 | this->
type << 23 | this->
vtype << 26 | this->
index;
40 byte c =
GB(data, 28, 4);
46 return this->
type < VLT_END;
72 if (wagons !=
nullptr && wagons != engines) wagons->clear();
76 if (v->type != type)
continue;
77 if (v->tile != tile)
continue;
85 if (individual_wagons || t->
IsFreeWagon()) wagons->push_back(t);
92 if (!v->IsInDepot())
continue;
96 if (!v->IsPrimaryVehicle())
continue;
98 engines->push_back(v);
103 engines->shrink_to_fit();
104 if (wagons !=
nullptr && wagons != engines) wagons->shrink_to_fit();
118 case VL_STATION_LIST:
120 if (v->type == vli.
vtype && v->IsPrimaryVehicle()) {
121 for (
const Order *order : v->Orders()) {
122 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT))
123 && order->GetDestination() == vli.
index) {
132 case VL_SHARED_ORDERS: {
146 if (v->type == vli.
vtype && v->IsPrimaryVehicle() &&
157 if (v->type == vli.
vtype && v->owner == vli.
company && v->IsPrimaryVehicle()) {
165 if (v->type == vli.
vtype && v->IsPrimaryVehicle()) {
166 for (
const Order *order : v->Orders()) {
167 if (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() &
ODATFB_NEAREST_DEPOT) && order->GetDestination() == vli.
index) {
176 default:
return false;
179 list->shrink_to_fit();
uint32 TileIndex
The index/ID of a Tile.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
CompanyID company
The company associated with this list.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
The information about a vehicle list.
bool UnpackIfValid(uint32 data)
Unpack a VehicleListIdentifier from a single uint32.
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
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 Pack() const
Pack a VehicleListIdentifier in a single uint32.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
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.
VehicleListType
Vehicle List type flags.
uint32 index
A vehicle list type specific index.
@ TRACK_BIT_DEPOT
Bitflag for a depot.
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.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
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.
bool GroupIsInGroup(GroupID search, GroupID group)
Test if GroupID group is a descendant of (or is) GroupID search.