@@ -330,26 +330,27 @@ static CommandCost BuildReplacementVehic
/* Does it need to be refitted */
CargoID refit_cargo = GetNewCargoTypeForReplace(old_veh, e, part_of_chain);
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) {
/* Orders contained a refit order that is incompatible with the new vehicle. */
SetDParam(1, STR_ERROR_AUTOREPLACE_INCOMPATIBLE_REFIT);
SetDParam(2, order_id + 1); // 1-based indexing for display
} else {
/* Current cargo is incompatible with the new vehicle. */
SetDParam(1, STR_ERROR_AUTOREPLACE_INCOMPATIBLE_CARGO);
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();
/* Build the new vehicle */
VehicleID new_veh_id;
std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID);
Status change: