commit 972e0266067e26c1151f9638977e0db45731c0ec
parent 94b59283b0cc74eaec5d5a89f9d373c2c2e8af3f
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 04:54:58 +0000
Refresh stale backpack ground-drop sources
Diffstat:
6 files changed, 127 insertions(+), 9 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -4086,6 +4086,13 @@ and server restarts. Turn every reproduced bug into a focused regression test.
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 backpack ground-drop sources. A controlled within-bag
+ move leaves an old native icon whose drop previously received no reply.
+ Cancel the valid packed source and refresh an open bag from current contents;
+ closed bags stay closed. Native same-window withdrawal and page/cold recovery
+ retain the exact loaded pistol and all other instances. Repeats, invalid
+ handles/slots and zero ownership writes have focused checks. See
+ [stale contained sources](docs/ground-drops.md#stale-backpack-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
@@ -138,3 +138,33 @@ 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.
+
+## Stale backpack ground-drop sources
+
+The same missing-reply defect also affected a known backpack handle after its
+contents moved. A controlled move from bag slot0 to1 withholds its refresh;
+native dropping still sends packed source107:65536. The original server handler
+returns no response even though the pistol is durably owned in slot1.
+
+The refusal now cancels a valid source in a known owned bag. If that source is
+empty and the bag is open, it also publishes current contents. A closed bag is
+not reopened. Unknown handles, foreign actors and positions beyond slot20 do
+not receive a correction. Repeated open/closed stale requests preserve exact
+ownership, handles and cold state with zero checkpoint writes. The focused Go
+group passes5 roots/28 results; vet and driver syntax checks pass.
+
+The actual native baseline is retained in
+`local/ground-drop/20261103-205035/stale-contained/`. An earlier trial stopped
+before opening the bag and is not defect evidence. The combined verification
+run also hit this input ordering issue before exercising the new path; its
+ordinary and stale-carried phases passed. The final fixture opens/deposits
+before adjusting the camera and waits for the camera's mouse release to be
+consumed.
+
+The targeted corrected run at `local/ground-drop/20261103-205320/` passes the
+contained phase in15.72 seconds and fresh-server phase in8.45 seconds. Native
+refresh exposes slot1, withdrawal retains physical pistol1 with its exact QL2
+and three loaded rounds, and page/cold recovery conserves the bag, three-charge
+laboratory, five original world resources and allocator8. All five traces are
+free of client errors and dropped events. This is controlled stale-view evidence;
+canonical ground-object transfers remain open.
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", "stale", "cold"} {
+ for _, phase := range []string{"refusal", "stale", "stale-contained", "cold"} {
t.Run(phase, func(t *testing.T) {
world := newServerForTest(t)
player := world.characters[1]
@@ -69,6 +69,20 @@ func TestBrowserGroundDropRefusal(t *testing.T) {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
+ mux.HandleFunc("POST /test-stale-contained-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
+ item := inventory.Containers[2][0]
+ item.Slot = 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
@@ -21,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", "stale pending", "foreign actor", "unknown handle", "outside", "worn page"} {
+ for _, scenario := range []string{"carried", "backpack", "closed backpack", "stale backpack", "stale closed backpack", "outside 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]
@@ -39,12 +39,24 @@ func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
}
request := groundDropPacket(1, 104, 66)[20:]
switch scenario {
- case "backpack", "closed backpack":
+ case "backpack", "closed backpack", "stale backpack", "stale closed backpack", "outside 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 scenario == "stale backpack" || scenario == "stale closed backpack" {
+ inventory := player.inventory
+ item := inventory.Containers[2][0]
+ item.Slot = 1
+ inventory.Containers = map[uint32][]ownedItem{2: {item}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if scenario == "outside backpack" {
+ request = groundDropPacket(1, 107, 1<<16|21)[20:]
+ }
+ if scenario == "closed backpack" || scenario == "stale closed backpack" {
if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 2)[20:]); err != nil {
t.Fatal(err)
}
@@ -103,8 +115,12 @@ func TestGroundDropRefusalPreservesOwnedSourcesAndEquipment(t *testing.T) {
switch scenario {
case "carried", "separate pending":
replies = [][]byte{targetPacket(itemMovePacket(1, 66, 64)), targetPacket(itemMovePacket(1, 64, 66))}
- case "backpack", "closed backpack":
+ case "backpack", "closed backpack", "stale closed backpack":
replies = [][]byte{targetPacket(characterActionPacket(1, [5]uint32{146, 107, 1 << 16}))}
+ case "stale backpack":
+ replies = [][]byte{targetPacket(characterActionPacket(1, [5]uint32{146, 107, 1 << 16})),
+ targetPacket(backpackInventoryPacket(1, 2, 1, []ownedItem{
+ {ID: 3, Type: 51018, Template: 123742, Quality: 2, Slot: 1, Count: 1, Ammo: 3}}))}
}
if len(replies) == 0 {
if len(conn.packets) != 0 {
diff --git a/server/inventory.go b/server/inventory.go
@@ -260,11 +260,15 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
}
} 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 }) {
+ if bag == 0 || slot&65535 >= 21 ||
+ !slices.ContainsFunc(character.inventory.Items, func(item ownedItem) bool { return item.ID == bag && item.isPortableContainer() }) {
return nil
}
packets = [][]byte{characterActionPacket(client.id, [5]uint32{146, page, slot})}
+ if client.backpacks[slot>>16].open &&
+ !slices.ContainsFunc(character.inventory.Containers[bag], func(item ownedItem) bool { return item.Slot == slot&65535 }) {
+ packets = append(packets, backpackInventoryPacket(client.id, bag, slot>>16, character.inventory.Containers[bag]))
+ }
} else {
return nil
}
diff --git a/tools/client/test_ground_drop.mjs b/tools/client/test_ground_drop.mjs
@@ -27,7 +27,16 @@ try {
await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
await game.snapshot();
await inventory();
- if (phase === 'stale' || phase === 'refusal') {
+ if (phase === 'stale-contained') {
+ 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('backpack opened for contained source', state => state.grids.some(grid => grid.totalCells === 21));
+ await clickCell(cell(game.state, 104, 48));
+ await game.wait('pistol picked for contained source', state => state.dragged[0] === 104 && state.dragged[1] === 48);
+ await clickCell(game.state.grids.find(grid => grid.totalCells === 21).cells[0]);
+ await game.wait('pistol deposited for contained source', state => cell(state, 107, 65536));
+ }
+ if (phase === 'stale' || phase === 'stale-contained' || 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);
@@ -35,7 +44,45 @@ try {
try {
await page.mouse.move(point.x, point.y + 150, {steps: 8});
await game.snapshot();
- } finally { await page.mouse.up({button: 'right'}); }
+ } finally {
+ const release = game.sequence;
+ await page.mouse.up({button: 'right'});
+ await game.waitInput(release, 1026);
+ }
+ }
+ if (phase === 'stale-contained') {
+ assert((await page.request.post(url + '/test-stale-contained-source')).ok());
+ evidence.transferred = await server();
+ assert.deepEqual(evidence.transferred.inventory.Containers[2], [
+ {ID: 1, Type: 51018, Template: 123742, Quality: 2, Slot: 1, Count: 1, Ammo: 3}]);
+ await game.save(output + '/stale');
+ await clickCell(cell(game.state, 107, 65536));
+ await game.wait('stale contained source picked', state => state.dragged[0] === 107 && state.dragged[1] === 65536);
+ const sequence = game.sequence;
+ await game.click(500, 580);
+ await game.wait('actual stale contained ground-drop request', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '3a243f41' &&
+ Buffer.from(event.hex, 'hex').readUInt32BE(29) === 107 && Buffer.from(event.hex, 'hex').readUInt32BE(33) === 65536));
+ evidence.afterRequest = await server();
+ assert.deepEqual(evidence.afterRequest, evidence.transferred);
+ await game.wait('stale contained source cancelled and refreshed', state => !cell(state, 107, 65536) &&
+ cell(state, 107, 65537) && 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));
+ await game.save(output + '/refreshed');
+ await clickCell(cell(game.state, 107, 65537));
+ await game.wait('actual contained source picked', state => state.dragged[0] === 107 && state.dragged[1] === 65537);
+ await clickCell(game.state.grids.find(grid => grid.totalCells === 30).cells.find(item => item.identity[0] === 0));
+ await game.wait('exact contained item withdrawn', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === 48));
+ evidence.withdrawn = await server();
+ assert.equal(evidence.withdrawn.inventory.Containers, null);
+ assert.equal(evidence.withdrawn.inventory.Items.find(item => item.ID === 1).Ammo, 3);
+ 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 === 'stale') {
assert((await page.request.post(url + '/test-stale-source')).ok());