Scheduled dispatch: Add per dispatch slot flags field

Add flag for slot re-use
This commit is contained in:
Jonathan G Rennison
2024-01-28 01:48:54 +00:00
parent dee611f5f3
commit 6c329871f1
11 changed files with 260 additions and 49 deletions

View File

@@ -807,10 +807,14 @@ DateTicksScaled GetScheduledDispatchTime(const DispatchSchedule &ds, DateTicksSc
DateTicksScaled first_slot = -1;
/* Find next available slots */
for (auto current_offset : ds.GetScheduledDispatch()) {
for (const DispatchSlot &slot : ds.GetScheduledDispatch()) {
auto current_offset = slot.offset;
if (current_offset >= dispatch_duration) continue;
if ((int32_t)current_offset <= last_dispatched_offset) {
current_offset += dispatch_duration * ((last_dispatched_offset + dispatch_duration - current_offset) / dispatch_duration);
int32_t threshold = last_dispatched_offset;
if (HasBit(slot.flags, DispatchSlot::SDSF_REUSE_SLOT)) threshold--;
if ((int32_t)current_offset <= threshold) {
current_offset += dispatch_duration * ((threshold + dispatch_duration - current_offset) / dispatch_duration);
}
DateTicksScaled current_departure = begin_time + current_offset;