Add tracerestrict reserved tiles ahead conditional
This commit is contained in:
@@ -2784,6 +2784,7 @@ STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_SHORT :occupancy
|
||||
STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING_SHORT :occupancy remaining
|
||||
STR_TRACE_RESTRICT_VARIABLE_COUNTER_VALUE :counter value
|
||||
STR_TRACE_RESTRICT_VARIABLE_TIME_DATE_VALUE :current time/date
|
||||
STR_TRACE_RESTRICT_VARIABLE_RESERVED_TILES_AHEAD :reserved tiles ahead
|
||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_WEIGHT :weight
|
||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER :power
|
||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE :max T.E.
|
||||
|
@@ -76,7 +76,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_TRACE_RESTRICT_NEWSCTRL,XSCF_NULL, 1, 1, "tracerestrict_newsctrl", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TRACE_RESTRICT_COUNTER, XSCF_NULL, 1, 1, "tracerestrict_counter", nullptr, nullptr, "TRRC" },
|
||||
{ XSLFI_TRACE_RESTRICT_TIMEDATE,XSCF_NULL, 1, 1, "tracerestrict_timedate", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TRACE_RESTRICT_BRKCND, XSCF_NULL, 1, 1, "tracerestrict_braking_cond",nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TRACE_RESTRICT_BRKCND, XSCF_NULL, 2, 2, "tracerestrict_braking_cond",nullptr, nullptr, nullptr },
|
||||
{ XSLFI_PROG_SIGS, XSCF_NULL, 2, 2, "programmable_signals", nullptr, nullptr, "SPRG" },
|
||||
{ XSLFI_ADJACENT_CROSSINGS, XSCF_NULL, 1, 1, "adjacent_crossings", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_SAFER_CROSSINGS, XSCF_NULL, 1, 1, "safer_crossings", nullptr, nullptr, nullptr },
|
||||
|
@@ -524,6 +524,15 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
||||
break;
|
||||
}
|
||||
|
||||
case TRIT_COND_RESERVED_TILES: {
|
||||
uint tiles_ahead = 0;
|
||||
if (v->lookahead != nullptr) {
|
||||
tiles_ahead = std::max<int>(0, v->lookahead->reservation_end_position - v->lookahead->current_position) / TILE_SIZE;
|
||||
}
|
||||
result = TestCondition(tiles_ahead, condop, condvalue);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
@@ -807,6 +816,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
||||
case TRIT_COND_LOAD_PERCENT:
|
||||
case TRIT_COND_COUNTER_VALUE:
|
||||
case TRIT_COND_TIME_DATE_VALUE:
|
||||
case TRIT_COND_RESERVED_TILES:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -151,6 +151,7 @@ enum TraceRestrictItemType {
|
||||
TRIT_COND_LOAD_PERCENT = 26, ///< Test train load percentage
|
||||
TRIT_COND_COUNTER_VALUE = 27, ///< Test counter value
|
||||
TRIT_COND_TIME_DATE_VALUE = 28, ///< Test time/date value
|
||||
TRIT_COND_RESERVED_TILES = 29, ///< Test reserved tiles ahead of train
|
||||
|
||||
TRIT_COND_END = 48, ///< End (exclusive) of conditional item types, note that this has the same value as TRIT_REVERSE
|
||||
TRIT_REVERSE = 48, ///< Reverse behind signal
|
||||
@@ -753,6 +754,10 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
|
||||
out.value_type = TRVT_TIME_DATE_INT;
|
||||
break;
|
||||
|
||||
case TRIT_COND_RESERVED_TILES:
|
||||
out.value_type = TRVT_INT;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
|
@@ -458,6 +458,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
||||
STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING,
|
||||
STR_TRACE_RESTRICT_VARIABLE_COUNTER_VALUE,
|
||||
STR_TRACE_RESTRICT_VARIABLE_TIME_DATE_VALUE,
|
||||
STR_TRACE_RESTRICT_VARIABLE_RESERVED_TILES_AHEAD,
|
||||
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED,
|
||||
INVALID_STRING_ID,
|
||||
};
|
||||
@@ -485,6 +486,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
||||
TRIT_COND_SLOT_OCCUPANCY | (TRSOCAF_REMAINING << 16),
|
||||
TRIT_COND_COUNTER_VALUE,
|
||||
TRIT_COND_TIME_DATE_VALUE,
|
||||
TRIT_COND_RESERVED_TILES,
|
||||
TRIT_COND_UNDEFINED,
|
||||
};
|
||||
static const TraceRestrictDropDownListSet set_cond = {
|
||||
@@ -496,10 +498,10 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
||||
if (_settings_client.gui.show_adv_tracerestrict_features) {
|
||||
*hide_mask = 0;
|
||||
} else {
|
||||
*hide_mask = is_conditional ? 0x7C0000 : 0x2F0;
|
||||
*hide_mask = is_conditional ? 0xFC0000 : 0x2F0;
|
||||
}
|
||||
if (is_conditional && !_settings_game.game_time.time_in_minutes) *hide_mask |= 0x400000;
|
||||
if (is_conditional && _settings_game.vehicle.train_braking_model != TBM_REALISTIC) *hide_mask |= 0x200;
|
||||
if (is_conditional && _settings_game.vehicle.train_braking_model != TBM_REALISTIC) *hide_mask |= 0x800200;
|
||||
}
|
||||
return is_conditional ? &set_cond : &set_action;
|
||||
}
|
||||
|
Reference in New Issue
Block a user