diff --git a/src/order_base.h b/src/order_base.h index a96879580d..d39f572c05 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -246,7 +246,7 @@ public: /** * Gets the destination of this order. - * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION) || IsType(OT_RELEASE_SLOT) || IsType(OT_COUNTER) || IsType(OT_LABEL). + * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION) || IsType(OT_SLOT) || IsType(OT_COUNTER) || IsType(OT_LABEL). * @return the destination of the order. */ inline DestinationID GetDestination() const { return this->dest; } @@ -254,7 +254,7 @@ public: /** * Sets the destination of this order. * @param destination the new destination of the order. - * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION) || IsType(OT_RELEASE_SLOT) || IsType(OT_COUNTER) || IsType(OT_LABEL). + * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION) || IsType(OT_SLOT) || IsType(OT_COUNTER) || IsType(OT_LABEL). */ inline void SetDestination(DestinationID destination) { this->dest = destination; } @@ -467,7 +467,7 @@ public: * explicitly set (but travel_time is actually unused for conditionals). */ /* Does this order not have any associated travel or wait times */ - inline bool HasNoTimetableTimes() const { return this->IsType(OT_COUNTER) || this->IsType(OT_RELEASE_SLOT) || this->IsType(OT_LABEL); } + inline bool HasNoTimetableTimes() const { return this->IsType(OT_COUNTER) || this->IsType(OT_SLOT) || this->IsType(OT_LABEL); } /** Does this order have an explicit wait time set? */ inline bool IsWaitTimetabled() const @@ -635,6 +635,11 @@ public: } } + inline OrderSlotSubType GetSlotSubType() const + { + return (OrderSlotSubType)GB(this->flags, 0, 8); + } + inline OrderLabelSubType GetLabelSubType() const { return (OrderLabelSubType)GB(this->flags, 0, 8); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 3ead40b8d9..1f9f31f44e 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -242,8 +242,9 @@ void Order::MakeLoadingAdvance(StationID destination) void Order::MakeReleaseSlot() { - this->type = OT_RELEASE_SLOT; + this->type = OT_SLOT; this->dest = INVALID_TRACE_RESTRICT_SLOT_ID; + this->flags = OSST_RELEASE; } void Order::MakeChangeCounter() @@ -705,7 +706,7 @@ CargoMaskedStationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, Ca }); if (invalid) return CargoMaskedStationIDStack(cargo_mask, INVALID_STATION); } - } while (next->IsType(OT_GOTO_DEPOT) || next->IsType(OT_RELEASE_SLOT) || next->IsType(OT_COUNTER) || next->IsType(OT_DUMMY) || next->IsType(OT_LABEL) + } while (next->IsType(OT_GOTO_DEPOT) || next->IsType(OT_SLOT) || next->IsType(OT_COUNTER) || next->IsType(OT_DUMMY) || next->IsType(OT_LABEL) || (next->IsBaseStationOrder() && next->GetDestination() == v->last_station_visited)); return CargoMaskedStationIDStack(cargo_mask, next->GetDestination()); @@ -1268,12 +1269,19 @@ CommandCost CmdInsertOrderIntl(DoCommandFlag flags, Vehicle *v, VehicleOrderID s break; } - case OT_RELEASE_SLOT: { + case OT_SLOT: { TraceRestrictSlotID data = new_order.GetDestination(); if (data != INVALID_TRACE_RESTRICT_SLOT_ID) { const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(data); if (slot == nullptr || slot->vehicle_type != v->type) return CMD_ERROR; } + switch (new_order.GetSlotSubType()) { + case OSST_RELEASE: + break; + + default: + return CMD_ERROR; + } break; } @@ -1839,7 +1847,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uin if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_VALUE_2 && mof != MOF_COND_VALUE_3 && mof != MOF_COND_DESTINATION && mof != MOF_COND_STATION_ID) return CMD_ERROR; break; - case OT_RELEASE_SLOT: + case OT_SLOT: if (mof != MOF_SLOT) return CMD_ERROR; break; @@ -3239,10 +3247,14 @@ VehicleOrderID AdvanceOrderIndexDeferred(const Vehicle *v, VehicleOrderID index) return index; } - case OT_RELEASE_SLOT: + case OT_SLOT: if (TraceRestrictSlot::IsValidID(order->GetDestination())) { - include(_pco_deferred_slot_releases, order->GetDestination()); - container_unordered_remove(_pco_deferred_slot_acquires, order->GetDestination()); + switch (order->GetSlotSubType()) { + case OSST_RELEASE: + include(_pco_deferred_slot_releases, order->GetDestination()); + container_unordered_remove(_pco_deferred_slot_acquires, order->GetDestination()); + break; + } } break; @@ -3414,11 +3426,17 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool break; } - case OT_RELEASE_SLOT: + case OT_SLOT: assert(!pbs_look_ahead); if (order->GetDestination() != INVALID_TRACE_RESTRICT_SLOT_ID) { TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(order->GetDestination()); - if (slot != nullptr) slot->Vacate(v->index); + if (slot != nullptr) { + switch (order->GetSlotSubType()) { + case OSST_RELEASE: + slot->Vacate(v->index); + break; + } + } } UpdateVehicleTimetable(v, true); v->IncrementRealOrderIndex(); @@ -3718,7 +3736,7 @@ const char *GetOrderTypeName(OrderType order_type) "OT_IMPLICIT", "OT_WAITING", "OT_LOADING_ADVANCE", - "OT_RELEASE_SLOT", + "OT_SLOT", "OT_COUNTER", "OT_LABEL", }; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 64bfcd5946..589c0c476e 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1169,8 +1169,16 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int break; } - case OT_RELEASE_SLOT: - SetDParam(0, STR_ORDER_RELEASE_SLOT); + case OT_SLOT: + switch (order->GetSlotSubType()) { + case OSST_RELEASE: + SetDParam(0, STR_ORDER_RELEASE_SLOT); + break; + + default: + NOT_REACHED(); + break; + } if (order->GetDestination() == INVALID_TRACE_RESTRICT_SLOT_ID) { SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED); } else { @@ -2296,7 +2304,7 @@ public: break; } - case OT_RELEASE_SLOT: { + case OT_SLOT: { if (row_sel != nullptr) { row_sel->SetDisplayedPlane(DP_ROW_SLOT); } else { @@ -2612,7 +2620,7 @@ public: VehicleOrderID sel = this->OrderGetSel(); const Order *order = this->vehicle->GetOrder(sel); - if (order != nullptr && order->IsType(OT_RELEASE_SLOT)) { + if (order != nullptr && order->IsType(OT_SLOT)) { TraceRestrictSlotID value = order->GetDestination(); SetDParam(0, value); } diff --git a/src/order_type.h b/src/order_type.h index c75e273f0c..1f5967f2e9 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -46,12 +46,16 @@ enum OrderType : byte { OT_IMPLICIT = 8, OT_WAITING = 9, OT_LOADING_ADVANCE = 10, - OT_RELEASE_SLOT = 11, + OT_SLOT = 11, OT_COUNTER = 12, OT_LABEL = 13, OT_END }; +enum OrderSlotSubType : byte { + OSST_RELEASE = 0, +}; + enum OrderLabelSubType : byte { OLST_TEXT = 0, OLST_DEPARTURES_VIA = 1, diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index d95ba9c980..8df66a176d 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -713,8 +713,8 @@ std::vector PopulateSeparationState(const Vehicle *v_start) // Do not try to separate vehicles on depot service or halt orders separation_valid = false; } - if (order->IsType(OT_RELEASE_SLOT) || order->IsType(OT_COUNTER) || order->IsType(OT_DUMMY) || order->IsType(OT_LABEL)) { - // Do not try to separate vehicles on release slot, change counter, or invalid orders + if (order->IsType(OT_SLOT) || order->IsType(OT_COUNTER) || order->IsType(OT_DUMMY) || order->IsType(OT_LABEL)) { + // Do not try to separate vehicles on slot, change counter, or invalid orders separation_valid = false; } int order_ticks; diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index c5f1e6c7e1..3bca02dbac 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -2778,7 +2778,7 @@ void TraceRestrictRemoveSlotID(TraceRestrictSlotID index) o->GetXDataRef() = INVALID_TRACE_RESTRICT_SLOT_ID; changed_order = true; } - if (o->IsType(OT_RELEASE_SLOT) && o->GetDestination() == index) { + if (o->IsType(OT_SLOT) && o->GetDestination() == index) { o->SetDestination(INVALID_TRACE_RESTRICT_SLOT_ID); changed_order = true; } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a2fc42ed69..bdc16b379a 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -4435,7 +4435,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir, * the destination but instead to the next one if service isn't needed. */ CheckIfTrainNeedsService(v); if (v->current_order.IsType(OT_DUMMY) || v->current_order.IsType(OT_CONDITIONAL) || v->current_order.IsType(OT_GOTO_DEPOT) || - v->current_order.IsType(OT_RELEASE_SLOT) || v->current_order.IsType(OT_COUNTER) || v->current_order.IsType(OT_LABEL)) { + v->current_order.IsType(OT_SLOT) || v->current_order.IsType(OT_COUNTER) || v->current_order.IsType(OT_LABEL)) { ProcessOrders(v); } } @@ -6548,7 +6548,7 @@ static bool TrainLocoHandler(Train *v, bool mode) /* exit if train is stopped */ if ((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) return true; - bool valid_order = !v->current_order.IsType(OT_NOTHING) && v->current_order.GetType() != OT_CONDITIONAL && !v->current_order.IsType(OT_RELEASE_SLOT) && !v->current_order.IsType(OT_COUNTER) && !v->current_order.IsType(OT_LABEL); + bool valid_order = !v->current_order.IsType(OT_NOTHING) && v->current_order.GetType() != OT_CONDITIONAL && !v->current_order.IsType(OT_SLOT) && !v->current_order.IsType(OT_COUNTER) && !v->current_order.IsType(OT_LABEL); if (ProcessOrders(v) && CheckReverseTrain(v)) { v->wait_counter = 0; v->cur_speed = 0;