* 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.
| 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 | */ |
| 43 | void 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. |
no test coverage detected