Tracerestrict: Use combined aux and cond op fields for TRIT_SLOT subtype

This commit is contained in:
Jonathan G Rennison
2024-01-19 21:35:46 +00:00
parent f03a941b50
commit fc51491361
5 changed files with 34 additions and 15 deletions

View File

@@ -76,7 +76,7 @@ static uint32_t saveSTC(const SlxiSubChunkInfo *info, bool dry_run);
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_VERSION_LABEL, XSCF_IGNORABLE_ALL, 1, 1, "version_label", saveVL, loadVL, nullptr },
{ XSLFI_UPSTREAM_VERSION, XSCF_NULL, 1, 1, "upstream_version", saveUV, loadUV, nullptr },
{ XSLFI_TRACE_RESTRICT, XSCF_NULL, 16, 16, "tracerestrict", nullptr, nullptr, "TRRM,TRRP,TRRS" },
{ XSLFI_TRACE_RESTRICT, XSCF_NULL, 17, 17, "tracerestrict", nullptr, nullptr, "TRRM,TRRP,TRRS" },
{ XSLFI_TRACE_RESTRICT_OWNER, XSCF_NULL, 1, 1, "tracerestrict_owner", nullptr, nullptr, nullptr },
{ XSLFI_TRACE_RESTRICT_ORDRCND, XSCF_NULL, 4, 4, "tracerestrict_order_cond", nullptr, nullptr, nullptr },
{ XSLFI_TRACE_RESTRICT_STATUSCND, XSCF_NULL, 2, 2, "tracerestrict_status_cond", nullptr, nullptr, nullptr },

View File

@@ -72,6 +72,20 @@ static void Load_TRRP()
if (IsTraceRestrictDoubleItem(item)) i++;
}
}
if (SlXvIsFeatureMissing(XSLFI_TRACE_RESTRICT, 17)) {
/* TRIT_SLOT subtype moved from cond op to combined aux and cond op field in version 17.
* Do this for all previous versions to avoid cases where it is unexpectedly present despite the version,
* e.g. in JokerPP and non-SLXI tracerestrict saves.
*/
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) {
TraceRestrictSlotSubtypeField subtype = static_cast<TraceRestrictSlotSubtypeField>(GetTraceRestrictCondOp(item));
SetTraceRestrictCombinedAuxCondOpField(item, subtype);
}
if (IsTraceRestrictDoubleItem(item)) i++;
}
}
CommandCost validation_result = prog->Validate();
if (validation_result.Failed()) {
char str[4096];