commit 94b59283b0cc74eaec5d5a89f9d373c2c2e8af3f
parent a22151736837f0ebf9b192ac3665c08ed550a902
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 04:47:45 +0000
Clear empty carried sources after stale ground-drop requests
Diffstat:
6 files changed, 166 insertions(+), 7 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -4079,6 +4079,13 @@ and server restarts. Turn every reproduced bug into a focused regression test.
instances. First/last carried rows and invalid/pending requests have handler
checks. The broader disappearance audit remains open. See
[stale carried sources](docs/inventory.md#stale-carried-move-sources).
+- [x] [P0] Clear an empty carried source after a stale ground drop. A controlled
+ completed backpack deposit leaves the old carried icon visible; native dropping
+ sends a real request that previously received no response. Cancellation then
+ clearing of only that empty row now permits native withdrawal of the exact
+ retained pistol. Both carried boundaries, repeats, pending guards, zero writes
+ and page/cold conservation pass. The broader disappearance audit remains open.
+ See [stale ground sources](docs/ground-drops.md#stale-carried-ground-drop-sources).
- [x] [P0] Refresh stale reclaim withdrawals. Reproduction: a controlled earlier
collection/bank transfer leaves an old native source visible; clicking its
already-collected snapshot slot receives no reply and hides the icon. Source
diff --git a/docs/ground-drops.md b/docs/ground-drops.md
@@ -109,3 +109,32 @@ 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.
+
+## Stale carried ground-drop sources
+
+A completed controlled backpack deposit can leave an old carried icon visible
+when its refresh is withheld. Native two-click dropping of that icon sends
+DropTemplate104:48, but the server previously ignored the now-empty source.
+The client hid the icon without receiving a refusal. The pistol remained in
+its actual backpack; this was a stale-view defect, not a durable item loss.
+
+For an idle owner and a valid empty carried slot, the refusal now sends action146
+to cancel the pending source, then action112 to clear only that empty row, then
+the existing refusal text. It neither destroys the detached item nor changes
+ownership, creates a ground object or allocates an identity. Pending-equipment,
+foreign-actor, invalid-slot and unsupported-page guards remain in effect.
+
+The focused handler check first failed with zero replies at both saved slots64
+and93. It now verifies repeated cancellation/clear/refusal, exact cold ownership
+and zero checkpoint writes. Related focused checks pass5 roots/25 results;
+vet and driver syntax checks pass.
+
+The added `stale` phase of `TestBrowserGroundDropRefusal` uses controlled
+ownership and withheld publication, not earned progression. Its original
+request timed out under `local/ground-drop/20261103-204413/`. The corrected
+run at `local/ground-drop/20261103-204559/` clears the stale row, opens the real
+backpack and withdraws the same physical pistol through native input. Page and
+fresh-server recovery retain all three items, selected QLs, three loaded rounds,
+three laboratory charges, five original world resources and global counter8.
+The stale phase passes in16.11 seconds; ordinary refusal and cold phases also
+pass. All ten retained traces are free of client errors and dropped events.
diff --git a/server/browser_ground_drop_test.go b/server/browser_ground_drop_test.go
@@ -41,7 +41,7 @@ func TestBrowserGroundDropRefusal(t *testing.T) {
if err := world.db.Close(); err != nil {
t.Fatal(err)
}
- for _, phase := range []string{"refusal", "cold"} {
+ for _, phase := range []string{"refusal", "stale", "cold"} {
t.Run(phase, func(t *testing.T) {
world := newServerForTest(t)
player := world.characters[1]
@@ -52,6 +52,23 @@ func TestBrowserGroundDropRefusal(t *testing.T) {
defer world.mutex.Unlock()
json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory, "worldItems": len(world.worldItems), "lastID": world.nextItem})
})
+ // Isolate a completed bag deposit without publishing its source refresh.
+ mux.HandleFunc("POST /test-stale-source", func(w http.ResponseWriter, r *http.Request) {
+ world.updateMutex.Lock()
+ defer world.updateMutex.Unlock()
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ inventory := player.inventory
+ index := slices.IndexFunc(inventory.Items, func(item ownedItem) bool { return item.ID == 1 })
+ item := inventory.Items[index]
+ item.Slot = 0
+ inventory.Items = slices.Delete(slices.Clone(inventory.Items), index, index+1)
+ inventory.Containers = map[uint32][]ownedItem{2: {item}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Error(err)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
+ })
host := httptest.NewServer(mux)
t.Cleanup(host.Close)
closeTestBrowserStreams(t, world)
diff --git a/server/ground_drop_test.go b/server/ground_drop_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"cmp"
"encoding/binary"
+ "fmt"
"maps"
"math"
"reflect"
@@ -20,7 +21,7 @@ func groundDropPacket(owner, page, slot uint32) []byte {
}
func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
- for _, scenario := range []string{"carried", "backpack", "closed backpack", "separate pending", "admitted pending", "foreign actor", "unknown handle", "outside", "worn page"} {
+ for _, scenario := range []string{"carried", "backpack", "closed backpack", "separate pending", "admitted pending", "stale 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]
@@ -48,13 +49,16 @@ func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
t.Fatal(err)
}
}
- case "separate pending", "admitted pending":
+ case "separate pending", "admitted pending", "stale 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:]
}
+ if scenario == "stale pending" {
+ request = groundDropPacket(1, 104, 67)[20:]
+ }
case "foreign actor":
request = groundDropPacket(2, 104, 66)[20:]
case "unknown handle":
@@ -91,7 +95,7 @@ func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
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) ||
+ (scenario == "separate pending" || scenario == "admitted pending" || scenario == "stale pending") != (client.equipment != nil) ||
client.equipment != nil && *client.equipment != pending {
t.Fatal("ground-drop refusal changed ownership, writes, handles or admitted equipment", err)
}
@@ -138,3 +142,55 @@ func TestGroundDropNativeSourceDecodingPreservesPosition(t *testing.T) {
}
}
}
+
+func TestStaleGroundDropClearsOnlyEmptyCarriedSource(t *testing.T) {
+ for _, source := range []uint32{64, 93} {
+ t.Run(fmt.Sprint(source), func(t *testing.T) {
+ world, output := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ inventory := player.inventory
+ item := inventory.Items[0]
+ item.Slot = 0
+ inventory.Bank = []ownedItem{item}
+ inventory.Items = nil
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ output.packets = nil
+ auditCheckpointWrites(t, world)
+
+ for range 2 {
+ if err := world.handleInventory(client, groundDropPacket(1, 104, source)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ after, err := readTestItemStore(world)
+ cold := newTestInventoryServer(t)
+
+ if err != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 ||
+ !reflect.DeepEqual(player.inventory, inventory) || !reflect.DeepEqual(cold.characters[1].inventory, inventory) ||
+ world.nextItem != 1 || cold.nextItem != 1 || len(output.packets) != 6 {
+ t.Fatal("stale ground drop changed ownership or omitted correction", err, len(output.packets))
+ }
+ for repeat := range 2 {
+ for index, action := range []uint32{146, 112} {
+ packet := output.packets[repeat*3+index]
+ if binary.BigEndian.Uint32(packet[16:20]) != 0x5e477770 ||
+ binary.BigEndian.Uint32(packet[29:33]) != action || binary.BigEndian.Uint32(packet[33:37]) != 104 ||
+ binary.BigEndian.Uint32(packet[37:41]) != source-16 || binary.BigEndian.Uint64(packet[41:49]) != 0 {
+ t.Fatalf("stale ground drop did not cancel/clear only its source: %x", packet)
+ }
+ }
+ feedback := output.packets[repeat*3+2]
+ 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")
+ }
+ }
+ })
+ }
+}
diff --git a/server/inventory.go b/server/inventory.go
@@ -248,10 +248,16 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
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 {
+ if slot < 64 || slot >= 94 || client.equipment != nil && (index < 0 || character.inventory.Items[index].ID == client.equipment.itemID) {
return nil
}
- packets = equipmentCorrectionPackets(client.id, slot)
+ if index < 0 {
+ // Cancel the stale source before clearing its now-empty carried row.
+ packets = [][]byte{characterActionPacket(client.id, [5]uint32{146, 104, slot}),
+ characterActionPacket(client.id, [5]uint32{112, 104, slot})}
+ } else {
+ 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() }) ||
diff --git a/tools/client/test_ground_drop.mjs b/tools/client/test_ground_drop.mjs
@@ -27,7 +27,7 @@ try {
await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
await game.snapshot();
await inventory();
- if (phase === 'refusal') {
+ if (phase === 'stale' || 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);
@@ -36,6 +36,50 @@ try {
await page.mouse.move(point.x, point.y + 150, {steps: 8});
await game.snapshot();
} finally { await page.mouse.up({button: 'right'}); }
+ }
+ if (phase === 'stale') {
+ assert((await page.request.post(url + '/test-stale-source')).ok());
+ evidence.transferred = await server();
+ assert.deepEqual(evidence.transferred.inventory.Containers[2], [
+ {ID: 1, Type: 51018, Template: 123742, Quality: 2, Slot: 0, Count: 1, Ammo: 3}]);
+ assert(!evidence.transferred.inventory.Items.some(item => item.ID === 1));
+ await game.save(output + '/stale');
+ await clickCell(cell(game.state, 104, 48));
+ await game.wait('stale drop source picked', state => state.dragged[0] === 104 && state.dragged[1] === 48);
+ const sequence = game.sequence;
+ await game.click(500, 580);
+ await game.wait('actual stale ground-drop request', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '3a243f41' &&
+ Buffer.from(event.hex, 'hex').readUInt32BE(29) === 104 && Buffer.from(event.hex, 'hex').readUInt32BE(33) === 48));
+ evidence.afterRequest = await server();
+ assert.deepEqual(evidence.afterRequest, evidence.transferred);
+ await game.wait('stale ground-drop source cancelled and cleared', state => !cell(state, 104, 48) &&
+ state.dragged[0] === 0 && game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framereceived' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 146) &&
+ game.events.some(event => event.sequence > sequence && event.direction === 'framereceived' &&
+ event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 112));
+ await game.save(output + '/cleared');
+
+ // The same physical source must remain available through its actual bag.
+ 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('actual retained source opens', state => cell(state, 107, 65536));
+ await clickCell(cell(game.state, 107, 65536));
+ await game.wait('retained source picked', 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('same physical source withdrawn', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === 48));
+ evidence.withdrawn = await server();
+ assert.equal(evidence.withdrawn.inventory.Items.find(item => item.ID === 1).Ammo, 3);
+ assert.equal(evidence.withdrawn.inventory.Containers, null);
+ 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.withdrawn);
+ await inventory();
+ }
+ if (phase === 'refusal') {
evidence.before = await server();
await game.save(output + '/before');
const drop = async (type, slot) => {