Skip to content

fix: allow inventory reordering while bank is open#1100

Merged
GregHib merged 1 commit into
GregHib:mainfrom
HarleyGilpin:fix/inventory-dragging-while-banked
Jul 23, 2026
Merged

fix: allow inventory reordering while bank is open#1100
GregHib merged 1 commit into
GregHib:mainfrom
HarleyGilpin:fix/inventory-dragging-while-banked

Conversation

@HarleyGilpin

Copy link
Copy Markdown
Contributor

Closes #1060

Problem

Dragging items to reorder the inventory while the bank (or deposit box) was open did nothing. Additionally, depositing an item when carrying multiples deposited the first matching slot instead of the one clicked (noted in the issue comments).

Cause

Three separate gaps:

  1. Client never initiated drags on bank_side (763). The 634 client requires two access mask conditions for an item drag: drag-depth bits 18-20 != 0 on the source slot and bit 21 on the drop target (Class348_Sub44.method3304/method3302 in the deob). bank_side's options only unlocked the deposit/examine bits. The same combination is already what makes the normal inventory tab (Option12 = 17 + Drag = 20 on 149) and the music playlist work.
  2. Item ids arrive crossed in 763->763 switch packets. The client reorders its own display before sending, so each item id is paired with the slot it was dropped into. Validation compared the post-swap client state against the pre-swap server state and rejected the packet - leaving the client visually reordered but the server unchanged, which then desynced every later click on those slots. Interface 149 has the same crossing (its handler already swaps fromItemId/toItemId alongside the ghost-slot -28); 763 needs the id swap without the slot translation, since it uses real slots 0-27.
  3. Deposits ignored the clicked slot. moveToLimit(item.id, ...) removes by id from the first matching slot.

Changes

  • bank.ifaces.toml: add Drag-Source = 17 (bit 18, drag-depth 1) and Drag = 20 (bit 21) to bank_side inventory options, making the unlocked mask 2360446 - covers both the bank and deposit box paths
  • InterfaceSwitchHandler: swap the crossed item ids for 763->763 switches
  • BankOpen: handle interfaceSwap("bank_side:inventory", "bank_side:inventory") with inventory.swap (exact pair, so a future drag-to-deposit onto the bank grid isn't misrouted into an inventory swap)
  • BankDeposit: pass the clicked slot through and remove via RemoveItem.remove(slot, id, amount) - empties the clicked slot first, then any remainder from the earliest slots; bank-capacity clamping now happens up front via addToLimit
  • BankTest: reorder while banked (including onto an empty slot, and the crossed-id packet semantics), verifies both slots are resent to the client after a swap, deposit-after-reorder, and clicked-slot deposits

Tested in-game: dragging, reordering onto empty slots, and slot-accurate deposits all work with the bank and deposit box open.

- unlock drag-source (bit 18) and drop-target (bit 21) access mask
  bits on bank_side so the client initiates drags
- swap crossed item ids in 763->763 switch packets; the client
  reorders before sending, same as interface 149
- deposit from the clicked slot instead of the first matching item

Closes GregHib#1060

@GregHib GregHib 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.

Lgtm

@GregHib
GregHib merged commit 91094ad into GregHib:main Jul 23, 2026
2 checks passed
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.

Can't drag inventory items when bank is open

2 participants