Skip to content

Fix custom dealer inventory restoration after reload - #261

Merged
ifBars merged 2 commits into
stablefrom
diffuin/259-7ebc2622
Aug 12, 2026
Merged

Fix custom dealer inventory restoration after reload#261
ifBars merged 2 commits into
stablefrom
diffuin/259-7ebc2622

Conversation

@diffuin

@diffuin diffuin Bot commented Aug 11, 2026

Copy link
Copy Markdown

Requested by @ifBars in #259.

Diffuin response

Confidence: Medium

Implemented the approved custom dealer inventory persistence fix and focused regression coverage. Primary inventory now restores once after slot initialization in NPCLoader_Load_Prefix. The obsolete Awake-dependent queue was removed, while dealer overflow and base-game paths remain unchanged. No public API or durable save identifiers changed.

Recommended next steps

  1. Initialize the final NPCInventory slot collection immediately before loading the saved ItemSet.
  2. Use one synchronous primary-inventory restoration path independent of whether Awake already ran.
  3. Keep overflow inventory restoration separate and preserve the custom-NPC guard around primary restoration.
Evidence and validation

Evidence inspected

  • NPCLoader_Load_Prefix restores primary inventory after s1BaseNpc.Load completes, including dealer-specific loading.
  • NPCInventory.Awake still normalizes custom NPC slots but no longer owns delayed inventory hydration.
  • Dealer_Load_Prefix no longer reads or queues the primary Inventory payload; DealerData.OverflowItems retains its existing Mono and IL2CPP paths.
  • Regular and beta stripped sources retain the targeted NPCLoader.Load, NPCInventory.Awake, Dealer.Load, NPC.Inventory, and DealerData.OverflowItems seams.

Validation performed

Runtime validation remaining

  • Run restore, build, and the full test suite for MonoMelon and Il2CppMelon with .NET 9 and the required game references.
  • Perform human Mono and IL2CPP save-to-menu-to-reload checks covering item identity, quantities, slot positions, empty slots, and overflow inventory.
  • Confirm unchanged behavior for a base-game dealer in both runtimes.
Diffuin run details
  • Provider: codex
  • Model: gpt-5.6-sol
  • Reasoning: high (Luna advisor: risk (high); baseline bounded implementation)
  • Elapsed: 401s
  • Codex thread: 019ff307-8494-7fd0-9485-60573d93228a

AI notice: Generated with AI assistance and not guaranteed accurate. Verify findings and plans against the current source and runtime.

Closes #259


Diffuin job: 7ebc2622-05d0-4ea4-a091-9ce4dd73133a
Commit: a849e27435d552f34c426f8b94e5883eb4147a99

@ifBars ifBars left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified after reproducing two blockers in the original PR and pushing follow-up commit 1679a38:

  • Current native NPCInventory no longer exposes the legacy SlotCount member, so custom inventories could remain at zero slots before restoration. The follow-up preserves positive legacy/data/current counts and uses the vanilla five-slot default only for empty custom NPC inventories.
  • IL2CPP Delegate.Combine returned Il2CppSystem.Delegate and the CLR cast to Il2CppSystem.Action failed. The follow-up uses the established typed Il2CppInterop Cast path.

Validation:

  • MonoMelon build: 0 warnings, 0 errors; focused persistence tests 8/8; full suite 569/569.
  • Il2CppMelon build: 0 warnings, 0 errors; focused persistence tests 8/8; full suite 558/558.
  • Live disposable-save smoke passed separately on Mono and IL2CPP across save -> Menu -> reload. Primary slot 0 retained banana x7, slot 1 remained empty, slot 2 retained baseball bat x1, overflow slot 1 retained banana x3, and base dealer brad_crosby remained unchanged.
  • AssetRipper inspection confirmed NPCInventory is prefab-attached while slots are runtime-created, and all 114 exported NPC inventory data assets use five slots.
  • No public API, save identifier, network payload, or base-NPC behavior changes.

@ifBars ifBars added the bug Something isn't working label Aug 12, 2026
@ifBars ifBars self-assigned this Aug 12, 2026
@ifBars
ifBars merged commit 1ba8b5d into stable Aug 12, 2026
6 checks passed
@ifBars
ifBars deleted the diffuin/259-7ebc2622 branch August 12, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Custom dealer inventories are cleared after save reload

1 participant