From d55ba23a870153b2ed890a67f64845c847f3cadc Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 28 Jun 2023 19:24:24 +0100 Subject: [PATCH] Fix dual pane purchase window with mixed wagon/loco variant trees Use top-level variant engine for the loco/wagon categorisation See: #558 --- src/build_vehicle_gui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 265e1b32c4..0c29d4c33b 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -2607,7 +2607,12 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { if (!FilterSingleEngine(state, eid)) continue; - if ((rvi->railveh_type == RAILVEH_WAGON) != wagon) continue; + const Engine *top_engine = engine; + for (int depth = 0; depth < 16; depth++) { + if (top_engine->info.variant_id == INVALID_ENGINE) break; + top_engine = Engine::Get(top_engine->info.variant_id); + } + if ((top_engine->u.rail.railveh_type == RAILVEH_WAGON) != wagon) continue; /* Filter by name or NewGRF extra text */ if (!FilterByText(state, engine)) continue;