Add trace restrict slot membership conditional.

This commit is contained in:
Jonathan G Rennison
2017-03-30 21:53:30 +01:00
parent 6417fb16c3
commit 927323dcb1
4 changed files with 36 additions and 3 deletions

View File

@@ -354,6 +354,12 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
break;
}
case TRIT_COND_SLOT: {
const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(GetTraceRestrictValue(item));
result = TestBinaryConditionCommon(item, slot != NULL && slot->IsOccupant(v->index));
break;
}
case TRIT_COND_PHYS_PROP: {
switch (static_cast<TraceRestrictPhysPropCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPCAF_WEIGHT:
@@ -563,6 +569,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
case TRIT_COND_ENTRY_DIRECTION:
case TRIT_COND_PBS_ENTRY_SIGNAL:
case TRIT_COND_TRAIN_GROUP:
case TRIT_COND_SLOT:
case TRIT_COND_PHYS_PROP:
case TRIT_COND_PHYS_RATIO:
break;
@@ -1482,7 +1489,7 @@ void TraceRestrictRemoveSlotID(TraceRestrictSlotID index)
FOR_ALL_TRACE_RESTRICT_PROGRAMS(prog) {
for (size_t i = 0; i < prog->items.size(); i++) {
TraceRestrictItem &item = prog->items[i]; // note this is a reference,
if (GetTraceRestrictType(item) == TRIT_SLOT && GetTraceRestrictValue(item) == index) {
if ((GetTraceRestrictType(item) == TRIT_SLOT || GetTraceRestrictType(item) == TRIT_COND_SLOT) && GetTraceRestrictValue(item) == index) {
SetTraceRestrictValueDefault(item, TRVT_SLOT_INDEX); // this updates the instruction in-place
}
if (IsTraceRestrictDoubleItem(item)) i++;