Skip to content

Commit

Permalink
Fix #11168: Display variant groups that consist only of unavailable s…
Browse files Browse the repository at this point in the history
…ub-groups
  • Loading branch information
merni-ns committed Sep 30, 2023
1 parent b5dc932 commit 3d7b1f5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/build_vehicle_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,15 @@ struct BuildVehicleWindow : Window {
list.emplace_back(eid, e->info.variant_id, e->display_flags, 0);

if (rvi->railveh_type != RAILVEH_WAGON) num_engines++;
if (e->info.variant_id != eid && e->info.variant_id != INVALID_ENGINE) variants.push_back(e->info.variant_id);
if (e->info.variant_id != eid && e->info.variant_id != INVALID_ENGINE) {
EngineID parent = e->info.variant_id;
while (parent != INVALID_ENGINE) {
variants.push_back(parent);

Check failure on line 1428 in src/build_vehicle_gui.cpp

View workflow job for this annotation

GitHub Actions / Commit checker

Trailing whitespace

Check failure on line 1428 in src/build_vehicle_gui.cpp

View workflow job for this annotation

GitHub Actions / Commit checker

Invalid tab usage
parent = Engine::Get(parent)->info.variant_id;
}

Check failure on line 1431 in src/build_vehicle_gui.cpp

View workflow job for this annotation

GitHub Actions / Commit checker

Trailing whitespace
}

if (eid == this->sel_engine) sel_id = eid;
}

Expand Down Expand Up @@ -1563,7 +1571,13 @@ struct BuildVehicleWindow : Window {
/* ensure primary engine of variant group is in list after filtering */
std::vector<EngineID> variants;
for (const auto &item : this->eng_list) {
if (item.engine_id != item.variant_id && item.variant_id != INVALID_ENGINE) variants.push_back(item.variant_id);
if (item.engine_id != item.variant_id && item.variant_id != INVALID_ENGINE) {
EngineID parent = item.variant_id;
while (parent != INVALID_ENGINE) {
variants.push_back(parent);
parent = Engine::Get(parent)->info.variant_id;
}
}
}
for (const auto &variant : variants) {
if (std::find(this->eng_list.begin(), this->eng_list.end(), variant) == this->eng_list.end()) {
Expand Down

0 comments on commit 3d7b1f5

Please sign in to comment.