Merge branch 'template_train_replacement' into jgrpp

This commit is contained in:
Jonathan G Rennison
2018-01-30 18:58:34 +00:00
3 changed files with 39 additions and 17 deletions

View File

@@ -1175,6 +1175,16 @@ void CallVehicleTicks()
it->first->vehstatus |= VS_STOPPED;
CommandCost res = DoCommand(t->tile, t->index, stayInDepot ? 1 : 0, DC_EXEC, CMD_TEMPLATE_REPLACE_VEHICLE);
if (res.Succeeded()) {
VehicleID t_new = _new_vehicle_id;
t = Train::From(Vehicle::Get(t_new));
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);
SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->settings.engine_renew_money));
if (res2.Succeeded() || res.GetCost() == 0) res.AddCost(res2);
}
if (!IsLocalCompany()) continue;
if (res.Succeeded()) {