Tracerestrict: Add load percentage conditional
This commit is contained in:
@@ -2666,6 +2666,7 @@ STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER :current order
|
|||||||
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER :next order
|
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER :next order
|
||||||
STR_TRACE_RESTRICT_VARIABLE_LAST_VISITED_STATION :last visited station
|
STR_TRACE_RESTRICT_VARIABLE_LAST_VISITED_STATION :last visited station
|
||||||
STR_TRACE_RESTRICT_VARIABLE_CARGO :cargo
|
STR_TRACE_RESTRICT_VARIABLE_CARGO :cargo
|
||||||
|
STR_TRACE_RESTRICT_VARIABLE_LOAD_PERCENT :load percentage
|
||||||
STR_TRACE_RESTRICT_VARIABLE_ENTRY_DIRECTION :entry direction
|
STR_TRACE_RESTRICT_VARIABLE_ENTRY_DIRECTION :entry direction
|
||||||
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL :PBS entry signal
|
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL :PBS entry signal
|
||||||
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL_LONG :entered signal of PBS block
|
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL_LONG :entered signal of PBS block
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "pathfinder/yapf/yapf_cache.h"
|
#include "pathfinder/yapf/yapf_cache.h"
|
||||||
#include "scope_info.h"
|
#include "scope_info.h"
|
||||||
|
#include "vehicle_func.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -493,6 +494,11 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case TRIT_COND_LOAD_PERCENT: {
|
||||||
|
result = TestCondition(CalcPercentVehicleFilled(v, nullptr), condop, condvalue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
@@ -722,6 +728,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
case TRIT_COND_PHYS_RATIO:
|
case TRIT_COND_PHYS_RATIO:
|
||||||
case TRIT_COND_TRAIN_OWNER:
|
case TRIT_COND_TRAIN_OWNER:
|
||||||
case TRIT_COND_TRAIN_STATUS:
|
case TRIT_COND_TRAIN_STATUS:
|
||||||
|
case TRIT_COND_LOAD_PERCENT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -858,6 +865,7 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp
|
|||||||
case TRVT_WAIT_AT_PBS:
|
case TRVT_WAIT_AT_PBS:
|
||||||
case TRVT_TRAIN_STATUS:
|
case TRVT_TRAIN_STATUS:
|
||||||
case TRVT_REVERSE:
|
case TRVT_REVERSE:
|
||||||
|
case TRVT_PERCENT:
|
||||||
SetTraceRestrictValue(item, 0);
|
SetTraceRestrictValue(item, 0);
|
||||||
if (!IsTraceRestrictTypeAuxSubtype(GetTraceRestrictType(item))) {
|
if (!IsTraceRestrictTypeAuxSubtype(GetTraceRestrictType(item))) {
|
||||||
SetTraceRestrictAuxField(item, 0);
|
SetTraceRestrictAuxField(item, 0);
|
||||||
|
@@ -138,6 +138,7 @@ enum TraceRestrictItemType {
|
|||||||
TRIT_COND_SLOT_OCCUPANCY = 22, ///< Test train slot occupancy state
|
TRIT_COND_SLOT_OCCUPANCY = 22, ///< Test train slot occupancy state
|
||||||
TRIT_COND_TRAIN_OWNER = 24, ///< Test train owner
|
TRIT_COND_TRAIN_OWNER = 24, ///< Test train owner
|
||||||
TRIT_COND_TRAIN_STATUS = 25, ///< Test train status
|
TRIT_COND_TRAIN_STATUS = 25, ///< Test train status
|
||||||
|
TRIT_COND_LOAD_PERCENT = 26, ///< Test train load percentage
|
||||||
|
|
||||||
TRIT_COND_END = 48, ///< End (exclusive) of conditional item types, note that this has the same value as TRIT_REVERSE
|
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
|
TRIT_REVERSE = 48, ///< Reverse behind signal
|
||||||
@@ -553,6 +554,7 @@ enum TraceRestrictValueType {
|
|||||||
TRVT_WAIT_AT_PBS = 18,///< takes a TraceRestrictWaitAtPbsValueField value
|
TRVT_WAIT_AT_PBS = 18,///< takes a TraceRestrictWaitAtPbsValueField value
|
||||||
TRVT_SLOT_INDEX = 19,///< takes a TraceRestrictSlotID
|
TRVT_SLOT_INDEX = 19,///< takes a TraceRestrictSlotID
|
||||||
TRVT_SLOT_INDEX_INT = 20,///< takes a TraceRestrictSlotID, and an integer in the next item slot
|
TRVT_SLOT_INDEX_INT = 20,///< takes a TraceRestrictSlotID, and an integer in the next item slot
|
||||||
|
TRVT_PERCENT = 21,///> takes a unsigned integer percentage value between 0 and 100
|
||||||
TRVT_OWNER = 40,///< takes a CompanyID
|
TRVT_OWNER = 40,///< takes a CompanyID
|
||||||
TRVT_TRAIN_STATUS = 41,///< takes a TraceRestrictTrainStatusValueField
|
TRVT_TRAIN_STATUS = 41,///< takes a TraceRestrictTrainStatusValueField
|
||||||
TRVT_REVERSE = 42,///< takes a TraceRestrictReverseValueField
|
TRVT_REVERSE = 42,///< takes a TraceRestrictReverseValueField
|
||||||
@@ -677,6 +679,10 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
|
|||||||
out.cond_type = TRCOT_BINARY;
|
out.cond_type = TRCOT_BINARY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TRIT_COND_LOAD_PERCENT:
|
||||||
|
out.value_type = TRVT_PERCENT;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
break;
|
break;
|
||||||
|
@@ -394,6 +394,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
|||||||
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER,
|
STR_TRACE_RESTRICT_VARIABLE_NEXT_ORDER,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_LAST_VISITED_STATION,
|
STR_TRACE_RESTRICT_VARIABLE_LAST_VISITED_STATION,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_CARGO,
|
STR_TRACE_RESTRICT_VARIABLE_CARGO,
|
||||||
|
STR_TRACE_RESTRICT_VARIABLE_LOAD_PERCENT,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_ENTRY_DIRECTION,
|
STR_TRACE_RESTRICT_VARIABLE_ENTRY_DIRECTION,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL,
|
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL,
|
||||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_GROUP,
|
STR_TRACE_RESTRICT_VARIABLE_TRAIN_GROUP,
|
||||||
@@ -417,6 +418,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
|||||||
TRIT_COND_NEXT_ORDER,
|
TRIT_COND_NEXT_ORDER,
|
||||||
TRIT_COND_LAST_STATION,
|
TRIT_COND_LAST_STATION,
|
||||||
TRIT_COND_CARGO,
|
TRIT_COND_CARGO,
|
||||||
|
TRIT_COND_LOAD_PERCENT,
|
||||||
TRIT_COND_ENTRY_DIRECTION,
|
TRIT_COND_ENTRY_DIRECTION,
|
||||||
TRIT_COND_PBS_ENTRY_SIGNAL,
|
TRIT_COND_PBS_ENTRY_SIGNAL,
|
||||||
TRIT_COND_TRAIN_GROUP,
|
TRIT_COND_TRAIN_GROUP,
|
||||||
@@ -441,7 +443,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
|
|||||||
if (_settings_client.gui.show_adv_tracerestrict_features) {
|
if (_settings_client.gui.show_adv_tracerestrict_features) {
|
||||||
*hide_mask = 0;
|
*hide_mask = 0;
|
||||||
} else {
|
} else {
|
||||||
*hide_mask = is_conditional ? 0x70000 : 0x70;
|
*hide_mask = is_conditional ? 0xE0000 : 0x70;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return is_conditional ? &set_cond : &set_action;
|
return is_conditional ? &set_cond : &set_action;
|
||||||
@@ -683,6 +685,7 @@ static bool IsIntegerValueType(TraceRestrictValueType type)
|
|||||||
case TRVT_WEIGHT:
|
case TRVT_WEIGHT:
|
||||||
case TRVT_POWER:
|
case TRVT_POWER:
|
||||||
case TRVT_FORCE:
|
case TRVT_FORCE:
|
||||||
|
case TRVT_PERCENT:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -740,6 +743,10 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di
|
|||||||
case TRVT_PF_PENALTY:
|
case TRVT_PF_PENALTY:
|
||||||
return in;
|
return in;
|
||||||
|
|
||||||
|
case TRVT_PERCENT:
|
||||||
|
if (!to_display && in > 100) return 100;
|
||||||
|
return in;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -908,6 +915,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
|||||||
} else {
|
} else {
|
||||||
switch (properties.value_type) {
|
switch (properties.value_type) {
|
||||||
case TRVT_INT:
|
case TRVT_INT:
|
||||||
|
case TRVT_PERCENT:
|
||||||
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER;
|
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER;
|
||||||
DrawInstructionStringConditionalIntegerCommon(item, properties);
|
DrawInstructionStringConditionalIntegerCommon(item, properties);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user