Add leave early if any/all cargoes fully loaded timetable modes
This commit is contained in:
@@ -2045,6 +2045,25 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
}
|
||||
}
|
||||
}
|
||||
auto may_leave_early = [&]() -> bool {
|
||||
switch (front->current_order.GetLeaveType()) {
|
||||
case OLT_NORMAL:
|
||||
return false;
|
||||
|
||||
case OLT_LEAVE_EARLY:
|
||||
return true;
|
||||
|
||||
case OLT_LEAVE_EARLY_FULL_ANY:
|
||||
return !((front->type == VEH_AIRCRAFT && IsCargoInClass(front->cargo_type, CC_PASSENGERS) && front->cargo_cap > front->cargo.StoredCount()) ||
|
||||
((cargo_not_full | not_yet_in_station_cargo_not_full) != 0 && ((cargo_full | beyond_platform_end_cargo_full) & ~(cargo_not_full | not_yet_in_station_cargo_not_full)) == 0));
|
||||
|
||||
case OLT_LEAVE_EARLY_FULL_ALL:
|
||||
return (cargo_not_full | not_yet_in_station_cargo_not_full) == 0;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
};
|
||||
if (anything_loaded || anything_unloaded) {
|
||||
if (_settings_game.order.gradual_loading) {
|
||||
/* The time it takes to load one 'slice' of cargo or passengers depends
|
||||
@@ -2057,8 +2076,11 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
* load and we're not supposed to wait any longer: stop loading. */
|
||||
if (!anything_unloaded && full_load_amount == 0 && reservation_left == 0 && full_load_cargo_mask == 0 &&
|
||||
(front->current_order_time >= (uint)max<int>(front->current_order.GetTimetabledWait() - front->lateness_counter, 0) ||
|
||||
front->current_order.GetLeaveType() == OLT_LEAVE_EARLY)) {
|
||||
may_leave_early())) {
|
||||
SetBit(front->vehicle_flags, VF_STOP_LOADING);
|
||||
if (may_leave_early()) {
|
||||
front->current_order.SetLeaveType(OLT_LEAVE_EARLY);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLoadUnloadTicks(front, st, new_load_unload_ticks, platform_length_left);
|
||||
@@ -2104,6 +2126,10 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
if (!finished_loading) LinkRefresher::Run(front, true, true);
|
||||
|
||||
SB(front->vehicle_flags, VF_LOADING_FINISHED, 1, finished_loading);
|
||||
|
||||
if (finished_loading && may_leave_early()) {
|
||||
front->current_order.SetLeaveType(OLT_LEAVE_EARLY);
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the loading indicator fill percent and display
|
||||
|
Reference in New Issue
Block a user