commit 7e79f26f28e30b63b8902fa6859def51c87e0f77
parent a9723d00fc468a57f8eaf46fbe7cde109c017e45
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 04:21:42 +0000
Close inaccessible reclaim windows after rejected pickup
Diffstat:
6 files changed, 108 insertions(+), 3 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1234,6 +1234,12 @@ Historical outdoor give-up timing and wider route-selection fidelity remain open
one slot, all31 instances through native page replay and cold loading, and
nonzero source cancellation after partial collection have focused regressions.
These fixtures do not establish earned faction travel; see [reclaim](docs/reclaim.md).
+- [x] [P0] Cancel pending reclaim pickup after leaving booth range.
+ A controlled stale native view reproduced a hidden source with no reply.
+ Cancellation now precedes window closure and invalidates its slot mapping
+ without changing items. Go distance/playfield cases preserve the exact store;
+ native return/reopen, collection and page/cold retention of all31 instances
+ pass. See [reclaim](docs/reclaim.md).
- [x] [P0] Resolve the reported blocked Omni courtyard scanner approach with a focused
native regression. Start beside the original stair entrance, use real walking
input, check ascent/landing heights against server state, then pick and use
diff --git a/docs/reclaim.md b/docs/reclaim.md
@@ -141,6 +141,11 @@ The source is the fixed window index, including after an earlier slot has been
collected; it is not the item's old inventory slot. No item or mapping changes
on refusal, and a later pickup can retry the same source once space is available.
+If an otherwise valid open-source pickup arrives after leaving booth range or
+changing playfield, the server clears its snapshot mapping, cancels the pending
+page106 move with146 and closes the native window with110. Ownership remains
+unchanged. Returning to a booth can open a fresh mapping of the same items.
+
## Verification
`TestBrowserReclaimPickupRefusal` uses a controlled stale free-space view beside
@@ -153,6 +158,11 @@ claiming earned progression or faction travel. A public-handler regression also
collects one reclaim item before filling inventory and verifies cancellation of
the still-open nonzero source slot; failed persistence retains its existing
error path and publishes no success.
+The fixture also submits a real pickup from a stale booth view after a controlled
+authoritative position change. It verifies cancellation and closure, returns,
+reopens the same item and completes the full-inventory retry above. Separate
+distance/playfield regressions compare exact item-store bytes and cold ownership;
+this is failure-path coverage rather than ordinary travel evidence.
`TestReclaimPreventsInsuranceUntilEmptied` now checks pending/available reclaim,
new and stale Use sequences, failure-then-Feedback64 ordering and unchanged
diff --git a/server/browser_reclaim_refusal_test.go b/server/browser_reclaim_refusal_test.go
@@ -50,6 +50,21 @@ func TestBrowserReclaimPickupRefusal(t *testing.T) {
defer world.mutex.Unlock()
json.NewEncoder(w).Encode(player.inventory)
})
+ // A stale native view can submit pickup after authoritative range is lost.
+ mux.HandleFunc("POST /test-leave", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ player.position = [3]float32{960, 16.5, 511}
+ if world.nearReclaim_locked(world.clients[1]) {
+ t.Error("range fixture remained near a reclaim booth")
+ w.WriteHeader(500)
+ }
+ })
+ mux.HandleFunc("POST /test-return", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ player.position = [3]float32{598, 16.9, 329}
+ })
// Unpublished filler grants isolate authoritative refusal from native prechecks.
mux.HandleFunc("POST /test-fill", func(w http.ResponseWriter, r *http.Request) {
world.mutex.Lock()
diff --git a/server/reclaim.go b/server/reclaim.go
@@ -102,10 +102,18 @@ func (server *server) takeReclaim(client *worldClient, body []byte) error {
binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id ||
binary.BigEndian.Uint32(body[24:28]) != 50000 || binary.BigEndian.Uint32(body[28:32]) != client.id ||
binary.BigEndian.Uint32(body[32:36]) != 111 || source >= uint32(len(client.reclaimItems)) ||
- client.reclaimItems[source] == 0 || !server.nearReclaim_locked(client) {
+ client.reclaimItems[source] == 0 {
server.mutex.Unlock()
return nil
}
+ if !server.nearReclaim_locked(client) {
+ client.reclaimItems = nil
+ server.mutex.Unlock()
+ if err := client.send(characterActionPacket(client.id, [5]uint32{146, 106, source})); err != nil {
+ return err
+ }
+ return client.send(characterActionPacket(client.id, [5]uint32{110}))
+ }
index := slices.IndexFunc(player.inventory.Reclaim, func(entry reclaimItem) bool { return entry.Item.ID == client.reclaimItems[source] })
if index < 0 || time.Now().Before(player.inventory.Reclaim[index].AvailableAt) {
server.mutex.Unlock()
diff --git a/server/reclaim_test.go b/server/reclaim_test.go
@@ -1,6 +1,7 @@
package main
import (
+ "bytes"
"encoding/binary"
"reflect"
"slices"
@@ -197,7 +198,7 @@ func TestReclaimRejectsInvalidOpenAndPickup(t *testing.T) {
if err != nil || !reflect.DeepEqual(before, player.inventory) {
t.Fatalf("invalid pickup changed ownership: %v", err)
}
- if scenario == "loading" || scenario == "unready" || scenario == "replaced" || scenario == "dead" || scenario == "far" || scenario == "zone" || scenario == "11.0" {
+ if scenario == "loading" || scenario == "unready" || scenario == "replaced" || scenario == "dead" || scenario == "11.0" {
if len(conn.packets) != 0 {
t.Fatal("invalid user opened reclaim")
}
@@ -206,6 +207,52 @@ func TestReclaimRejectsInvalidOpenAndPickup(t *testing.T) {
}
}
+func TestReclaimRangeLossClosesOpenWindowWithoutChangingOwnership(t *testing.T) {
+ for _, reason := range []string{"distance", "playfield"} {
+ t.Run(reason, func(t *testing.T) {
+ world, conn := newReclaimWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ inventory := player.inventory
+ inventory.LastID = 4
+ inventory.Reclaim = []reclaimItem{{ownedItem{ID: 4, Type: 51005, Template: 42640, Quality: 1, Slot: 65, Count: 1}, time.Now().Add(-time.Second).UTC()}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleReclaim(client, reclaimRequest(109)); err != nil {
+ t.Fatal(err)
+ }
+ if reason == "distance" {
+ player.position[0] = 930
+ } else {
+ player.playfield = 950
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ conn.packets = nil
+
+ if err := world.handleInventory(client, reclaimTakeRequest(0)); err != nil {
+ t.Fatal(err)
+ }
+ after, err := readTestItemStore(world)
+ cold := newTestInventoryServer(t)
+
+ if err != nil || !bytes.Equal(before, after) || !reflect.DeepEqual(player.inventory, inventory) ||
+ !reflect.DeepEqual(cold.characters[1].inventory, inventory) {
+ t.Fatal("range loss changed either durable inventory or reclaim ownership", err)
+ }
+ if client.reclaimItems != nil || len(conn.packets) != 2 ||
+ binary.BigEndian.Uint32(conn.packets[0][16:20]) != 0x5e477770 ||
+ binary.BigEndian.Uint32(conn.packets[0][29:33]) != 146 || binary.BigEndian.Uint32(conn.packets[0][33:37]) != 106 ||
+ binary.BigEndian.Uint32(conn.packets[0][37:41]) != 0 ||
+ binary.BigEndian.Uint32(conn.packets[1][16:20]) != 0x5e477770 || binary.BigEndian.Uint32(conn.packets[1][29:33]) != 110 {
+ t.Fatal("range loss did not cancel the pending pickup before closing its source")
+ }
+ })
+ }
+}
+
func TestReclaimFullInventoryAndFailedPickupSaveRetainSource(t *testing.T) {
for _, scenario := range []string{"full", "failed save"} {
t.Run(scenario, func(t *testing.T) {
diff --git a/tools/client/test_reclaim_refusal.mjs b/tools/client/test_reclaim_refusal.mjs
@@ -22,6 +22,25 @@ try {
await game.click(x, y, 'right');
await game.wait('reclaim source icon', state => state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 106 && !cell.dummy)));
evidence.before = await server();
+
+ // The client retains its old booth view while authoritative range is lost.
+ assert((await page.request.post(url + '/test-leave')).ok());
+ const staleSequence = game.sequence;
+ await game.click(30, 45);
+ await game.wait('actual out-of-range reclaim pickup', () => game.events.some(event => event.sequence > staleSequence &&
+ event.direction === 'framesent' && event.opcode === '47537a24' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 106));
+ await game.wait('out-of-range pickup cancelled and window closed', () => game.events.some(event => event.sequence > staleSequence &&
+ event.direction === 'framereceived' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 110));
+ await game.wait('inaccessible reclaim source removed', state => !state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 106)));
+ evidence.outOfRange = await server();
+ assert.deepEqual(evidence.outOfRange, evidence.before);
+ await game.save(output + '/out-of-range');
+ assert((await page.request.post(url + '/test-return')).ok());
+ const [returnX, returnY] = await game.pick(51059, 0xc00a02c1);
+ await game.click(returnX, returnY, 'right');
+ await game.wait('same item reopens after returning', state => state.grids.some(grid => grid.cells.some(cell =>
+ cell.identity[0] === 106 && cell.identity[1] === 0 && !cell.dummy)));
+
assert((await page.request.post(url + '/test-fill')).ok());
evidence.full = await server();
assert.equal(evidence.full.Items.length, 30);
@@ -62,7 +81,7 @@ try {
evidence.after.Items.map(item => item.ID).sort((a, b) => a - b));
assert.deepEqual(await server(), evidence.after);
assert.equal(game.errors.length, 0);
- console.log('PASS: full reclaim pickup restores its icon, same-window retry transfers once and all 31 instances survive page/cold recovery');
+ console.log('PASS: inaccessible reclaim closes without loss, full pickup restores its icon, return/retry and all 31 instances survive page/cold recovery');
} finally {
try {
await fs.mkdir(output, {recursive: true});