Add reserve through action to trace restrict programs.

This only changes the behaviour of PBS reservations which
would otherwise terminate at a PBS signal.
If the signal restriction sets the reserve through state,
the reservation continues through the signal, and the signal
is set to green.
This commit is contained in:
Jonathan G Rennison
2015-09-02 01:39:33 +01:00
parent 06cc930e47
commit 06a1d7c5c9
8 changed files with 126 additions and 4 deletions

View File

@@ -119,6 +119,7 @@ static const StringID _program_insert_str[] = {
STR_TRACE_RESTRICT_CONDITIONAL_ELSE,
STR_TRACE_RESTRICT_PF_DENY,
STR_TRACE_RESTRICT_PF_PENALTY,
STR_TRACE_RESTRICT_RESERVE_THROUGH,
INVALID_STRING_ID
};
static const uint32 _program_insert_else_hide_mask = 8; ///< disable bitmask for else
@@ -131,6 +132,7 @@ static const uint _program_insert_val[] = {
TRIT_COND_ENDIF | (TRCF_ELSE << 16), // else block
TRIT_PF_DENY, // deny
TRIT_PF_PENALTY, // penalty
TRIT_RESERVE_THROUGH, // reserve through
};
/** insert drop down list strings and values */
@@ -153,6 +155,21 @@ static const TraceRestrictDropDownListSet _deny_value = {
_deny_value_str, _deny_value_val,
};
static const StringID _reserve_through_value_str[] = {
STR_TRACE_RESTRICT_RESERVE_THROUGH,
STR_TRACE_RESTRICT_RESERVE_THROUGH_CANCEL,
INVALID_STRING_ID
};
static const uint _reserve_through_value_val[] = {
0,
1,
};
/** value drop down list for deny types strings and values */
static const TraceRestrictDropDownListSet _reserve_through_value = {
_reserve_through_value_str, _reserve_through_value_val,
};
static const StringID _direction_value_str[] = {
STR_TRACE_RESTRICT_DIRECTION_FRONT,
STR_TRACE_RESTRICT_DIRECTION_BACK,
@@ -211,11 +228,13 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI
static const StringID str_action[] = {
STR_TRACE_RESTRICT_PF_DENY,
STR_TRACE_RESTRICT_PF_PENALTY,
STR_TRACE_RESTRICT_RESERVE_THROUGH,
INVALID_STRING_ID,
};
static const uint val_action[] = {
TRIT_PF_DENY,
TRIT_PF_PENALTY,
TRIT_RESERVE_THROUGH,
};
static const TraceRestrictDropDownListSet set_action = {
str_action, val_action,
@@ -642,6 +661,10 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
}
break;
case TRIT_RESERVE_THROUGH:
instruction_string = GetTraceRestrictValue(item) ? STR_TRACE_RESTRICT_RESERVE_THROUGH_CANCEL : STR_TRACE_RESTRICT_RESERVE_THROUGH;
break;
default:
NOT_REACHED();
break;
@@ -843,6 +866,10 @@ public:
this->ShowDropDownListWithValue(&_pf_penalty_dropdown, GetPathfinderPenaltyDropdownIndex(item), false, TR_WIDGET_VALUE_DROPDOWN, 0, 0, 0);
break;
case TRVT_RESERVE_THROUGH:
this->ShowDropDownListWithValue(&_reserve_through_value, GetTraceRestrictValue(item), false, TR_WIDGET_VALUE_DROPDOWN, 0, 0, 0);
break;
default:
break;
}
@@ -1581,6 +1608,13 @@ private:
}
break;
case TRVT_RESERVE_THROUGH:
right_sel->SetDisplayedPlane(DPR_VALUE_DROPDOWN);
this->EnableWidget(TR_WIDGET_VALUE_DROPDOWN);
this->GetWidget<NWidgetCore>(TR_WIDGET_VALUE_DROPDOWN)->widget_data =
GetTraceRestrictValue(item) ? STR_TRACE_RESTRICT_RESERVE_THROUGH_CANCEL : STR_TRACE_RESTRICT_RESERVE_THROUGH;
break;
default:
break;
}