Skip to content

Toolbar: an item that leaves the player leaves the bar (fix #219) - #234

Merged
eriknihlen merged 2 commits into
mainfrom
fix/issue-219-hotbar
Oct 20, 2026
Merged

eriknihlen merged 2 commits into
mainfrom
fix/issue-219-hotbar

Conversation

@eriknihlen

Copy link
Copy Markdown
Owner

Fixes #219.

When the server moves or removes an item the player no longer owns (dropped, given, sold, traded, last use consumed), the toolbar clears that item's shortcut and tells the server (remove-shortcut), as the original client does. Moves between the player's own packs, wield and unwield keep the slot; a partial stack use keeps it.

A full stack merge of an item on the toolbar now moves its shortcut to the merged stack in the runtime (it lived only in the graphical toolbar), so plugins and the headless client keep the slot too instead of losing it.

  • RuntimeInventoryState: clear-on-ownership-loss and the merge retarget; GameRuntime binds the player and the send on both hosts.
  • Tests: removal cases, two slots holding the same item, spell shortcuts untouched, and a host-parity merge scenario. Portable filter: 21,703 passed.
  • Open question noted privately: whether a newer copy of an object under the same id should clear the slot.

🤖 Generated with Claude Code

eriknihlen and others added 2 commits October 19, 2026 22:39
Dropping a Treated Healing Kit left its shortcut on the bar; pressing the
key then walked the character to the kit on the ground and picked it up.
The original client clears the slot, and tells the server, whenever the
server moves or removes an item on the bar that the player no longer owns
(dropped, given, sold, put in a container that is not the player's,
destroyed, used up). The server never clears a shortcut on its own, so the
stale slot was also saved with the character.

The inventory owner in the runtime now watches the server's placement
changes and removals: for the slot holding that item it clears the
shortcut and sends RemoveShortCut unless the player still owns the item.
A local drag projection and a fresh incarnation of the same object keep
the slot. The game runtime binds the player and the in-world send, so the
graphical and headless clients behave the same; the bar repaints from the
shortcut store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging a stack that sits on the toolbar moves its shortcut to the stack
it joins, the moment the merge is sent. That lived only in the windowed
toolbar panel, so a plugin, automatic or headless merge never moved the
shortcut; with the new ownership rule the slot was then cleared and a
RemoveShortCut sent when the server took the poured stack away.

The inventory owner in the runtime now does the retarget and sends both
changes; the game runtime subscribes it to the item owner's merge event,
and the inventory panel's own drag merge calls the same method through its
bindings. The toolbar panel's copy is gone.

Tests: the retarget and its quiet aftermath on the runtime owner, a host
parity scenario for a plugin merge on both clients (red with the runtime
subscription removed), and the ownership rule's edges: a confirmed move of
an item the client never held clears, an item on two slots loses only the
first, an exact-incarnation delete clears, spell shortcuts are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eriknihlen
eriknihlen merged commit d6087a2 into main Oct 20, 2026
7 checks passed
@eriknihlen
eriknihlen deleted the fix/issue-219-hotbar branch October 20, 2026 06:45
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.

Items remain on hotbar after removed from inventory

1 participant