Skip to content

Fix Save Editor inventory edits leaving C/D-pad buttons desynced - #7008

Open
bassdr wants to merge 2 commits into
HarbourMasters:developfrom
bassdr:fix/save-editor-button-desync
Open

Fix Save Editor inventory edits leaving C/D-pad buttons desynced#7008
bassdr wants to merge 2 commits into
HarbourMasters:developfrom
bassdr:fix/save-editor-button-desync

Conversation

@bassdr

@bassdr bassdr commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

While testing #6951 I hit the recurring save corruption tracked in #7004 and first suspected that PR. After investigating, I'm now confident the origin is the Inventory debug menu, not #6951.

Cause

The Save Editor's Inventory tab writes inventory.items[] directly, but a C/D-pad item button mirrors the slot it points at (buttonItems[i] == items[cButtonSlots[i-1]]). That mirror was never refreshed after a raw edit, so changing a bottle assigned to a button (e.g. emptying it) leaves the button on stale contents — an equip/inventory desync the game then trips on at the next age swap or bottle update.

Fix

After an Inventory-tab slot write, re-sync any button pointing at that slot. Equipment on a button stores an equipment-page index in cButtonSlots (≥ inventory size), so it never matches an inventory slot and is left untouched. Debug menu only; no gameplay behavior changes.

Build Artifacts

The Save Editor's Inventory tab writes gSaveContext.inventory.items[]
directly, but a C/D-pad item button mirrors the slot it points at
(buttonItems[i] == items[cButtonSlots[i-1]]). That derived value was
never refreshed, so e.g. emptying a bottle assigned to a button left the
button showing its old contents -- a desync the game's equip/inventory
consistency then trips on at the next age swap or bottle update.

Re-sync any button pointing at an edited slot after the write. Equipment
assigned to a button stores an equipment-page index in cButtonSlots
(>= inventory size), so it never matches an inventory slot and is left
untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMnZEp5CRuq4e3ozJbhRZy
Comment thread soh/soh/Enhancements/debugger/debugSaveEditor.cpp Outdated
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.

2 participants