diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 36e2556b5f..00b665d84e 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -810,6 +810,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1 } if (cost.Succeeded() && nothing_to_do) cost = CommandCost(STR_ERROR_AUTOREPLACE_NOTHING_TO_DO); + cost.SetResultData(v->index); return cost; } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 22401a740b..08228bcc01 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1647,6 +1647,9 @@ void CallVehicleTicks() const Company *c = Company::Get(_current_company); SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, (Money)c->settings.engine_renew_money)); CommandCost res2 = DoCommand(0, t_new, 1, DC_EXEC, CMD_AUTOREPLACE_VEHICLE); + if (res2.HasResultData()) { + t = Train::Get(res2.GetResultData()); + } SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->settings.engine_renew_money)); if (res2.Succeeded() || res.GetCost() == 0) res.AddCost(res2); }