Scheduled dispatch: Fix handling of missing last/next dispatch times

In some cases
This commit is contained in:
Jonathan G Rennison
2024-03-13 17:34:17 +00:00
parent f0832fa9b5
commit 4200757db3
4 changed files with 29 additions and 11 deletions

View File

@@ -3192,6 +3192,10 @@ bool EvaluateDispatchSlotConditionalOrder(const Order *order, const Vehicle *v,
offset = last % sched.GetScheduledDispatchDuration();
} else {
StateTicks slot = GetScheduledDispatchTime(sched, state_ticks);
if (slot == INVALID_STATE_TICKS) {
/* No next dispatch */
return OrderConditionCompare(order->GetConditionComparator(), 0, 0);
}
offset = (slot - sched.GetScheduledDispatchStartTick()).base() % sched.GetScheduledDispatchDuration();
}