# HG changeset patch # User Peter Nelson # Date 2024-02-07 08:51:03 # Node ID bc027124702725fa162f25d31408df05a8251023 # Parent 77f6be3a982ce9b9e26ab627fe239c59168c21ed Fix #12024: Autoreplace failed news message for trains must go to lead engine. (#12025) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -333,7 +333,8 @@ static CommandCost BuildReplacementVehic if (!IsValidCargoID(refit_cargo)) { if (!IsLocalCompany()) return CommandCost(); - SetDParam(0, old_veh->index); + VehicleID old_veh_id = (old_veh->type == VEH_TRAIN) ? Train::From(old_veh)->First()->index : old_veh->index; + SetDParam(0, old_veh_id); int order_id = GetIncompatibleRefitOrderIdForAutoreplace(old_veh, e); if (order_id != -1) { @@ -346,7 +347,7 @@ static CommandCost BuildReplacementVehic SetDParam(2, CargoSpec::Get(old_veh->cargo_type)->name); } - AddVehicleAdviceNewsItem(STR_NEWS_VEHICLE_AUTORENEW_FAILED, old_veh->index); + AddVehicleAdviceNewsItem(STR_NEWS_VEHICLE_AUTORENEW_FAILED, old_veh_id); return CommandCost(); }