Scheduled dispatch: Fix handling of missing last/next dispatch times
In some cases
This commit is contained in:
@@ -508,7 +508,8 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
||||
}
|
||||
|
||||
bool have_last = false;
|
||||
if (ds.GetScheduledDispatchLastDispatch() % ds.GetScheduledDispatchDuration() == slot->offset) {
|
||||
int32_t last_dispatch = ds.GetScheduledDispatchLastDispatch();
|
||||
if (last_dispatch != INVALID_SCHEDULED_DISPATCH_OFFSET && (last_dispatch % ds.GetScheduledDispatchDuration() == slot->offset)) {
|
||||
_temp_special_strings[0] += '\n';
|
||||
_temp_special_strings[0] += GetString(STR_SCHDISPATCH_SLOT_TOOLTIP_LAST);
|
||||
if (_settings_time.time_in_minutes) {
|
||||
@@ -521,7 +522,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
||||
have_last = true;
|
||||
}
|
||||
StateTicks next_slot = GetScheduledDispatchTime(ds, _state_ticks);
|
||||
if ((next_slot - ds.GetScheduledDispatchStartTick()).AsTicks() % ds.GetScheduledDispatchDuration() == slot->offset) {
|
||||
if (next_slot != INVALID_STATE_TICKS && ((next_slot - ds.GetScheduledDispatchStartTick()).AsTicks() % ds.GetScheduledDispatchDuration() == slot->offset)) {
|
||||
if (!have_last) _temp_special_strings[0] += '\n';
|
||||
_temp_special_strings[0] += GetString(STR_SCHDISPATCH_SLOT_TOOLTIP_NEXT);
|
||||
if (_settings_time.time_in_minutes) {
|
||||
@@ -631,9 +632,14 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
||||
const StateTicks end_tick = ds.GetScheduledDispatchStartTick() + ds.GetScheduledDispatchDuration();
|
||||
|
||||
StateTicks slot = GetScheduledDispatchTime(ds, _state_ticks);
|
||||
int32_t next_offset = (slot - ds.GetScheduledDispatchStartTick()).AsTicks() % ds.GetScheduledDispatchDuration();
|
||||
int32_t next_offset = (slot != INVALID_STATE_TICKS) ? (slot - ds.GetScheduledDispatchStartTick()).AsTicks() % ds.GetScheduledDispatchDuration() : INT32_MIN;
|
||||
|
||||
int32_t last_dispatch = ds.GetScheduledDispatchLastDispatch() % ds.GetScheduledDispatchDuration();
|
||||
int32_t last_dispatch;
|
||||
if (ds.GetScheduledDispatchLastDispatch() != INVALID_SCHEDULED_DISPATCH_OFFSET) {
|
||||
last_dispatch = ds.GetScheduledDispatchLastDispatch() % ds.GetScheduledDispatchDuration();
|
||||
} else {
|
||||
last_dispatch = INT32_MIN;
|
||||
}
|
||||
|
||||
for (int y = r.top + 1; num < maxval; y += this->resize.step_height) { /* Draw the rows */
|
||||
for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) {
|
||||
@@ -829,9 +835,11 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
||||
}
|
||||
|
||||
const StateTicks next_departure = GetScheduledDispatchTime(ds, _state_ticks);
|
||||
set_next_departure_update(next_departure + ds.GetScheduledDispatchDelay());
|
||||
SetDParam(0, next_departure);
|
||||
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_NEXT_AVAILABLE_DEPARTURE);
|
||||
if (next_departure != INVALID_STATE_TICKS) {
|
||||
set_next_departure_update(next_departure + ds.GetScheduledDispatchDelay());
|
||||
SetDParam(0, next_departure);
|
||||
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_NEXT_AVAILABLE_DEPARTURE);
|
||||
}
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
departure_time_warnings(next_departure);
|
||||
|
Reference in New Issue
Block a user