commit 55b204bbce93d4b3069a2b545a384ffba0d1d7e7
parent 133f5d83392001dc82a7eda88ecc17d31abed612
Author: anon <anon@example.com>
Date: Sat, 24 Oct 2026 14:29:17 +0000
Support carried Briefcase remote bank access
Enforce authored Use requirements and resolve owned backpack contents through known native handles. Share terminal bank opening, locality and atomic transfer behavior without consuming the Briefcase.
Verify native world requests, requirement and session boundaries, replay, closed bags and persistence. Hardware WASM checks cover item conservation, filled bags, movement closure and reconnect. Full Go and repeated affected race suites pass; retain wielded weapon support as explicit follow-up work.
Diffstat:
7 files changed, 482 insertions(+), 9 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -876,9 +876,22 @@ and unresolved indoor lifecycle are explicit in [flight](docs/vehicles.md#yalmah
stack and restore the original quantities without changing SQLite. Returning
the held cursor item allows a normal split and withdrawal afterward. See
[bank storage](docs/bank-storage.md) for the captured native state and wire proof.
-- [ ] Implement Briefcase of Holding remote bank access using its authored
- profession, skill, title-level and combat conditions; research bank CASH/XP
- semantics and historical filled-bag deletion policy.
+- [x] Implement Briefcase of Holding remote bank access from ordinary inventory
+ and known carried backpack contents. Enforce Bureaucrat, effective Psychology
+ >=300, title level >=4 and no combat, without consuming the item. Reuse the
+ existing bank, transfers and opening locality. Hardware WASM checks cover
+ requirement feedback, repeated use, filled-bag transfers, movement closure and
+ reconnect; protocol tests cover known closed bags and invalid/stale sources.
+ See [remote bank access](docs/remote-bank.md).
+- [ ] Support wielding Briefcase of Holding and using its equipped page-101
+ source. Implement its researched equip requirements, weapon attacks, specials,
+ OnWear modifiers and OnHit effects, keeping those separate from bank Use.
+ Verify equip/remove, persistence, profession/skill/title boundaries, combat
+ Use rejection, repeated use and failed operations with the native WASM UI.
+- [ ] Research bank CASH/XP semantics and the original server's filled-backpack
+ deletion policy; current zero fields and recursive deletion are reconstruction
+ policies. Also establish the original combat-state producer/expiry and remote
+ bank lifetime after moving or removing the opening Briefcase.
- [ ] Recover the original global reload hotkey producer. CharacterAction 106
closes a bank; the verified reload request is GenericCmd command 5 with the
ammunition and weapon identities. Keep bank-close ammunition regression tests.
diff --git a/docs/bank-storage.md b/docs/bank-storage.md
@@ -133,9 +133,13 @@ action 146, which would cancel the native equip bar while leaving the server's
delayed operation pending. This is a reconstruction policy, not recovered
original-server packet selection.
-Briefcase of Holding (205736) invokes the same bank effect with separate authored
-profession, skill, title-level and combat conditions. Remote bank opening is not
-implemented by ordinary terminal support.
+Briefcase of Holding (205736) opens the same bank from ordinary inventory or
+known carried backpack contents. Its authored Use requirements are Bureaucrat,
+effective Psychology >=300, title level >=4 and no combat. Opening does not
+consume the Briefcase or change its placement. Terminal and portable access
+share the bank snapshot, transfer rules and five-metre opening anchor. See
+[remote bank access](remote-bank.md) for source evidence, verification and the
+remaining wielded-weapon work.
## Verification
diff --git a/docs/remote-bank.md b/docs/remote-bank.md
@@ -0,0 +1,116 @@
+# Remote bank access
+
+Briefcase of Holding (205736, QL100) opens the owner's normal 102-slot bank
+from ordinary inventory or a carried backpack. The server checks Bureaucrat,
+effective Psychology >=300, title level >=4 and no combat. It sends native
+GenericCmd Use success followed by the existing BankIIR and banked Chest
+updates. No item, charge, credit or nano cost is authored for this use.
+
+The terminal and portable item share one bank-opening implementation. Both
+anchor the session at the player's current position and use the existing
+five-metre locality, ownership, transfer, Unique and persistence rules described
+in [bank storage](bank-storage.md). A newer repeated Use sends a fresh snapshot;
+an already processed sequence does nothing. Opening does not change the
+Briefcase's instance, count or location.
+
+## Original evidence
+
+Original 14.9.1 resource `1000020:205736`, offset 566865480, contains a 1309-byte
+payload with SHA-256
+`27472718879a9ad49bbb8adbb421f22d713b34110190b0d5805a6e46d2c1746e`.
+Its decoded authored Use3 requirements are:
+
+| Stat | Predicate |
+| --- | --- |
+| Profession 60 | ==8, Bureaucrat |
+| Psychology 162 | >299 |
+| TitleLevel 37 | >3 |
+| IsFightingMe 410 | ==0 |
+
+The OnUse function is 53092, OpenBank, targeting User with no arguments,
+one tick and no interval. Only this item and terminal 116807 have that function
+in the decoded target-era catalog. The record has neither Eat nor
+UseEmptyDestruct. Its weapon attack/recharge/equip delays and OnHit effects are
+separate events; they do not establish a bank-use timer. Psychology uses the
+original 50% Intelligence / 50% Sense ability weights. The server includes
+ability trickle and supported equipment modifiers when checking the boundary.
+
+Original KKR SHA-256
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`
+establishes the client path:
+
+- `N3Msg_UseItem`, `0x1002acd0`, sees the item's stat-30 Use bit and chooses
+ GenericCmd action 3 despite its weapon category. Ordinary inventory uses
+ page104/native48..77; bag contents use page107/packed `(handle<<16)|slot`.
+- Validators `0x1004d350`/`0x1005e4e0` route owned item pages before world-terminal
+ distance checks. Resolver `0x10061800` uses known Chest handles for page107
+ without requiring a currently open bag window.
+- Template Use validation `0x1008fda0` checks authored Use requirements. The
+ local effect gate `0x100bfb40` excludes 53092, requiring the server response
+ to open the bank.
+- BankIIR activation `0x1007d3a0` replaces the bank contents, opens the window
+ and saves current XYZ; repeated activation does not toggle it closed.
+ Periodic locality `0x100567b0` closes the window and emits action106 beyond
+ five metres. That path may retain the cached BankEntry, unlike explicit
+ teardown `0x1005dc00`; a nonzero cache pointer alone is not an open-window test.
+
+Original DDR SHA-256
+`3c937161de8f690351c3c08e158431417cee9ced77a41b677e7123b61a8c9883`
+toolbar producer `0x10078f90` calls builder `0x10078320`, whose page107 branch
+clears the destination shortcut. The native toolbar therefore does not provide
+a bag-content shortcut; no client change bypasses that behavior.
+
+Retained research is in `local/remote-bank-research/`: `content/` holds exact
+resource bytes and parser identities, `native/` holds the original KKR snapshot
+and 46 validated citations, and `shortcut/` holds the DDR snapshot and 10
+validated citations. The modern
+[AO Universe guide](https://www.ao-universe.com/guides/classic-ao/tradeskill-guides-6/gadgets-5/briefcase-of-holding)
+corroborates inventory/backpack use but postdates the target version; the
+original resources and procedures establish the implementation here.
+
+## Policy boundaries and remaining work
+
+The server requires a known handle, an actually carried portable container
+and a matching child slot. A stale handle to a banked or foreign bag cannot
+open the bank. These ownership checks are server policy; static client evidence
+does not observe an original server accepting crafted requests.
+
+Stat410's original name is IsFightingMe / Number of fighting opponents.
+The implementation uses the server's existing incoming-or-outgoing combat
+predicate. The original producer and expiry of that state, original-server
+repeat policy and the bank's lifetime after source removal remain unresolved.
+
+Wielded page101 Use is established in the original engine but is not yet
+implemented here. The Briefcase still needs weapon/equip support, OnWear
+modifiers and OnHit effects. Its Equip8 predicate lacks the Use3 combat
+restriction, so those events must stay distinct. These are explicit TODOs.
+
+## Verification
+
+Automated tests exercise exact Psychology/title boundaries, ability trickle,
+profession, incoming/outgoing combat, known open/closed bags, unavailable and
+banked sources, invalid actors/sessions, replay, repeated opening, close/reopen
+and durable transfers. A real world connection opens a bag, closes its window
+and successfully uses the Briefcase through the retained page107 handle.
+
+Hardware WASM testing used Chromium with GPU OpenGL4.5, away from any
+terminal. Native right-clicks showed profession, title and skill rejection
+messages locally; these failures sent no Use request. Successful ordinary and
+bag uses received Use success and BankIIR, with capacity102 and occupied slot101
+verified in native memory. Repeated use consumed nothing. A filled backpack
+was withdrawn, opened with its child still in slot20, and redeposited; a
+three-unit stack was withdrawn and redeposited intact. Movement closed the
+window and sent action106. A fresh Use reopened it, and browser reconnect
+preserved every item and allowed bag use again. The attempted bag-content
+toolbar shortcut remained empty, matching the original DDR branch.
+
+SQLite and native-memory checks preserve all six fixture instances, quantities
+and child placements, with no new instance allocation. Browser/adapter errors
+were empty. Evidence is retained in `local/remote-bank-smoke/verification.json`,
+wire captures, screenshots and SQLite/native snapshots. Fixtures are removed
+after testing while the shared LAN preview remains available.
+
+The full `go test ./server/...` suite and two repeated race runs of remote bank,
+bank, backpack, inventory, reload and item-store tests pass. Vet passes with
+`-stdversion=false`; the declared Go version versus existing `WaitGroup.Go`
+usage remains a separate TODO. Logs are in `local/remote-bank-research/`.
diff --git a/server/backpacks.go b/server/backpacks.go
@@ -66,7 +66,7 @@ func (server *server) handleOwnedItemUse(client *worldClient, body []byte) error
binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id ||
binary.BigEndian.Uint32(body[16:20]) != 0 || binary.BigEndian.Uint32(body[24:28]) != 3 || binary.BigEndian.Uint32(body[28:32]) > 1 ||
binary.BigEndian.Uint32(body[32:36]) != 50000 || binary.BigEndian.Uint32(body[36:40]) != client.id ||
- (binary.BigEndian.Uint32(body[40:44]) != 104 && binary.BigEndian.Uint32(body[40:44]) != 102 && binary.BigEndian.Uint32(body[40:44]) != 51017) {
+ (binary.BigEndian.Uint32(body[40:44]) != 104 && binary.BigEndian.Uint32(body[40:44]) != 102 && binary.BigEndian.Uint32(body[40:44]) != 107 && binary.BigEndian.Uint32(body[40:44]) != 51017) {
return nil
}
sequence := binary.BigEndian.Uint32(body[20:24])
@@ -74,12 +74,28 @@ func (server *server) handleOwnedItemUse(client *worldClient, body []byte) error
return nil
}
client.useSequence = sequence
+ if binary.BigEndian.Uint32(body[40:44]) == 107 {
+ // Known carried contents remain usable after their bag window closes.
+ slot := binary.BigEndian.Uint32(body[44:48])
+ bag := client.backpacks[slot>>16].id
+ if bag == 0 || !slices.ContainsFunc(player.inventory.Items, func(item ownedItem) bool { return item.ID == bag && item.isPortableContainer() }) {
+ return nil
+ }
+ for _, item := range player.inventory.Containers[bag] {
+ if item.Slot == slot&65535 {
+ return server.useRemoteBank_locked(client, item, body)
+ }
+ }
+ return nil
+ }
if binary.BigEndian.Uint32(body[40:44]) == 104 {
index := slices.IndexFunc(player.inventory.Items, func(item ownedItem) bool {
return item.Slot == binary.BigEndian.Uint32(body[44:48])
})
if index >= 0 {
switch player.inventory.Items[index].Template {
+ case 205736:
+ return server.useRemoteBank_locked(client, player.inventory.Items[index], body)
case 43330, 29625, 28778:
return server.learnNano_locked(client, index, body)
case 85366:
diff --git a/server/bank.go b/server/bank.go
@@ -100,12 +100,35 @@ func (server *server) handleBankUse(client *worldClient, body []byte) error {
if err := client.send(n3Packet(0x52526858, 50000, client.id, reply)); err != nil || !accepted {
return err
}
+ return server.openBank_locked(client)
+}
+
+func (server *server) useRemoteBank_locked(client *worldClient, item ownedItem, body []byte) error {
+ player := server.characters[client.id]
+ // Briefcase Use3 requires Bureaucrat, Psychology >299, title >3 and no combat.
+ accepted := item.Type == 51018 && item.Template == 205736 && item.Quality == 100 &&
+ player.profession == 8 && player.titleLevel() > 3 &&
+ player.effectiveSkill(162, player.baseStats().TradeRepair.Psychology, gamedata.IPTraining.Weights[162]) > 299 &&
+ !server.characterInCombat_locked(player)
+ reply := append([]byte(nil), body[16:]...)
+ binary.BigEndian.PutUint32(reply, 2)
+ if accepted {
+ binary.BigEndian.PutUint32(reply, 1)
+ }
+ if err := client.send(n3Packet(0x52526858, 50000, client.id, reply)); err != nil || !accepted {
+ return err
+ }
+ return server.openBank_locked(client)
+}
+
+func (server *server) openBank_locked(client *worldClient) error {
+ player := server.characters[client.id]
if client.shop != nil {
if err := server.abortShop_locked(client); err != nil {
return err
}
}
- client.bank = &bankSession{player.playfield, position}
+ client.bank = &bankSession{player.playfield, predictedPosition_locked(player, client, time.Now())}
for _, item := range player.inventory.Bank {
if item.isPortableContainer() {
if err := client.send(backpackPacket(client.id, player.playfield, item, 105)); err != nil {
diff --git a/server/main.go b/server/main.go
@@ -509,7 +509,7 @@ func (server *server) serveWorldClient(client *worldClient) error {
var err error
if len(body) == 56 && binary.BigEndian.Uint32(body[24:28]) == 5 {
err = server.handleReload(client, body)
- } else if len(body) == 48 && (binary.BigEndian.Uint32(body[40:44]) == 102 || binary.BigEndian.Uint32(body[40:44]) == 104 || binary.BigEndian.Uint32(body[40:44]) == 51017) {
+ } else if len(body) == 48 && (binary.BigEndian.Uint32(body[40:44]) == 102 || binary.BigEndian.Uint32(body[40:44]) == 104 || binary.BigEndian.Uint32(body[40:44]) == 107 || binary.BigEndian.Uint32(body[40:44]) == 51017) {
err = server.handleOwnedItemUse(client, body)
} else if len(body) == 48 && binary.BigEndian.Uint32(body[40:44]) == 51035 {
err = server.handleShopUse(client, body)
diff --git a/server/remote_bank_test.go b/server/remote_bank_test.go
@@ -0,0 +1,301 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "testing"
+)
+
+func newRemoteBankWorld(t *testing.T) (*server, *combatTestConn) {
+ t.Helper()
+ world, conn := newBackpackWorld(t)
+ t.Cleanup(func() { world.db.Close() })
+ player := world.characters[1]
+ player.level, player.profession = 100, 8
+ player.position = [3]float32{1100, 20, 700}
+ player.stats.TradeRepair.Psychology = 298
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if granted, err := world.grantItem_locked(player, 205736); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ return world, conn
+}
+
+func TestRemoteBankUsesCarriedInventoryAndKnownBackpackContents(t *testing.T) {
+ for _, placement := range []string{"inventory", "open backpack", "closed backpack"} {
+ t.Run(placement, func(t *testing.T) {
+ world, conn := newRemoteBankWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ request := backpackUseRequest(1, 69, 10)[20:]
+ if placement != "inventory" {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 66, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleInventory(client, backpackMoveRequest(104, 69, 51017, 3, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if placement == "closed backpack" {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 66, 2)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ binary.BigEndian.PutUint32(request[40:44], 107)
+ binary.BigEndian.PutUint32(request[44:48], 1<<16)
+ }
+ before, _ := readTestItemStore(world)
+ conn.packets = nil
+
+ err := world.handleOwnedItemUse(client, request)
+ after, _ := readTestItemStore(world)
+
+ if err != nil || !bytes.Equal(before, after) || client.bank == nil || client.bank.position != player.position || len(conn.packets) != 2 {
+ t.Fatal("carried Briefcase did not open the private bank without consuming state", err)
+ }
+ if binary.BigEndian.Uint32(conn.packets[0][29:33]) != 1 || binary.BigEndian.Uint32(conn.packets[1][16:20]) != 0x343c287f {
+ t.Fatalf("remote bank omitted native Use success or BankIIR: %x", conn.packets)
+ }
+ page, slot := uint32(104), uint32(53)
+ if placement != "inventory" {
+ page, slot = 107, 1<<16
+ }
+ if binary.BigEndian.Uint32(conn.packets[0][53:57]) != page || binary.BigEndian.Uint32(conn.packets[0][57:61]) != slot {
+ t.Fatalf("remote Use changed native source coordinates: %x", conn.packets[0])
+ }
+ })
+ }
+}
+
+func TestRemoteBankUseRequirementBoundaries(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ accepted bool
+ }{
+ {"exact requirements", true}, {"Psychology 299", false}, {"title 3", false},
+ {"other profession", false}, {"outgoing combat", false}, {"incoming combat", false},
+ {"ability trickle", true},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ world, conn := newRemoteBankWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ switch scenario.name {
+ case "Psychology 299":
+ player.stats.TradeRepair.Psychology = 297
+ case "title 3":
+ player.level = 99
+ case "other profession":
+ player.profession = 7
+ case "outgoing combat":
+ player.fighting = 1000000
+ case "incoming combat":
+ world.fighting[1000000] = &character{id: 1000000, fighting: 1}
+ case "ability trickle":
+ player.stats.TradeRepair.Psychology = 297
+ player.stats.Abilities.Intelligence, player.stats.Abilities.Sense = 16, 16
+ }
+ before, _ := readTestItemStore(world)
+ conn.packets = nil
+
+ err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, 1)[20:])
+ after, _ := readTestItemStore(world)
+
+ packets, result := 1, uint32(2)
+ if scenario.accepted {
+ packets, result = 2, 1
+ }
+ if err != nil || !bytes.Equal(before, after) || len(conn.packets) != packets || (client.bank != nil) != scenario.accepted || binary.BigEndian.Uint32(conn.packets[0][29:33]) != result {
+ t.Fatalf("remote Use requirement result differs: %v bank=%+v packets=%x", err, client.bank, conn.packets)
+ }
+ })
+ }
+}
+
+func TestRemoteBankRepeatedUseCloseAndTransfersPreserveBriefcase(t *testing.T) {
+ world, conn := newRemoteBankWorld(t)
+ client := world.clients[1]
+ before, _ := readTestItemStore(world)
+
+ for _, sequence := range []uint32{1, 1, 2} {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, sequence)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if len(conn.packets) != 4 {
+ t.Fatalf("replay or repeat opened the wrong number of banks: %x", conn.packets)
+ }
+ for _, request := range [][]byte{backpackMoveRequest(104, 64, 57005, 1, 111), backpackMoveRequest(105, 0, 50000, 1, 111)} {
+ if err := world.handleInventory(client, request[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := world.handleBankClose(client, characterActionPacket(1, [5]uint32{106})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, 3)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ restarted := newTestInventoryServer(t)
+ t.Cleanup(func() { restarted.db.Close() })
+ after, _ := readTestItemStore(restarted)
+
+ if client.bank == nil || len(world.characters[1].inventory.Bank) != 0 || len(conn.packets) != 8 ||
+ !bytes.Equal(before, after) || restarted.nextItem != 6 {
+ t.Fatal("remote bank consumed the source, lost transfers or failed to reopen")
+ }
+}
+
+func TestRemoteBankRejectsUnavailableCarriedSources(t *testing.T) {
+ for _, scenario := range []string{"unknown handle", "missing child", "banked bag", "foreign handle", "banked briefcase"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newRemoteBankWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ request := backpackUseRequest(1, 69, 10)[20:]
+ if scenario != "banked briefcase" {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 66, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleInventory(client, backpackMoveRequest(104, 69, 51017, 3, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ binary.BigEndian.PutUint32(request[40:44], 107)
+ binary.BigEndian.PutUint32(request[44:48], 1<<16)
+ }
+ switch scenario {
+ case "unknown handle":
+ binary.BigEndian.PutUint32(request[44:48], 2<<16)
+ case "missing child":
+ binary.BigEndian.PutUint32(request[44:48], 1<<16|20)
+ case "foreign handle":
+ client.backpacks[1] = backpackHandle{id: 999}
+ case "banked bag", "banked briefcase":
+ if scenario == "banked bag" {
+ // The bag holds the Briefcase; open through the actual bank terminal.
+ player.playfield = 705
+ player.position = [3]float32{985, 20.2001, 580}
+ if err := world.handleBankUse(client, bankUseRequest(3)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ } else if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, 2)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ slot := uint32(69)
+ if scenario == "banked bag" {
+ slot = 66
+ }
+ if err := world.handleInventory(client, backpackMoveRequest(104, slot, 57005, 1, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if len(player.inventory.Bank) != 1 {
+ t.Fatal("source was not banked")
+ }
+ if err := world.handleBankClose(client, characterActionPacket(1, [5]uint32{106})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ before, _ := readTestItemStore(world)
+ conn.packets = nil
+
+ err := world.handleOwnedItemUse(client, request)
+ after, _ := readTestItemStore(world)
+
+ if err != nil || !bytes.Equal(before, after) || client.bank != nil {
+ t.Fatal("unavailable or non-carried source opened remote storage", err)
+ }
+ for _, packet := range conn.packets {
+ if binary.BigEndian.Uint32(packet[16:20]) != 0x52526858 || binary.BigEndian.Uint32(packet[29:33]) != 2 {
+ t.Fatalf("unavailable source sent success: %x", conn.packets)
+ }
+ }
+ })
+ }
+}
+
+func TestRemoteBankUseRejectsInvalidSessionAndActor(t *testing.T) {
+ for _, scenario := range []string{"actor", "owner", "reply", "action", "mode", "sequence", "dead", "loading", "unready", "stale", "equipment", "old client"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newRemoteBankWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ request := backpackUseRequest(1, 69, 1)[20:]
+ switch scenario {
+ case "actor":
+ binary.BigEndian.PutUint32(request[8:12], 2)
+ case "owner":
+ binary.BigEndian.PutUint32(request[36:40], 2)
+ case "reply":
+ binary.BigEndian.PutUint32(request[16:20], 1)
+ case "action":
+ binary.BigEndian.PutUint32(request[24:28], 5)
+ case "mode":
+ binary.BigEndian.PutUint32(request[28:32], 2)
+ case "sequence":
+ client.useSequence = 1
+ case "dead":
+ player.health = 0
+ case "loading":
+ client.loading = true
+ case "unready":
+ client.ready = false
+ case "stale":
+ world.clients[1] = &worldClient{id: 1}
+ case "equipment":
+ client.equipment = &equipmentMove{}
+ case "old client":
+ client.target = false
+ }
+ before, _ := readTestItemStore(world)
+ conn.packets = nil
+
+ err := world.handleOwnedItemUse(client, request)
+ after, _ := readTestItemStore(world)
+
+ if err != nil || !bytes.Equal(before, after) || client.bank != nil || len(conn.packets) != 0 {
+ t.Fatal("invalid remote use changed storage or acknowledged success", err)
+ }
+ })
+ }
+}
+
+func TestRemoteBankNativeWireUsesClosedBackpackReference(t *testing.T) {
+ fixture, _ := newRemoteBankWorld(t)
+ if err := fixture.handleOwnedItemUse(fixture.clients[1], backpackUseRequest(1, 66, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := fixture.handleInventory(fixture.clients[1], backpackMoveRequest(104, 69, 51017, 3, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ world := newTestInventoryServer(t)
+ t.Cleanup(func() { world.db.Close() })
+ peer := connectZoningClient(t, world, true)
+ for _, sequence := range []uint32{1, 2} {
+ peer.Write(targetPacket(backpackUseRequest(1, 66, sequence)))
+ count := 3
+ if sequence == 2 {
+ count = 2
+ }
+ for range count {
+ if _, err := readPacket(peer); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ request := backpackUseRequest(1, 1<<16, 3)
+ binary.BigEndian.PutUint32(request[60:64], 107)
+ before, _ := readTestItemStore(world)
+
+ peer.Write(targetPacket(request))
+ ack, err := readPacket(peer)
+ if err != nil {
+ t.Fatal(err)
+ }
+ bank, err := readPacket(peer)
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ after, _ := readTestItemStore(world)
+
+ if err != nil || !bytes.Equal(before, after) || world.clients[1].bank == nil || world.clients[1].backpacks[1].open ||
+ binary.BigEndian.Uint32(ack[29:33]) != 1 || binary.BigEndian.Uint32(ack[53:57]) != 107 || binary.BigEndian.Uint32(ack[57:61]) != 1<<16 ||
+ binary.BigEndian.Uint32(bank[16:20]) != 0x343c287f {
+ t.Fatalf("native closed-bag Use did not reach remote bank handling: %v %x %x", err, ack, bank)
+ }
+}