Add next order condition variable.
This commit is contained in:
@@ -2385,6 +2385,7 @@ STR_TRACE_RESTRICT_CONDITIONAL_ENDIF :End if
|
|||||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH :train length
|
STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH :train length
|
||||||
STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED :max speed
|
STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED :max speed
|
||||||
STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER :current order
|
STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER :current order
|
||||||
|
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER :next order
|
||||||
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED :undefined
|
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED :undefined
|
||||||
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER :{STRING} {STRING} {STRING} {COMMA} then
|
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER :{STRING} {STRING} {STRING} {COMMA} then
|
||||||
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED :{STRING} {STRING} {STRING} {VELOCITY} then
|
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED :{STRING} {STRING} {STRING} {VELOCITY} then
|
||||||
|
@@ -218,6 +218,20 @@ void TraceRestrictProgram::Execute(const Train* v, TraceRestrictProgramResult& o
|
|||||||
result = TestOrderCondition(&(v->current_order), item);
|
result = TestOrderCondition(&(v->current_order), item);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TRIT_COND_NEXT_ORDER: {
|
||||||
|
if (v->orders.list == NULL) break;
|
||||||
|
if (v->orders.list->GetNumOrders() == 0) break;
|
||||||
|
|
||||||
|
const Order *current_order = v->GetOrder(v->cur_real_order_index);
|
||||||
|
for (const Order *order = v->orders.list->GetNext(current_order); order != current_order; order = v->orders.list->GetNext(order)) {
|
||||||
|
if (order->IsGotoOrder()) {
|
||||||
|
result = TestOrderCondition(order, item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
@@ -737,7 +751,8 @@ void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint1
|
|||||||
FOR_ALL_TRACE_RESTRICT_PROGRAMS(prog) {
|
FOR_ALL_TRACE_RESTRICT_PROGRAMS(prog) {
|
||||||
for (size_t i = 0; i < prog->items.size(); i++) {
|
for (size_t i = 0; i < prog->items.size(); i++) {
|
||||||
TraceRestrictItem &item = prog->items[i]; // note this is a reference,
|
TraceRestrictItem &item = prog->items[i]; // note this is a reference,
|
||||||
if (GetTraceRestrictType(item) == TRIT_COND_CURRENT_ORDER) {
|
if (GetTraceRestrictType(item) == TRIT_COND_CURRENT_ORDER ||
|
||||||
|
GetTraceRestrictType(item) == TRIT_COND_NEXT_ORDER) {
|
||||||
if (GetTraceRestrictAuxField(item) == type && GetTraceRestrictValue(item) == index) {
|
if (GetTraceRestrictAuxField(item) == type && GetTraceRestrictValue(item) == index) {
|
||||||
SetTraceRestrictValueDefault(item, TRVT_ORDER); // this updates the instruction in-place
|
SetTraceRestrictValueDefault(item, TRVT_ORDER); // this updates the instruction in-place
|
||||||
}
|
}
|
||||||
|
@@ -83,6 +83,7 @@ enum TraceRestrictItemType {
|
|||||||
TRIT_COND_TRAIN_LENGTH = 10, ///< Test train length
|
TRIT_COND_TRAIN_LENGTH = 10, ///< Test train length
|
||||||
TRIT_COND_MAX_SPEED = 11, ///< Test train max speed
|
TRIT_COND_MAX_SPEED = 11, ///< Test train max speed
|
||||||
TRIT_COND_CURRENT_ORDER = 12, ///< Test train current order (station, waypoint or depot)
|
TRIT_COND_CURRENT_ORDER = 12, ///< Test train current order (station, waypoint or depot)
|
||||||
|
TRIT_COND_NEXT_ORDER = 13, ///< Test train next order (station, waypoint or depot)
|
||||||
/* space up to 31 */
|
/* space up to 31 */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -251,6 +252,7 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIT_COND_CURRENT_ORDER:
|
case TRIT_COND_CURRENT_ORDER:
|
||||||
|
case TRIT_COND_NEXT_ORDER:
|
||||||
out.value_type = TRVT_ORDER;
|
out.value_type = TRVT_ORDER;
|
||||||
out.cond_type = TRCOT_BINARY;
|
out.cond_type = TRCOT_BINARY;
|
||||||
break;
|
break;
|
||||||
|
@@ -159,6 +159,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI
|
|||||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH,
|
STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED,
|
STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER,
|
STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER,
|
||||||
|
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED,
|
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED,
|
||||||
INVALID_STRING_ID,
|
INVALID_STRING_ID,
|
||||||
};
|
};
|
||||||
@@ -166,6 +167,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI
|
|||||||
TRIT_COND_TRAIN_LENGTH,
|
TRIT_COND_TRAIN_LENGTH,
|
||||||
TRIT_COND_MAX_SPEED,
|
TRIT_COND_MAX_SPEED,
|
||||||
TRIT_COND_CURRENT_ORDER,
|
TRIT_COND_CURRENT_ORDER,
|
||||||
|
TRIT_COND_NEXT_ORDER,
|
||||||
TRIT_COND_UNDEFINED,
|
TRIT_COND_UNDEFINED,
|
||||||
};
|
};
|
||||||
static const TraceRestrictDropDownListSet set_cond = {
|
static const TraceRestrictDropDownListSet set_cond = {
|
||||||
|
Reference in New Issue
Block a user