From e071da35fad44ee91137de64cc6a7e822e34f7b9 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 19 Jan 2020 21:16:09 +0000 Subject: [PATCH] Fix 42481344: Fix template replacement index not being updated --- src/vehicle_cmd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 6c9e9a24e1..b6ebfc180d 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -1153,11 +1153,14 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3 // Make sure our replacements still point to the correct thing. if (old_ID != template_vehicle->index) { + bool reindex = false; for (TemplateReplacement *tr : TemplateReplacement::Iterate()) { if (tr->GetTemplateVehicleID() == old_ID) { tr->SetTemplate(template_vehicle->index); + reindex = true; } } + if (reindex) ReindexTemplateReplacements(); } InvalidateWindowClassesData(WC_TEMPLATEGUI_MAIN, 0);