Fix 42481344: Fix template replacement index not being updated

This commit is contained in:
Jonathan G Rennison
2020-01-19 21:16:09 +00:00
parent c4ec533d44
commit e071da35fa

View File

@@ -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);