Skip to content

Fix stale crafted affixes when affix limits shrink - #2610

Open
ooPG233 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
ooPG233:fix/crafted-affix-limit-shrink
Open

ooPG233 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
ooPG233:fix/crafted-affix-limit-shrink

Conversation

@ooPG233

@ooPG233 ooPG233 commented Dec 2, 2026

Copy link
Copy Markdown

Follow-up to #2372 (related to #2568).

Description of the problem being solved:

When crafting an item with an affix-capacity modifier (such as Serle's Triumph granting +1 Suffix Modifier allowed), shrinking the affix limit leaves stale state behind:

  1. Removing or replacing the rune, disabling the capacity modifier in preview, or reducing the rune socket count hides the extra affix row while leaving the surplus entry in prefixes/suffixes and its explicit modifier active in calculations and saved XML.
  2. Reducing the rune socket count in ItemsTab did not call UpdateAffixControls(), so surviving affix dropdowns stayed stale. Selecting the same affix group in an open slot and restoring the rune could produce duplicate affixes (e.g. two Dexterity4 rolls granting +40 Dexterity).
  3. Importing a crafted raw item with Rune: Serle's Triumph (without the expanded rune modifier line) computed affix limits before rune lines were generated, leaving affixLimit at 6 on the first parse.
  4. ItemsTab preallocated maxModCount = 9 affix rows even though the rare item model allows up to 6 + 6 = 12 modifiers, and the rune dropdown tooltipFunc dereferenced value without a nil guard.

Changes:

  • src/Classes/Item.lua: Count rune affix-limit changes after rune lines are resolved; trim overflowing serialized craft selections and recraft when an occupied slot is removed; reset self.fractured on reparse and preserve disabled capacity lines across Craft(); preserve imported explicit modifiers on non-crafted and advanced-copy items.
  • src/Classes/ItemsTab.lua: Call UpdateAffixControls() on crafted items when rune socket count changes; raise maxModCount from 9 to 12; guard value in the rune dropdown tooltipFunc.
  • spec/System/TestItemsTab_spec.lua & spec/System/TestItemParse_spec.lua: Add 15 regression tests covering all shrink paths, duplicate-affix prevention, build XML save/reload, mirrored prefix shrink, fractured/custom modifier preservation, 10/12 affix rows, name-only rune imports, and nil rune tooltips.

Steps taken to verify a working solution:

  • Reproduced the stale/duplicate fourth suffix flow in the local dev build (Trarthan Cannon + Serle's Triumph).
  • Ran local LuaJIT Busted test suites against the branch (TestItemsTab 87/87, TestItemParse 95/95, TestItemMods 33/33, TestSkillsTab 46/46, TestImportReimport 21/21; 282/282 passed).
  • Verified git diff --check dev..HEAD and confirmed src/Data/ModCache.lua is unchanged.

Link to a build that showcases this PR:

N/A (reproducible from a blank build by crafting a Rare Trarthan Cannon with Serle's Triumph).

Before screenshot:

image

After screenshot:

image

Resolve named runes before counting their affix capacity. Trim surplus
craft selections and rebuild their effects when occupied slots disappear.
Preserve imported modifier lines and refresh the crafter's socket and
affix controls for layouts up to twelve modifiers.

Verified 282 cases across five item, skill and import specs with the
local Windows LuaJIT harness.
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.

1 participant