Add conditional order to test if last/next dispatch slot is first/last

This commit is contained in:
Jonathan G Rennison
2022-07-03 13:59:27 +01:00
parent 116ddf4b35
commit 4e8a8a5e0a
9 changed files with 235 additions and 6 deletions

View File

@@ -393,6 +393,16 @@ CommandCost CmdScheduledDispatchRemoveSchedule(TileIndex tile, DoCommandFlag fla
} else if (idx > (int)schedule_index) {
o->SetDispatchScheduleIndex(idx - 1);
}
if (o->IsType(OT_CONDITIONAL) && o->GetConditionVariable() == OCV_DISPATCH_SLOT) {
uint16 dispatch_slot = GB(o->GetXData(), 0, 16);
if (dispatch_slot == UINT16_MAX) {
/* do nothing */
} else if (dispatch_slot == schedule_index) {
SB(o->GetXDataRef(), 0, 16, UINT16_MAX);
} else if (dispatch_slot > schedule_index) {
SB(o->GetXDataRef(), 0, 16, (uint16)(dispatch_slot - 1));
}
}
}
SchdispatchInvalidateWindows(v);
}