commit c9c4cf5abc0d653059e544ce7ddca142cf55ac64
parent 2c5c5e785b77f1b0478a36cea3ffa7b108b953ca
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 23:20:01 +0000
fix: explicitly refuse unsupported native ground drops
Diffstat:
8 files changed, 460 insertions(+), 2 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -226,6 +226,21 @@ contracts rather than importing later daily missions or expansion rules.
Inventory persistence, protocol evidence and native visual ordering are
recorded in [inventory behavior](docs/inventory.md).
+- [x] [P0] Restore a carried source after an unsupported ground drop. An actual
+ outdoor two-click drop sends original DropTemplateIIR3a243f41, clears the
+ cursor and hides the loaded QL2 pistol while the server still owns it. Check:
+ explicit refusal restores usable carried/backpack sources without ownership
+ writes. Repeated carried/backpack requests, pending equipment, page and
+ fresh-server WASM recovery now retain exact IDs, selected qualities, charges
+ and loaded rounds. See [verified refusal](docs/ground-drops.md).
+- [ ] [P1] Implement original ground dropping and retrieval. Recover the full
+ ground-object identity/creation and DropDynelIIR contracts, position/admission
+ rules, ownership/public pickup and lifetime before moving owned items into
+ world storage. Preserve selected templates, stacks, ammunition and filled
+ bags atomically through failure/retry and native page/cold scene replay.
+ The recovered source/position request and explicit refusal do not complete
+ that behavior. See [ground-drop evidence](docs/ground-drops.md).
+
## Stacks and backpacks
- [ ] [P2] Merge one stackable item type. Check: compatible stacks combine up to the
diff --git a/docs/ground-drops.md b/docs/ground-drops.md
@@ -0,0 +1,81 @@
+# Ground drops: protocol and remaining ownership contract
+
+The shipped14.9.1 help file
+`anarchy-vanilla-14.9.1/cd_image/text/help/The Inventory Window.txt` describes
+left-clicking a carried item, then the ground. The original Funcom manual
+also documents that gesture; a [preserved copy](https://manuals.plus/m/1f4dd17ae346cdbd3c4bb8391f9a059768560b95cd148ed039c288b9bd69cb97)
+contains it on printed page29. File-host publication dates do not date the
+original manual.
+
+## Original client evidence
+
+The original `anarchy-vanilla-14.9.1/kkr.dll` has SHA256
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
+The complete sixteen-record REA bundle is
+`local/ground-drop/original-drop-evidence.json`.
+
+- `n3EngineClientAnarchy_t::N3Msg_DropItem` at1002a520 checks five-metre3D
+ distance, rejects equipment pages below104 and evaluates original surface
+ eligibility. It checks NoDrop0x04000000 on the item and inside a Chest.
+- Constructor1007dfa0 creates `DropTemplateIIR_t`. Reader1007e0b0 and
+ writer1007e100 establish an eight-byte source identity followed by three
+ position floats. Its receiver1007e140 invokes1005f4e0 for a SimpleChar.
+- Receiver1005f4e0 distinguishes template/live rows, rechecks drop admission,
+ removes the inventory row and delivers successful-drop GUI notifications.
+ These functions do not establish the complete server ground-object creation,
+ physical identity, pickup-rights or lifetime contract.
+- The name census also identifies a `DropDynelIIR_t` hash candidate47483633;
+ its producer, complete payload and relationship to world updates remain open.
+ The separate exported1002bc80 builds an ActionDrop request; it is not proof
+ that its ActionData payload is the DropDynelIIR body.
+
+Evidence IDs for producer/constructor/reader/writer/receiver are
+`ev_fd00e28efeb10903b3642abe4727971f8927597cda303183ff85fc15364990eb`,
+`ev_0a269971f698621ae71a994d6cf789c2e4e7aff08926a639a7d43771a2a51bb1`,
+`ev_a5abd9e7bacd85724829c31c58b86a8f6f9e72c0b6e820261530d70be7d1db8d`,
+`ev_3dc2ec7106320282a0baad82b88f43f49f822fcba596536ccd4dc17b544f6436`
+and `ev_47089a5d0d368b5dfffe3ad898f5d657a255ea672e624e742ad7725f47f13f12`.
+
+## Native reproduction and refusal
+
+An ordinary outdoor two-click drop at a controlled Parnassos checkpoint sends
+opcode3a243f41 with source104:48 and position
+`[320.18747,0,191.76025]`. The cursor clears and the pistol icon becomes hidden,
+but the unanswered request leaves server item1 owned at slot64: template123742,
+QL2 and three loaded rounds. Two other carried items and the five original
+world resources remain unchanged. The global high-water mark stays8.
+
+The server now routes this request through authenticated inventory handling and
+decodes only an ordinary source slot. Unsupported ground ownership is refused
+with source correction and original feedback text. Known carried-backpack
+sources use their unchanged packed identity. The refusal does not move or
+delete the item, allocate a world instance or claim successful original dropping.
+Active trade/shop sessions retain the existing inventory-action cancellation
+policy. Zero-write regression checks cover standalone and pending-equipment
+refusals; they do not assert that cancelling an active draft performs no writes.
+
+Indoor two-click and held-drag trials did not emit this request; the two-click
+trial left the item on the cursor. Those observations do not prove an original
+indoor restriction or a server-side loss. Full canonical ground transfers remain
+an open TODO alongside the immediate disappearing-icon fix.
+
+## Verification
+
+`TestGroundDropRefusalPreservesOwnedSourcesAndEquipment` covers carried and
+open/closed backpack sources, a separate/admitted pending equip, foreign actors,
+unknown handles, invalid slots and worn-page refusals. Two repeats preserve
+ownership, selected qualities, loaded rounds, handles and deadlines with zero
+standalone ownership writes. Native source decoding tests preserve all position
+bytes at both inventory boundaries and leave packed backpack positions intact.
+
+`TestBrowserGroundDropRefusal` sends two actual carried requests and a packed
+backpack request, then normally withdraws the retained pistol. Page and fresh
+server/WASM recovery preserve three owned IDs, the laboratory's three charges,
+the pistol's three loaded rounds, all five original resource placements and
+global counter8. The phases pass in 16.69/8.68 seconds under
+`local/ground-drop/20261103-151542/` with six clean traces.
+
+Related Go checks pass70roots/276results, focused race checks pass4/15, and vet
+and driver syntax checks pass. `local/ground-drop/verification.json` independently
+checks the failed original request, actual refusal packets, absence of success
+echoes, native endpoint pairs, exact physical ledgers and shipped-binary evidence.
diff --git a/server/browser_ground_drop_test.go b/server/browser_ground_drop_test.go
@@ -0,0 +1,84 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserGroundDropRefusal(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for native ground-drop inspection")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/ground-drop", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.playfield, player.position = 500, [3]float32{320.12518, .7511, 194.0258}
+ player.rotation = [4]float32{0, 1, 0, 0}
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("ground-drop")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := playerInventory{LastID: 3, Items: []ownedItem{
+ {ID: 1, Type: 51018, Template: 123742, Quality: 2, Slot: 64, Count: 1, Ammo: 3},
+ {ID: 2, Type: 51017, Template: 99228, Quality: 1, Slot: 65, Count: 1},
+ {ID: 3, Type: 51005, Template: 25812, Quality: 2, Slot: 66, Count: 3}}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.db.Close(); err != nil {
+ t.Fatal(err)
+ }
+ for _, phase := range []string{"refusal", "cold"} {
+ t.Run(phase, func(t *testing.T) {
+ world := newServerForTest(t)
+ player := world.characters[1]
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory, "worldItems": len(world.worldItems), "lastID": world.nextItem})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_ground_drop.mjs"), host.URL, filepath.Join(output, phase), phase)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+
+ t.Logf("Browser artifacts: %s", output)
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ if len(player.inventory.Items) != 3 || len(player.inventory.Containers) != 0 || world.nextItem != 8 || len(world.worldItems) != 5 {
+ t.Fatal("ground-drop refusal changed item ownership, contents or allocation")
+ }
+ for _, item := range inventory.Items {
+ if !slices.Contains(player.inventory.Items, item) {
+ t.Fatal("ground-drop refusal changed an exact owned item", item)
+ }
+ }
+ })
+ if t.Failed() {
+ return
+ }
+ }
+}
diff --git a/server/ground_drop_test.go b/server/ground_drop_test.go
@@ -0,0 +1,140 @@
+package main
+
+import (
+ "bytes"
+ "cmp"
+ "encoding/binary"
+ "maps"
+ "math"
+ "reflect"
+ "slices"
+ "testing"
+)
+
+func groundDropPacket(owner, page, slot uint32) []byte {
+ var body []byte
+ for _, value := range []uint32{page, slot, math.Float32bits(320.18747), 0, math.Float32bits(191.76025)} {
+ body = binary.BigEndian.AppendUint32(body, value)
+ }
+ return n3Packet(0x3a243f41, 50000, owner, body)
+}
+
+func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
+ for _, scenario := range []string{"carried", "backpack", "closed backpack", "separate pending", "admitted pending", "foreign actor", "unknown handle", "outside", "worn page"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ for _, template := range []uint32{99228, 123742} {
+ if granted, err := world.grantItem_locked(player, template); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ }
+ player.inventory.Items[2].Quality, player.inventory.Items[2].Ammo = 2, 3
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ request := groundDropPacket(1, 104, 66)[20:]
+ switch scenario {
+ case "backpack", "closed backpack":
+ if err := world.handleInventory(client, backpackMoveRequest(104, 66, 51017, 2, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ request = groundDropPacket(1, 107, 1<<16)[20:]
+ if scenario == "closed backpack" {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 2)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ case "separate pending", "admitted pending":
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("axe did not begin its admitted move", err)
+ }
+ if scenario == "admitted pending" {
+ request = groundDropPacket(1, 104, 64)[20:]
+ }
+ case "foreign actor":
+ request = groundDropPacket(2, 104, 66)[20:]
+ case "unknown handle":
+ request = groundDropPacket(1, 107, 2<<16)[20:]
+ case "outside":
+ request = groundDropPacket(1, 104, 94)[20:]
+ case "worn page":
+ request = groundDropPacket(1, 101, 6)[20:]
+ }
+ handles := maps.Clone(client.backpacks)
+ var pending equipmentMove
+ if client.equipment != nil {
+ pending = *client.equipment
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ auditCheckpointWrites(t, world)
+ conn.packets = nil
+
+ for range 2 {
+ if err := world.handleInventory(client, request); err != nil {
+ t.Fatal(err)
+ }
+ }
+ after, err := readTestItemStore(world)
+ cold := newTestInventoryServer(t).characters[1].inventory
+ expected := player.inventory
+ expected.Items = slices.Clone(expected.Items)
+ slices.SortFunc(expected.Items, func(a, b ownedItem) int { return cmp.Compare(a.ID, b.ID) })
+ cold.Items = slices.Clone(cold.Items)
+ slices.SortFunc(cold.Items, func(a, b ownedItem) int { return cmp.Compare(a.ID, b.ID) })
+
+ if err != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 ||
+ !reflect.DeepEqual(expected, cold) || !reflect.DeepEqual(handles, client.backpacks) || world.nextItem != 3 ||
+ (scenario == "separate pending" || scenario == "admitted pending") != (client.equipment != nil) ||
+ client.equipment != nil && *client.equipment != pending {
+ t.Fatal("ground-drop refusal changed ownership, writes, handles or admitted equipment", err)
+ }
+ var replies [][]byte
+ switch scenario {
+ case "carried", "separate pending":
+ replies = [][]byte{targetPacket(itemMovePacket(1, 66, 64)), targetPacket(itemMovePacket(1, 64, 66))}
+ case "backpack", "closed backpack":
+ replies = [][]byte{targetPacket(characterActionPacket(1, [5]uint32{146, 107, 1 << 16}))}
+ }
+ if len(replies) == 0 {
+ if len(conn.packets) != 0 {
+ t.Fatal("unknown or admitted source received a correction")
+ }
+ return
+ }
+ if len(conn.packets) != 2*(len(replies)+1) {
+ t.Fatal("each refusal needs source correction and feedback", len(conn.packets))
+ }
+ for repeat := range 2 {
+ start := repeat * (len(replies) + 1)
+ if !reflect.DeepEqual(conn.packets[start:start+len(replies)], replies) {
+ t.Fatal("incorrect refused ground-drop source correction")
+ }
+ feedback := conn.packets[start+len(replies)]
+ if binary.BigEndian.Uint32(feedback[16:20]) != 0x5f4b442a ||
+ string(feedback[33:33+binary.BigEndian.Uint32(feedback[29:33])]) != "You are not able to drop this item." {
+ t.Fatal("missing ground-drop refusal feedback")
+ }
+ }
+ })
+ }
+}
+
+func TestGroundDropNativeSourceDecodingPreservesPosition(t *testing.T) {
+ for _, scenario := range [][3]uint32{{104, 48, 64}, {104, 77, 93}, {104, 47, 94}, {104, 78, 94}, {107, 65536, 65536}} {
+ body := groundDropPacket(1, scenario[0], scenario[1])[20:]
+ position := slices.Clone(body[24:])
+
+ decodeInventory1491(body)
+
+ if binary.BigEndian.Uint32(body[20:24]) != scenario[2] || !bytes.Equal(position, body[24:]) {
+ t.Fatalf("ground drop changed its position or packed source: %x", body)
+ }
+ }
+}
diff --git a/server/inventory.go b/server/inventory.go
@@ -232,7 +232,7 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
if key == 0x5e477770 && binary.BigEndian.Uint32(body[16:20]) == 52 {
return server.syncStacks_locked(client)
}
- if key == 0x47537a24 {
+ if key == 0x47537a24 || key == 0x3a243f41 {
return client.send(characterActionPacket(client.id, [5]uint32{146, binary.BigEndian.Uint32(body[16:20]), binary.BigEndian.Uint32(body[20:24])}))
}
return nil
@@ -242,6 +242,37 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
return err
}
}
+ if key == 0x3a243f41 {
+ // Ground storage is unsupported; restore only a validated owned source.
+ page, slot := binary.BigEndian.Uint32(body[16:20]), binary.BigEndian.Uint32(body[20:24])
+ var packets [][]byte
+ if page == 104 {
+ index := slices.IndexFunc(character.inventory.Items, func(item ownedItem) bool { return item.Slot == slot })
+ if slot < 64 || slot >= 94 || index < 0 || client.equipment != nil && character.inventory.Items[index].ID == client.equipment.itemID {
+ return nil
+ }
+ packets = equipmentCorrectionPackets(client.id, slot)
+ } else if page == 107 {
+ bag := client.backpacks[slot>>16].id
+ if bag == 0 || !slices.ContainsFunc(character.inventory.Items, func(item ownedItem) bool { return item.ID == bag && item.isPortableContainer() }) ||
+ !slices.ContainsFunc(character.inventory.Containers[bag], func(item ownedItem) bool { return item.Slot == slot&65535 }) {
+ return nil
+ }
+ packets = [][]byte{characterActionPacket(client.id, [5]uint32{146, page, slot})}
+ } else {
+ return nil
+ }
+ for _, packet := range packets {
+ if err := client.send(packet); err != nil {
+ return err
+ }
+ }
+ text := "You are not able to drop this item."
+ feedback := binary.BigEndian.AppendUint32(nil, uint32(len(text)))
+ feedback = append(feedback, text...)
+ feedback = append(feedback, 0, 0)
+ return client.send(n3Packet(0x5f4b442a, 50000, client.id, feedback))
+ }
if key == 0x5e477770 && binary.BigEndian.Uint32(body[20:24]) == 107 && binary.BigEndian.Uint32(body[24:28])>>16 != 0 {
return server.handleBackpackAction_locked(client, body)
}
diff --git a/server/main.go b/server/main.go
@@ -562,7 +562,7 @@ func (server *server) serveWorldClient(client *worldClient) error {
if err != nil {
return err
}
- case 0x47537a24:
+ case 0x47537a24, 0x3a243f41:
if err := server.handleInventory(client, body); err != nil {
return err
}
diff --git a/server/target_protocol.go b/server/target_protocol.go
@@ -178,6 +178,10 @@ func decodeInventory1491(body []byte) {
return
}
switch binary.BigEndian.Uint32(body) {
+ case 0x3a243f41:
+ if binary.BigEndian.Uint32(body[16:20]) == 104 {
+ binary.BigEndian.PutUint32(body[20:24], decodeInventorySlot1491(binary.BigEndian.Uint32(body[20:24])))
+ }
case 0x47537a24:
if binary.BigEndian.Uint32(body[16:20]) == 104 {
binary.BigEndian.PutUint32(body[20:24], decodeInventorySlot1491(binary.BigEndian.Uint32(body[20:24])))
diff --git a/tools/client/test_ground_drop.mjs b/tools/client/test_ground_drop.mjs
@@ -0,0 +1,103 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output, phase] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'ground-drop', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const cell = (state, type, slot) => state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === type && cell.identity[1] === slot && !cell.dummy);
+ const clickCell = async item => game.click((item.bounds[0] + item.bounds[2]) / 2, (item.bounds[1] + item.bounds[3]) / 2);
+ const inventory = async () => {
+ if (!game.state.grids.some(grid => grid.totalCells === 30)) await game.key('KeyI');
+ };
+ await page.goto(url);
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ await game.snapshot();
+ await inventory();
+ if (phase === 'refusal') {
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ const point = await game.point(500, 400);
+ await page.mouse.move(point.x, point.y);
+ await page.mouse.down({button: 'right'});
+ try {
+ await page.mouse.move(point.x, point.y + 150, {steps: 8});
+ await game.snapshot();
+ } finally { await page.mouse.up({button: 'right'}); }
+ evidence.before = await server();
+ await game.save(output + '/before');
+ const drop = async (type, slot) => {
+ await clickCell(cell(game.state, type, slot));
+ await game.wait('owned drop source picked', state => state.dragged[0] === type && state.dragged[1] === slot);
+ const sequence = game.sequence;
+ await game.click(500, 580);
+ await game.wait('actual ground-drop request', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '3a243f41' &&
+ Buffer.from(event.hex, 'hex').readUInt32BE(29) === type && Buffer.from(event.hex, 'hex').readUInt32BE(33) === slot));
+ await game.wait('refused ground-drop source restored', state => cell(state, type, slot) && game.events.some(event =>
+ event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '5f4b442a' &&
+ Buffer.from(event.hex, 'hex').toString('ascii', 33, 68) === 'You are not able to drop this item.'));
+ assert.deepEqual(game.state.dragged, [0, 0]);
+ };
+ await drop(104, 48);
+ evidence.refused = await server();
+ assert.deepEqual(evidence.refused, evidence.before);
+ await game.save(output + '/refused');
+ await drop(104, 48);
+ assert.deepEqual(await server(), evidence.before);
+
+ // Move the same pistol into its own bag and refuse its packed drop source.
+ const bag = cell(game.state, 104, 49);
+ await game.click((bag.bounds[0] + bag.bounds[2]) / 2, (bag.bounds[1] + bag.bounds[3]) / 2, 'right');
+ await game.wait('carried backpack opens', state => state.grids.some(grid => grid.totalCells === 21));
+ await clickCell(cell(game.state, 104, 48));
+ await game.wait('pistol picked for deposit', state => state.dragged[0] === 104 && state.dragged[1] === 48);
+ await clickCell(game.state.grids.find(grid => grid.totalCells === 21).cells[0]);
+ await game.wait('same pistol deposited', state => cell(state, 107, 65536) && !game.local(state).inventory.some(item => item.id === 1));
+ evidence.bagged = await server();
+ assert.deepEqual(evidence.bagged.inventory.Containers[2], [{ID: 1, Type: 51018, Template: 123742, Quality: 2, Slot: 0, Count: 1, Ammo: 3}]);
+ await drop(107, 65536);
+ evidence.bagRefused = await server();
+ assert.deepEqual(evidence.bagRefused, evidence.bagged);
+ await game.save(output + '/bag-refused');
+ await clickCell(cell(game.state, 107, 65536));
+ await game.wait('retained pistol picked for withdrawal', state => state.dragged[0] === 107 && state.dragged[1] === 65536);
+ await clickCell(game.state.grids.find(grid => grid.totalCells === 30).cells.find(item => item.identity[0] === 0));
+ await game.wait('refused pistol remains normally withdrawable', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === 48));
+ evidence.after = await server();
+ assert.deepEqual(evidence.after.inventory.Items.toSorted((a, b) => a.ID - b.ID), evidence.before.inventory.Items);
+ assert.equal(evidence.after.worldItems, 5);
+ assert.equal(evidence.after.lastID, 8);
+ await game.save(output + '/withdrawn');
+ await page.reload();
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ await game.snapshot();
+ assert.deepEqual(await server(), evidence.after);
+ await inventory();
+ }
+ assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot, item.templates, item.quality, item.count]), [
+ [1, 48, [123742, 123743], 2, 1], [2, 49, [99228, 99228], 1, 1], [3, 50, [25812, 25811], 2, 3]]);
+ evidence.final = await server();
+ assert.equal(evidence.final.inventory.Items.find(item => item.ID === 1).Ammo, 3);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS: carried/backpack ground-drop refusals restore sources; repeated input and page/cold retain IDs, selected qualities, charges and loaded rounds');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}