commit d05d8b6c4dc41b0a3212f19dfe5d4eb2aa4ff14d
parent 972e0266067e26c1151f9638977e0db45731c0ec
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 05:01:24 +0000
Clear stale empty right-hand removal sources
Diffstat:
6 files changed, 168 insertions(+), 14 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 a stale empty right-hand source after native removal. A controlled
+ earlier transfer leaves the worn axe visible; removal sends101:6 to111 but
+ previously received no reply. Cancellation, the existing unequip notification
+ and row clearing now preserve the detached banked weapon. Native same-page
+ withdrawal/re-equip and page/cold recovery retain both exact fixture items.
+ First/last ordinary destinations, first-free111, repeats, foreign/pending guards
+ and zero writes pass. See [stale hand](docs/inventory.md#stale-right-hand-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
diff --git a/docs/inventory.md b/docs/inventory.md
@@ -217,6 +217,37 @@ The baseline and17-second corrected captures are in `local/stale-inventory-move/
The initial ordinary-grid rearrangement did not publish a move and is not used
as evidence of this server failure.
+### Stale right-hand move sources
+
+A controlled completed transfer can also leave a worn right-hand weapon visible
+after its authoritative slot becomes empty. Native right-click removal emits
+ContainerAddItem101:6 to destination111. The server previously ignored this
+request, leaving the stale hand unresolved while the physical axe remained in
+the bank. The actual baseline is retained in
+`local/stale-inventory-move/20261103-205752/6/`. An earlier fixture incorrectly
+expected the Wear panel in the icon-grid list and supplies no defect evidence.
+
+For this empty hand, a current idle owner and an ordinary destination or native
+first-free111, correction now sends action146, the existing weapon-unequip97
+notification and action112 for101:6. This clears the hand/model and row without
+destroying the detached weapon, publishing a successful move or writing ownership.
+Other worn slots are not admitted by this specific correction: their effect
+contracts remain separate. Pending equipment, foreign requests and invalid
+destinations retain their guards.
+
+The public-handler regression first failed with zero replies at destinations64,
+93 and111. Repeated correction now preserves the exact banked item, allocation
+and cold state with zero checkpoint writes. The related group passes23 root
+tests/99 results; vet and driver syntax checks pass.
+
+`TestBrowserStaleWornMove` uses the shared controlled fixture alongside
+`TestBrowserStaleOrdinaryMove`. Its17.38-second corrected run at
+`local/stale-inventory-move/20261103-210005/6/` clears the visible hand and then
+normally withdraws/re-equips that exact axe on the same page. Page and cold
+recovery retain axe1 worn at6 and part2 at65, zero cash and allocator2. The
+ordinary companion also passes; all eight traces have no client errors or
+dropped events. This is controlled ownership/view evidence, not earned progression.
+
## Native visual order
The shipped `cd_image/text/help/The Inventory Window.txt` documents left-click
diff --git a/server/browser_stale_inventory_move_test.go b/server/browser_stale_inventory_move_test.go
@@ -18,12 +18,21 @@ import (
)
func TestBrowserStaleOrdinaryMove(t *testing.T) {
+ testBrowserStaleInventoryMove(t, 64)
+}
+
+func TestBrowserStaleWornMove(t *testing.T) {
+ testBrowserStaleInventoryMove(t, 6)
+}
+
+func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) {
+ t.Helper()
if os.Getenv("AO_GAME_TEST") != "1" {
- t.Skip("set AO_GAME_TEST=1 for stale ordinary moves")
+ t.Skip("set AO_GAME_TEST=1 for stale inventory moves")
}
_, source, _, _ := runtime.Caller(0)
root := filepath.Dir(filepath.Dir(source))
- output := filepath.Join(root, "local/stale-inventory-move", time.Now().Format("20060102-150405"))
+ output := filepath.Join(root, "local/stale-inventory-move", time.Now().Format("20060102-150405"), fmt.Sprint(sourceSlot))
world := newTestServer(t)
player := world.newCharacter()
player.playfield, player.position = 1183, [3]float32{193.79826, 5.01, 136.83983}
@@ -34,7 +43,7 @@ func TestBrowserStaleOrdinaryMove(t *testing.T) {
t.Fatal(err)
}
inventory := playerInventory{LastID: 2, Items: []ownedItem{
- {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: sourceSlot, Count: 1},
{ID: 2, Type: 51005, Template: 42640, Quality: 1, Slot: 65, Count: 1}}}
if err := world.saveInventory_locked(player, inventory); err != nil {
t.Fatal(err)
@@ -46,7 +55,7 @@ func TestBrowserStaleOrdinaryMove(t *testing.T) {
defer world.mutex.Unlock()
json.NewEncoder(w).Encode(player.inventory)
})
- // Isolate an earlier bank transfer without refreshing its old carried source.
+ // Isolate an earlier bank transfer without refreshing its old source.
mux.HandleFunc("POST /test-stale-view", func(w http.ResponseWriter, r *http.Request) {
world.updateMutex.Lock()
defer world.updateMutex.Unlock()
@@ -83,7 +92,7 @@ func TestBrowserStaleOrdinaryMove(t *testing.T) {
}()
defer func() { cancel(); <-stopped }()
- command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_stale_inventory_move.mjs"), host.URL, output)
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_stale_inventory_move.mjs"), host.URL, output, fmt.Sprint(sourceSlot))
command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
err := command.Run()
diff --git a/server/inventory.go b/server/inventory.go
@@ -369,6 +369,18 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
}
return client.send(characterActionPacket(client.id, [5]uint32{112, 104, sourceSlot}))
}
+ if index < 0 && client.equipment == nil && key == 0x47537a24 && sourceType == 101 && sourceSlot == 6 &&
+ binary.BigEndian.Uint32(body[24:28]) == 50000 && binary.BigEndian.Uint32(body[28:32]) == client.id &&
+ (destination == 111 || destination >= 64 && destination < 94) {
+ // Clear an empty hand without destroying its detached physical weapon.
+ for _, packet := range [][]byte{characterActionPacket(client.id, [5]uint32{146, 101, 6}),
+ weaponUnequipPacket(client.id), characterActionPacket(client.id, [5]uint32{112, 101, 6})} {
+ if err := client.send(packet); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
if index < 0 || (sourceSlot >= 64 && sourceType != 104) ||
(sourceSlot > 0 && sourceSlot < 16 && sourceType != 101) ||
(sourceSlot >= 33 && sourceSlot <= 45 && sourceType != 103) ||
diff --git a/server/stale_inventory_move_test.go b/server/stale_inventory_move_test.go
@@ -102,3 +102,89 @@ func TestStaleOrdinaryMoveIgnoresInvalidOrPendingRequests(t *testing.T) {
})
}
}
+
+func TestStaleRightHandMoveClearsOnlyEmptySourceWithoutWrites(t *testing.T) {
+ for _, destination := range []uint32{64, 93, 111} {
+ t.Run(fmt.Sprint(destination), 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, inventory.Items = []ownedItem{item}, 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, itemMovePacket(1, 6, destination)[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 right-hand move changed ownership or omitted correction", err, len(output.packets))
+ }
+ for repeat := range 2 {
+ for index, packet := range [][]byte{
+ targetPacket(characterActionPacket(1, [5]uint32{146, 101, 6})),
+ targetPacket(weaponUnequipPacket(1)),
+ targetPacket(characterActionPacket(1, [5]uint32{112, 101, 6})),
+ } {
+ if !bytes.Equal(output.packets[repeat*3+index], packet) {
+ t.Fatalf("stale hand did not cancel, unequip and clear its source: %x", output.packets)
+ }
+ }
+ }
+ })
+ }
+}
+
+func TestStaleRightHandMoveIgnoresInvalidOrPendingRequests(t *testing.T) {
+ for _, scenario := range []string{"foreign actor", "foreign target", "wrong page", "other worn slot", "invalid destination", "pending equipment"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, output := newEquipmentWorld(t)
+ client := world.clients[1]
+ request := itemMovePacket(1, 6, 111)[20:]
+ switch scenario {
+ case "foreign actor":
+ binary.BigEndian.PutUint32(request[8:12], 2)
+ case "foreign target":
+ binary.BigEndian.PutUint32(request[28:32], 2)
+ case "wrong page":
+ binary.BigEndian.PutUint32(request[16:20], 102)
+ case "other worn slot":
+ binary.BigEndian.PutUint32(request[20:24], 5)
+ case "invalid destination":
+ binary.BigEndian.PutUint32(request[32:36], 94)
+ case "pending equipment":
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("equipment fixture did not begin", err)
+ }
+ }
+ pending := client.equipment
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ output.packets = nil
+
+ err = world.handleInventory(client, request)
+ after, readErr := readTestItemStore(world)
+
+ if err != nil || readErr != nil || !bytes.Equal(before, after) || len(output.packets) != 0 || client.equipment != pending {
+ t.Fatal("invalid stale hand request changed ownership or pending equipment", err, readErr)
+ }
+ })
+ }
+}
diff --git a/tools/client/test_stale_inventory_move.mjs b/tools/client/test_stale_inventory_move.mjs
@@ -4,7 +4,9 @@ import {createRequire} from 'node:module';
import {GameTest} from './game_test.mjs';
const {chromium} = createRequire(import.meta.url)('playwright');
-const [url, output] = process.argv.slice(2);
+const [url, output, sourceSlot] = process.argv.slice(2);
+const sourcePage = sourceSlot === '6' ? 101 : 104;
+const nativeSlot = sourceSlot === '6' ? 6 : 48;
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']});
@@ -18,6 +20,8 @@ try {
const server = async () => (await page.request.get(url + '/test-state')).json();
const cell = (pageId, slot) => game.state.grids.flatMap(grid => grid.cells).find(cell =>
cell.identity[0] === pageId && cell.identity[1] === slot && !cell.dummy);
+ const sourcePresent = () => sourcePage === 101 ?
+ game.local().inventory.some(item => item.id === 1 && item.slot === 6) : cell(104, 48);
const click = async (source, button = 'left') => {
assert(source, 'the exact native source must be usable');
await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2, button);
@@ -27,21 +31,26 @@ try {
await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
await game.snapshot();
await game.key('KeyI');
- assert(cell(104, 48) && cell(104, 49));
+ if (sourcePage === 101) {
+ await page.keyboard.press('Control+1');
+ await game.snapshot();
+ }
+ assert(sourcePresent() && cell(104, 49));
assert((await page.request.post(url + '/test-stale-view')).ok());
evidence.transferred = await server();
assert.deepEqual(evidence.transferred.Items.map(item => [item.ID, item.Slot]), [[2, 65]]);
assert.deepEqual(evidence.transferred.Bank.map(item => [item.ID, item.Slot]), [[1, 0]]);
await game.save(output + '/stale');
const sequence = game.sequence;
- await click(cell(104, 48), 'right');
- await game.wait('actual stale ordinary move', () => game.events.some(event => event.sequence > sequence &&
+ if (sourcePage === 101) await game.click(867, 206, 'right');
+ else await click(cell(104, 48), 'right');
+ await game.wait('actual stale inventory move', () => game.events.some(event => event.sequence > sequence &&
event.direction === 'framesent' && event.opcode === '47537a24' &&
- Buffer.from(event.hex, 'hex').readUInt32BE(29) === 104 && Buffer.from(event.hex, 'hex').readUInt32BE(33) === 48 &&
- Buffer.from(event.hex, 'hex').readUInt32BE(45) === 6));
- await game.wait('stale ordinary move cancelled', () => game.events.some(event => event.sequence > sequence &&
+ Buffer.from(event.hex, 'hex').readUInt32BE(29) === sourcePage && Buffer.from(event.hex, 'hex').readUInt32BE(33) === nativeSlot &&
+ Buffer.from(event.hex, 'hex').readUInt32BE(45) === (sourcePage === 101 ? 111 : 6)));
+ await game.wait('stale inventory move cancelled', () => game.events.some(event => event.sequence > sequence &&
event.direction === 'framereceived' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 146));
- await game.wait('empty authoritative source cleared', () => !cell(104, 48) && cell(104, 49) && game.state.dragged[0] === 0);
+ await game.wait('empty authoritative source cleared', () => !sourcePresent() && cell(104, 49) && game.state.dragged[0] === 0);
assert.deepEqual(await server(), evidence.transferred);
await game.save(output + '/refused');
@@ -68,7 +77,7 @@ try {
assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot]).sort((a, b) => a[0] - b[0]), [[1, 6], [2, 49]]);
assert.deepEqual(await server(), evidence.after);
assert.deepEqual(game.errors, []);
- console.log('PASS: stale ordinary source cleared, exact banked item withdrawn/moved and both instances retained through page/cold recovery');
+ console.log('PASS: stale inventory source cleared, exact banked item withdrawn/moved and both instances retained through page/cold recovery');
} finally {
try {
await fs.mkdir(output, {recursive: true});