MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / BuildDepotVehicleList

Function BuildDepotVehicleList

src/vehiclelist.cpp:43–62  ·  view source on GitHub ↗

* Generate a list of vehicles inside a depot. * @param type Type of vehicle * @param tile The tile the depot is located on * @param engines Pointer to list to add vehicles to * @param wagons Pointer to list to add wagons to (can be nullptr) * @param individual_wagons If true add every wagon to \a wagons which is not attached to an engine. If false only add the first wagon of every row.

Source from the content-addressed store, hash-verified

41 * @param individual_wagons If true add every wagon to \a wagons which is not attached to an engine. If false only add the first wagon of every row.
42 */
43void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
44{
45 engines->clear();
46 if (wagons != nullptr && wagons != engines) wagons->clear();
47
48 for (Vehicle *v : VehiclesOnTile(tile)) {
49 if (v->type != type || !v->IsInDepot()) continue;
50
51 if (type == VEH_TRAIN) {
52 const Train *t = Train::From(v);
53 if (t->IsArticulatedPart() || t->IsRearDualheaded()) continue;
54 if (wagons != nullptr && t->First()->IsFreeWagon()) {
55 if (individual_wagons || t->IsFreeWagon()) wagons->push_back(t);
56 continue;
57 }
58 }
59
60 if (v->IsPrimaryVehicle()) engines->push_back(v);
61 }
62}
63
64/**
65 * Generate a list of vehicles based on window type.

Callers 4

RefreshVehicleListMethod · 0.85
CmdMassStartStopVehicleFunction · 0.85
CmdDepotSellAllVehiclesFunction · 0.85
CmdDepotMassAutoReplaceFunction · 0.85

Calls 9

VehiclesOnTileClass · 0.85
IsArticulatedPartMethod · 0.80
IsRearDualheadedMethod · 0.80
IsFreeWagonMethod · 0.80
push_backMethod · 0.80
clearMethod · 0.45
IsInDepotMethod · 0.45
FirstMethod · 0.45
IsPrimaryVehicleMethod · 0.45

Tested by

no test coverage detected