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

Method GenerateBuildAircraftList

src/build_vehicle_gui.cpp:1502–1534  ·  view source on GitHub ↗

Figure out what aircraft EngineIDs to put in the list */

Source from the content-addressed store, hash-verified

1500
1501 /* Figure out what aircraft EngineIDs to put in the list */
1502 void GenerateBuildAircraftList()
1503 {
1504 EngineID sel_id = EngineID::Invalid();
1505
1506 this->eng_list.clear();
1507
1508 const Station *st = this->listview_mode ? nullptr : Station::GetByTile(TileIndex(this->window_number));
1509
1510 BadgeTextFilter btf(this->string_filter, GSF_AIRCRAFT);
1511 BadgeDropdownFilter bdf(this->badge_filter_choices);
1512
1513 /* Make list of all available planes.
1514 * Also check to see if the previously selected plane is still available,
1515 * and if not, reset selection to EngineID::Invalid(). This could be the case
1516 * when planes become obsolete and are removed */
1517 for (const Engine *e : Engine::IterateType(VEH_AIRCRAFT)) {
1518 if (!this->show_hidden_engines && e->IsVariantHidden(_local_company)) continue;
1519 EngineID eid = e->index;
1520 if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_company)) continue;
1521 /* First VEH_END window_numbers are fake to allow a window open for all different types at once */
1522 if (!this->listview_mode && !CanVehicleUseStation(eid, st)) continue;
1523 if (!bdf.Filter(e->badges)) continue;
1524
1525 /* Filter by name or NewGRF extra text */
1526 if (!FilterByText(e) && !btf.Filter(e->badges)) continue;
1527
1528 this->eng_list.emplace_back(eid, e->info.variant_id, e->display_flags, 0);
1529
1530 if (eid == this->sel_engine) sel_id = eid;
1531 }
1532
1533 this->SelectEngine(sel_id);
1534 }
1535
1536 /* Generate the list of vehicles */
1537 void GenerateBuildList()

Callers 1

GenerateBuildListMethod · 0.95

Calls 7

SelectEngineMethod · 0.95
InvalidFunction · 0.85
IsEngineBuildableFunction · 0.85
CanVehicleUseStationFunction · 0.85
IsVariantHiddenMethod · 0.80
clearMethod · 0.45
FilterMethod · 0.45

Tested by

no test coverage detected