Skip to content

Harden customize-item mod parsing to reject malformed entries and prevent persistent bad equips#7

Merged
dawc17 merged 2 commits into
mainfrom
copilot/fix-customization-error
Apr 17, 2026
Merged

Harden customize-item mod parsing to reject malformed entries and prevent persistent bad equips#7
dawc17 merged 2 commits into
mainfrom
copilot/fix-customization-error

Conversation

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Malformed customize_item_* payloads could be loaded even when required fields were missing, allowing invalid items to be equipped and persisted in save data. This change tightens parser acceptance criteria so malformed customization entries are dropped before they can be emitted back into mods.

  • Problem scope

    • customize_item_common_list.bin and customize_item_unique_list.bin accepted structurally invalid rows (e.g., missing IDs or asset keys), which could propagate bad customization records.
  • Parser hardening

    • Added entry-level validators for customization records:
      • common entries require non-zero item_id and non-empty key text fields.
      • unique/body entries require non-zero item ID + non-empty asset_name.
    • ParseCustomizeItemCommonJson now appends only validated entries.
    • ParseCustomizeItemUniqueListJson now returns failure when both arrays are empty after validation.
  • Generic array parsing behavior

    • Updated ParseExclusiveArray(...) to only push entries when parseFn(...) returns true, enabling per-entry rejection consistently across call sites.
  • Load-path gating

    • LoadFromPath(...) now conditionally adds customize_item_unique_list.bin only when parsing succeeds, aligning with existing guarded behavior used for other bins.
  • User recovery guidance

    • Added a concise README recovery section for already-corrupted saves: re-enable offending mod, unequip to vanilla, resave, then remove mod; fallback to pre-corruption backup/clean profile if persistence remains.
static bool IsValidCustomizeItemUniqueEntry(const CustomizeItemUniqueEntry& e)
{
    return e.char_item_id != 0 && IsNonEmptyText(e.asset_name);
}

template<typename TEntry, typename TParseFunc>
static void ParseExclusiveArray(const char* json, const char* arrayKey,
                                std::vector<TEntry>& out, TParseFunc parseFn)
{
    ...
    TEntry entry{};
    if (parseFn(arr, objEnd, entry))
        out.push_back(entry);
}

Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix possible irreversible customization error Harden customize-item mod parsing to reject malformed entries and prevent persistent bad equips Apr 17, 2026
Copilot AI requested a review from dawc17 April 17, 2026 22:29
@dawc17
dawc17 marked this pull request as ready for review April 17, 2026 22:31
@dawc17
dawc17 merged commit a0c2918 into main Apr 17, 2026
1 check failed
Copilot stopped work on behalf of dawc17 due to an error April 17, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible irreversible customization error

2 participants