function sendLowProfitVehiclesToDepot() {
local roadVehicleList = AIVehicleList();
roadVehicleList.Valuate(AIVehicle.GetVehicleType);
roadVehicleList.KeepValue(AIVehicle.VT_ROAD);
if(LuDiAIAfterFix.MAX_TOWN_VEHICLES - 50 > roadVehicleList.Count()) {
return;
}
if((AIDate.GetCurrentDate() - m_lastVehicleRemoved) > 60) {
local vehicleList = AIVehicleList_Depot(m_depotTile);
vehicleList.Valuate(AIVehicle.GetAge);
vehicleList.KeepAboveValue(2 * 365);
for (local vehicle = vehicleList.Begin(); vehicleList.HasNext(); vehicle = vehicleList.Next()) {
AIController.Sleep(1);
local cargoId = Utils.getCargoId(m_cargoClass);
local cargoWaiting = AIStation.GetCargoWaiting(AIStation.GetStationID(m_stationTo), cargoId) +
AIStation.GetCargoWaiting(AIStation.GetStationID(m_stationFrom), cargoId);
if ((cargoWaiting < 150) ||
(AIVehicle.GetProfitLastYear(vehicle) < (highestProfitLastYear() / 6))) {
if(sendVehicleToDepot(vehicle)) {
m_sentToDepotList.AddItem(vehicle, 0);
}
}
}
}
}