Generate the list of vehicles */
| 1535 | |
| 1536 | /* Generate the list of vehicles */ |
| 1537 | void GenerateBuildList() |
| 1538 | { |
| 1539 | if (!this->eng_list.NeedRebuild()) return; |
| 1540 | |
| 1541 | /* Update filter type in case the road/railtype of the depot got converted */ |
| 1542 | this->UpdateFilterByTile(); |
| 1543 | |
| 1544 | this->eng_list.clear(); |
| 1545 | |
| 1546 | GUIEngineList list; |
| 1547 | |
| 1548 | switch (this->vehicle_type) { |
| 1549 | default: NOT_REACHED(); |
| 1550 | case VEH_TRAIN: |
| 1551 | this->GenerateBuildTrainList(list); |
| 1552 | GUIEngineListAddChildren(this->eng_list, list); |
| 1553 | this->eng_list.RebuildDone(); |
| 1554 | return; |
| 1555 | case VEH_ROAD: |
| 1556 | this->GenerateBuildRoadVehList(); |
| 1557 | break; |
| 1558 | case VEH_SHIP: |
| 1559 | this->GenerateBuildShipList(); |
| 1560 | break; |
| 1561 | case VEH_AIRCRAFT: |
| 1562 | this->GenerateBuildAircraftList(); |
| 1563 | break; |
| 1564 | } |
| 1565 | |
| 1566 | this->FilterEngineList(); |
| 1567 | |
| 1568 | /* ensure primary engine of variant group is in list after filtering */ |
| 1569 | FlatSet<EngineID> variants; |
| 1570 | for (const auto &item : this->eng_list) { |
| 1571 | EngineID parent = item.variant_id; |
| 1572 | while (parent != EngineID::Invalid() && variants.insert(parent).second) { |
| 1573 | parent = Engine::Get(parent)->info.variant_id; |
| 1574 | } |
| 1575 | } |
| 1576 | |
| 1577 | for (const auto &variant : variants) { |
| 1578 | if (std::ranges::find(this->eng_list, variant, &GUIEngineListItem::engine_id) == this->eng_list.end()) { |
| 1579 | const Engine *e = Engine::Get(variant); |
| 1580 | this->eng_list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlag::Shaded, 0); |
| 1581 | } |
| 1582 | } |
| 1583 | |
| 1584 | _engine_sort_direction = this->descending_sort_order; |
| 1585 | EngList_Sort(this->eng_list, _engine_sort_functions[this->vehicle_type][this->sort_criteria]); |
| 1586 | |
| 1587 | this->eng_list.swap(list); |
| 1588 | GUIEngineListAddChildren(this->eng_list, list, EngineID::Invalid(), 0); |
| 1589 | this->eng_list.RebuildDone(); |
| 1590 | } |
| 1591 | |
| 1592 | DropDownList BuildCargoDropDownList() const |
| 1593 | { |
no test coverage detected