Conditional orders: Add slot acquire modes to train in slot conditional
This commit is contained in:
@@ -1110,7 +1110,19 @@ CommandCost CmdInsertOrderIntl(DoCommandFlag flags, Vehicle *v, VehicleOrderID s
|
||||
if (v->type != VEH_TRAIN) return CMD_ERROR;
|
||||
TraceRestrictSlotID slot = new_order.GetXData();
|
||||
if (slot != INVALID_TRACE_RESTRICT_SLOT_ID && !TraceRestrictSlot::IsValidID(slot)) return CMD_ERROR;
|
||||
if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) return CMD_ERROR;
|
||||
switch (occ) {
|
||||
case OCC_IS_TRUE:
|
||||
case OCC_IS_FALSE:
|
||||
break;
|
||||
|
||||
case OCC_EQUALS:
|
||||
case OCC_NOT_EQUALS:
|
||||
if (new_order.GetConditionVariable() != OCV_TRAIN_IN_SLOT) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CMD_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1677,10 +1689,13 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
case OCV_CARGO_ACCEPTANCE:
|
||||
case OCV_CARGO_WAITING:
|
||||
case OCV_SLOT_OCCUPANCY:
|
||||
case OCV_TRAIN_IN_SLOT:
|
||||
if (data != OCC_IS_TRUE && data != OCC_IS_FALSE) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
case OCV_TRAIN_IN_SLOT:
|
||||
if (data != OCC_IS_TRUE && data != OCC_IS_FALSE && data != OCC_EQUALS && data != OCC_NOT_EQUALS) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (data == OCC_IS_TRUE || data == OCC_IS_FALSE) return CMD_ERROR;
|
||||
break;
|
||||
@@ -2584,9 +2599,10 @@ static StationID GetNextRealStation(const Vehicle *v, const Order *order, int co
|
||||
* Process a conditional order and determine the next order.
|
||||
* @param order the order the vehicle currently has
|
||||
* @param v the vehicle to update
|
||||
* @param dry_run whether this is a dry-run, so do not execute side-effects
|
||||
* @return index of next order to jump to, or INVALID_VEH_ORDER_ID to use the next order
|
||||
*/
|
||||
VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
|
||||
VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, bool dry_run)
|
||||
{
|
||||
if (order->GetType() != OT_CONDITIONAL) return INVALID_VEH_ORDER_ID;
|
||||
|
||||
@@ -2631,8 +2647,15 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
|
||||
break;
|
||||
}
|
||||
case OCV_TRAIN_IN_SLOT: {
|
||||
const TraceRestrictSlot* slot = TraceRestrictSlot::GetIfValid(order->GetXData());
|
||||
if (slot != nullptr) skip_order = OrderConditionCompare(occ, slot->IsOccupant(v->index), value);
|
||||
TraceRestrictSlot* slot = TraceRestrictSlot::GetIfValid(order->GetXData());
|
||||
bool occupant = slot->IsOccupant(v->index);
|
||||
if (occ == OCC_EQUALS || occ == OCC_NOT_EQUALS) {
|
||||
if (!occupant && !dry_run) {
|
||||
occupant = slot->Occupy(v->index);
|
||||
}
|
||||
occ = (occ == OCC_EQUALS) ? OCC_IS_TRUE : OCC_IS_FALSE;
|
||||
}
|
||||
if (slot != nullptr) skip_order = OrderConditionCompare(occ, occupant, value);
|
||||
break;
|
||||
}
|
||||
case OCV_FREE_PLATFORMS: {
|
||||
|
Reference in New Issue
Block a user