/* Aircraft too old? Sell it. */
if (AIVehicle.GetAgeLeft(i) < 365) {
/* Send the vehicle to depot if we didn't do so yet */
if (!vehicle_to_depot.rawin(i) || vehicle_to_depot.rawget(i) != true) {
AILog.Info("Sending " + AIVehicle.GetName(i) + " to hangar to be sold, due to its old age.");
AIVehicle.SendVehicleToDepot(i);
vehicle_to_depot.rawset(i, true);
}
}
/* Sell it once it really is in the depot */
if (vehicle_to_depot.rawin(i) && vehicle_to_depot.rawget(i) == true && AIVehicle.IsStoppedInDepot(i)) {
AILog.Info("Selling " + AIVehicle.GetName(i) + " as it finally is in a hangar. (From " + AIStation.GetName(AIStation.GetStationID(AIOrder.GetOrderDestination(i, 0))) + " to " + AIStation.GetName(AIStation.GetStationID(AIOrder.GetOrderDestination(i, 1))) + ")");
local list2 = AIVehicleList_Station(AIStation.GetStationID(AIOrder.GetOrderDestination(i, 0)));
list2.Valuate(AIVehicle.GetVehicleType);
list2.KeepValue(AIVehicle.VT_AIR);
/* Last vehicle on this route? Consider increasing the minimum distance for the next routes. */
if (list2.Count() == 1) {
if (AIVehicle.GetProfitLastYear(i) < 10000 && AIVehicle.GetProfitThisYear(i) < 10000) {
AILog.Warning("Last vehicle on this route!");
local dist = this.distance_of_route.rawget(i);
if (min_air_distance < max_air_distance - dist) {
min_air_distance = dist;
}
}
}
if (AIVehicle.SellVehicle(i)) {
vehicle_to_depot.rawdelete(i);
}
}
}