Rename OT_RELEASE_SLOT to OT_SLOT, use a subtype field
This commit is contained in:
@@ -246,7 +246,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the destination of this order.
|
* 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.
|
* @return the destination of the order.
|
||||||
*/
|
*/
|
||||||
inline DestinationID GetDestination() const { return this->dest; }
|
inline DestinationID GetDestination() const { return this->dest; }
|
||||||
@@ -254,7 +254,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Sets the destination of this order.
|
* Sets the destination of this order.
|
||||||
* @param destination the new destination of the 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; }
|
inline void SetDestination(DestinationID destination) { this->dest = destination; }
|
||||||
|
|
||||||
@@ -467,7 +467,7 @@ public:
|
|||||||
* explicitly set (but travel_time is actually unused for conditionals). */
|
* explicitly set (but travel_time is actually unused for conditionals). */
|
||||||
|
|
||||||
/* Does this order not have any associated travel or wait times */
|
/* 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? */
|
/** Does this order have an explicit wait time set? */
|
||||||
inline bool IsWaitTimetabled() const
|
inline bool IsWaitTimetabled() const
|
||||||
@@ -635,6 +635,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline OrderSlotSubType GetSlotSubType() const
|
||||||
|
{
|
||||||
|
return (OrderSlotSubType)GB(this->flags, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
inline OrderLabelSubType GetLabelSubType() const
|
inline OrderLabelSubType GetLabelSubType() const
|
||||||
{
|
{
|
||||||
return (OrderLabelSubType)GB(this->flags, 0, 8);
|
return (OrderLabelSubType)GB(this->flags, 0, 8);
|
||||||
|
@@ -242,8 +242,9 @@ void Order::MakeLoadingAdvance(StationID destination)
|
|||||||
|
|
||||||
void Order::MakeReleaseSlot()
|
void Order::MakeReleaseSlot()
|
||||||
{
|
{
|
||||||
this->type = OT_RELEASE_SLOT;
|
this->type = OT_SLOT;
|
||||||
this->dest = INVALID_TRACE_RESTRICT_SLOT_ID;
|
this->dest = INVALID_TRACE_RESTRICT_SLOT_ID;
|
||||||
|
this->flags = OSST_RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Order::MakeChangeCounter()
|
void Order::MakeChangeCounter()
|
||||||
@@ -705,7 +706,7 @@ CargoMaskedStationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, Ca
|
|||||||
});
|
});
|
||||||
if (invalid) return CargoMaskedStationIDStack(cargo_mask, INVALID_STATION);
|
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));
|
|| (next->IsBaseStationOrder() && next->GetDestination() == v->last_station_visited));
|
||||||
|
|
||||||
return CargoMaskedStationIDStack(cargo_mask, next->GetDestination());
|
return CargoMaskedStationIDStack(cargo_mask, next->GetDestination());
|
||||||
@@ -1268,12 +1269,19 @@ CommandCost CmdInsertOrderIntl(DoCommandFlag flags, Vehicle *v, VehicleOrderID s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_RELEASE_SLOT: {
|
case OT_SLOT: {
|
||||||
TraceRestrictSlotID data = new_order.GetDestination();
|
TraceRestrictSlotID data = new_order.GetDestination();
|
||||||
if (data != INVALID_TRACE_RESTRICT_SLOT_ID) {
|
if (data != INVALID_TRACE_RESTRICT_SLOT_ID) {
|
||||||
const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(data);
|
const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(data);
|
||||||
if (slot == nullptr || slot->vehicle_type != v->type) return CMD_ERROR;
|
if (slot == nullptr || slot->vehicle_type != v->type) return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
switch (new_order.GetSlotSubType()) {
|
||||||
|
case OSST_RELEASE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
break;
|
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;
|
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;
|
break;
|
||||||
|
|
||||||
case OT_RELEASE_SLOT:
|
case OT_SLOT:
|
||||||
if (mof != MOF_SLOT) return CMD_ERROR;
|
if (mof != MOF_SLOT) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -3239,10 +3247,14 @@ VehicleOrderID AdvanceOrderIndexDeferred(const Vehicle *v, VehicleOrderID index)
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_RELEASE_SLOT:
|
case OT_SLOT:
|
||||||
if (TraceRestrictSlot::IsValidID(order->GetDestination())) {
|
if (TraceRestrictSlot::IsValidID(order->GetDestination())) {
|
||||||
include(_pco_deferred_slot_releases, order->GetDestination());
|
switch (order->GetSlotSubType()) {
|
||||||
container_unordered_remove(_pco_deferred_slot_acquires, order->GetDestination());
|
case OSST_RELEASE:
|
||||||
|
include(_pco_deferred_slot_releases, order->GetDestination());
|
||||||
|
container_unordered_remove(_pco_deferred_slot_acquires, order->GetDestination());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -3414,11 +3426,17 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_RELEASE_SLOT:
|
case OT_SLOT:
|
||||||
assert(!pbs_look_ahead);
|
assert(!pbs_look_ahead);
|
||||||
if (order->GetDestination() != INVALID_TRACE_RESTRICT_SLOT_ID) {
|
if (order->GetDestination() != INVALID_TRACE_RESTRICT_SLOT_ID) {
|
||||||
TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(order->GetDestination());
|
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);
|
UpdateVehicleTimetable(v, true);
|
||||||
v->IncrementRealOrderIndex();
|
v->IncrementRealOrderIndex();
|
||||||
@@ -3718,7 +3736,7 @@ const char *GetOrderTypeName(OrderType order_type)
|
|||||||
"OT_IMPLICIT",
|
"OT_IMPLICIT",
|
||||||
"OT_WAITING",
|
"OT_WAITING",
|
||||||
"OT_LOADING_ADVANCE",
|
"OT_LOADING_ADVANCE",
|
||||||
"OT_RELEASE_SLOT",
|
"OT_SLOT",
|
||||||
"OT_COUNTER",
|
"OT_COUNTER",
|
||||||
"OT_LABEL",
|
"OT_LABEL",
|
||||||
};
|
};
|
||||||
|
@@ -1169,8 +1169,16 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_RELEASE_SLOT:
|
case OT_SLOT:
|
||||||
SetDParam(0, STR_ORDER_RELEASE_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) {
|
if (order->GetDestination() == INVALID_TRACE_RESTRICT_SLOT_ID) {
|
||||||
SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED);
|
SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED);
|
||||||
} else {
|
} else {
|
||||||
@@ -2296,7 +2304,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_RELEASE_SLOT: {
|
case OT_SLOT: {
|
||||||
if (row_sel != nullptr) {
|
if (row_sel != nullptr) {
|
||||||
row_sel->SetDisplayedPlane(DP_ROW_SLOT);
|
row_sel->SetDisplayedPlane(DP_ROW_SLOT);
|
||||||
} else {
|
} else {
|
||||||
@@ -2612,7 +2620,7 @@ public:
|
|||||||
VehicleOrderID sel = this->OrderGetSel();
|
VehicleOrderID sel = this->OrderGetSel();
|
||||||
const Order *order = this->vehicle->GetOrder(sel);
|
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();
|
TraceRestrictSlotID value = order->GetDestination();
|
||||||
SetDParam(0, value);
|
SetDParam(0, value);
|
||||||
}
|
}
|
||||||
|
@@ -46,12 +46,16 @@ enum OrderType : byte {
|
|||||||
OT_IMPLICIT = 8,
|
OT_IMPLICIT = 8,
|
||||||
OT_WAITING = 9,
|
OT_WAITING = 9,
|
||||||
OT_LOADING_ADVANCE = 10,
|
OT_LOADING_ADVANCE = 10,
|
||||||
OT_RELEASE_SLOT = 11,
|
OT_SLOT = 11,
|
||||||
OT_COUNTER = 12,
|
OT_COUNTER = 12,
|
||||||
OT_LABEL = 13,
|
OT_LABEL = 13,
|
||||||
OT_END
|
OT_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum OrderSlotSubType : byte {
|
||||||
|
OSST_RELEASE = 0,
|
||||||
|
};
|
||||||
|
|
||||||
enum OrderLabelSubType : byte {
|
enum OrderLabelSubType : byte {
|
||||||
OLST_TEXT = 0,
|
OLST_TEXT = 0,
|
||||||
OLST_DEPARTURES_VIA = 1,
|
OLST_DEPARTURES_VIA = 1,
|
||||||
|
@@ -713,8 +713,8 @@ std::vector<TimetableProgress> PopulateSeparationState(const Vehicle *v_start)
|
|||||||
// Do not try to separate vehicles on depot service or halt orders
|
// Do not try to separate vehicles on depot service or halt orders
|
||||||
separation_valid = false;
|
separation_valid = false;
|
||||||
}
|
}
|
||||||
if (order->IsType(OT_RELEASE_SLOT) || order->IsType(OT_COUNTER) || order->IsType(OT_DUMMY) || order->IsType(OT_LABEL)) {
|
if (order->IsType(OT_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
|
// Do not try to separate vehicles on slot, change counter, or invalid orders
|
||||||
separation_valid = false;
|
separation_valid = false;
|
||||||
}
|
}
|
||||||
int order_ticks;
|
int order_ticks;
|
||||||
|
@@ -2778,7 +2778,7 @@ void TraceRestrictRemoveSlotID(TraceRestrictSlotID index)
|
|||||||
o->GetXDataRef() = INVALID_TRACE_RESTRICT_SLOT_ID;
|
o->GetXDataRef() = INVALID_TRACE_RESTRICT_SLOT_ID;
|
||||||
changed_order = true;
|
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);
|
o->SetDestination(INVALID_TRACE_RESTRICT_SLOT_ID);
|
||||||
changed_order = true;
|
changed_order = true;
|
||||||
}
|
}
|
||||||
|
@@ -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. */
|
* the destination but instead to the next one if service isn't needed. */
|
||||||
CheckIfTrainNeedsService(v);
|
CheckIfTrainNeedsService(v);
|
||||||
if (v->current_order.IsType(OT_DUMMY) || v->current_order.IsType(OT_CONDITIONAL) || v->current_order.IsType(OT_GOTO_DEPOT) ||
|
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);
|
ProcessOrders(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6548,7 +6548,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
|
|||||||
/* exit if train is stopped */
|
/* exit if train is stopped */
|
||||||
if ((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) return true;
|
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)) {
|
if (ProcessOrders(v) && CheckReverseTrain(v)) {
|
||||||
v->wait_counter = 0;
|
v->wait_counter = 0;
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
|
Reference in New Issue
Block a user