Fix crash in template replacement failure news if autorenew succeeds

pull/532/head
Jonathan G Rennison 12 months ago
parent 13183d3f13
commit 6880cf24a0

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

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

Loading…
Cancel
Save