Fix crash in template replacement failure news if autorenew succeeds
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user