Change pf penalty restriction value button to preset values and a custom option.

Preset values are 'small', 'medium' and 'large'.
Change default to 'small' preset.
This commit is contained in:
Jonathan G Rennison
2015-08-04 19:09:40 +01:00
parent a0520b8937
commit 76707fb72a
4 changed files with 171 additions and 7 deletions

View File

@@ -66,6 +66,23 @@ INSTANTIATE_POOL_METHODS(TraceRestrictProgram)
*/
TraceRestrictMapping _tracerestrictprogram_mapping;
/**
* Default value for pathfinder penalty instructions
*/
static const uint16 _tracerestrict_penalty_item_default_value = 500;
/**
* List of pre-defined pathfinder penalty values
* This is indexed by TraceRestrictPathfinderPenaltyPresetIndex
*/
const uint16 _tracerestrict_pathfinder_penalty_preset_values[] = {
500,
2000,
8000,
};
assert_compile(lengthof(_tracerestrict_pathfinder_penalty_preset_values) == TRPPPI_END);
/**
* This should be used when all pools have been or are immediately about to be also cleared
* Calling this at other times will leave dangling refcounts
@@ -347,9 +364,25 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
out.flags |= TRPRF_DENY;
}
break;
case TRIT_PF_PENALTY:
out.penalty += GetTraceRestrictValue(item);
switch (static_cast<TraceRestrictPathfinderPenaltyAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPAF_VALUE:
out.penalty += GetTraceRestrictValue(item);
break;
case TRPPAF_PRESET: {
uint16 index = GetTraceRestrictValue(item);
assert(index < TRPPPI_END);
out.penalty += _tracerestrict_pathfinder_penalty_preset_values[index];
break;
}
default:
NOT_REACHED();
}
break;
default:
NOT_REACHED();
}
@@ -490,6 +523,11 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp
SetTraceRestrictAuxField(item, 0);
break;
case TRVT_PF_PENALTY:
SetTraceRestrictValue(item, TRPPPI_SMALL);
SetTraceRestrictAuxField(item, TRPPAF_PRESET);
break;
default:
NOT_REACHED();
break;