Skip to content

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

Merged
serprex merged 3 commits into
HarbourMasters:developfrom
bassdr:fix/save-editor-button-desync
Aug 3, 2026
Merged

Fix Save Editor inventory edits leaving C/D-pad buttons desynced#7008
serprex merged 3 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

Comment thread soh/soh/Enhancements/debugger/debugSaveEditor.cpp Outdated
bassdr and others added 2 commits August 2, 2026 11:39
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
@bassdr
bassdr force-pushed the fix/save-editor-button-desync branch from 8cc38b2 to 7982735 Compare August 2, 2026 15:40
@djevangelia

Copy link
Copy Markdown
Contributor

The function seems to do what it should and it has equivalents in z_kaleido_item.
The comment is a bit verbose and in particular the part "Equipment buttons hold an equipment-page index in cButtonSlots (>= 24)..." doesn't make much sense.
It could be argued that syncing would be best as a toggle that is normally enabled (much like restricting to valid items), as it is possible in game to desync inventory slot content and C button item (like RBA) and inventory editing could help debugging/practicing that.

Address review: add a default-on "Keep C/D-pad buttons in sync" checkbox
(mirroring "Restrict to valid items") so inventory edits can intentionally
leave a slot desynced from its button for RBA practice/debugging. Also trim
the helper comment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMnZEp5CRuq4e3ozJbhRZy
@bassdr

bassdr commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Applied both — added a default-on "Keep C/D-pad buttons in sync" toggle (mirroring "Restrict to valid items") so it can be turned off to intentionally desync a slot from its button for RBA setup/practice, and trimmed the comment.

@serprex
serprex merged commit 44f680a into HarbourMasters:develop Aug 3, 2026
5 checks passed
@bassdr
bassdr deleted the fix/save-editor-button-desync branch August 3, 2026 18:48
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.

3 participants