Changeset - r27982:31e8aef007ea
[Not reviewed]
master
0 2 0
merni-ns - 14 months ago 2023-10-03 12:43:15
66267867+merni-ns@users.noreply.github.com
Fix #10763, Fix #11168: Display variant groups that consist only of unavailable sub-groups (#11342)
2 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -179,7 +179,13 @@ class ReplaceVehicleWindow : public Wind
 
			if (side == 1 && eid == this->sel_engine[0]) flags |= EngineDisplayFlags::Shaded;
 
			list.emplace_back(eid, e->info.variant_id, flags, 0);
 

	
 
			if (side == 1 && e->info.variant_id != INVALID_ENGINE) variants.push_back(e->info.variant_id);
 
			if (side == 1) {
 
				EngineID parent = e->info.variant_id;
 
				while (parent != INVALID_ENGINE) {
 
					variants.push_back(parent);
 
					parent = Engine::Get(parent)->info.variant_id;
 
				}
 
			}
 
			if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
 
		}
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1422,7 +1422,14 @@ 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 != INVALID_ENGINE) variants.push_back(e->info.variant_id);
 

	
 
			/* Add all parent variants of this engine to the variant list */
 
			EngineID parent = e->info.variant_id;
 
			while (parent != INVALID_ENGINE) {
 
				variants.push_back(parent);
 
				parent = Engine::Get(parent)->info.variant_id;
 
			}
 

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

	
 
@@ -1563,8 +1570,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);
 
			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()) {
 
				const Engine *e = Engine::Get(variant);
0 comments (0 inline, 0 general)