commit bcfb6730bad957c92b94ed1ce165ba77cd7a968f
parent ad98323bb1f625440a8653a1e50a2005104d5453
Author: anon <anon@example.com>
Date: Mon, 2 Nov 2026 19:29:40 +0000
Cover finite weapon reclaim and cold native recovery
Diffstat:
5 files changed, 284 insertions(+), 0 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -3559,6 +3559,12 @@ and server restarts. Turn every reproduced bug into a focused regression test.
24 reclaim entries, exactly-once collection, charged recovery, bound-key
mission re-entry/settlement and the reclaimed sleeve's wear/remove/rewear.
Final cold loading retains every physical/native slot and property.
+ A short controlled native regression now covers an instantiated finite
+ weapon's removal, same-playfield death, exact reclaim collection and usable
+ re-equip. QL75 LIZARD retains its 13 loaded rounds, separate 100-round energy
+ stack and exactly-once Psychic bonus through fresh-server native recovery.
+ This isolates ownership; resurrection-shock rules remain open below. See
+ [weapon reclaim](docs/inventory.md#retained-weapon-death-and-reclaim).
- [ ] [P2] Review nearly invisible original item icons separately from ownership
loss. Low-Tech sleeves 70561/85744 reference icon 1010008/13228: the original
14.9.1 PNG is almost entirely chroma-key green, with only a tiny shoulder in
@@ -3686,6 +3692,13 @@ and server restarts. Turn every reproduced bug into a focused regression test.
rollback, shared ranged outcomes and resurrection without replay. Two native
clients verified removal and return; historical persistent-nano exceptions
remain open in [temporary nanos](docs/nano-buffs.md#death-and-resurrection).
+- [ ] [P1] Recover and apply original resurrection-shock rules. The shipped
+ return reports temporarily reduced stats, but the current server restores
+ 1 HP/nano without applying a stat penalty. Recover the original modifier,
+ duration/recovery, level exceptions and equipment/resource consequences;
+ verify native/server agreement and cold expiry without inventing a blanket
+ reduction. The controlled weapon-reclaim check isolates item conservation
+ under current stats and does not establish canonical post-return eligibility.
- [ ] [P0] Audit corpse loot, credits and expiry. Cover entitled/unrelated players,
simultaneous pickup, partial looting, full inventory, stale windows, expiry,
repeat requests and persistence of both sides of each transfer.
diff --git a/docs/inventory.md b/docs/inventory.md
@@ -409,6 +409,42 @@ starter-weapon test exposed the separate missing-dynel possession check;
update activation and despawn evidence is retained in
`local/fast-attack-research/native/re-equip.md`.
+### Retained weapon death and reclaim
+
+`TestBrowserReclaimWeapon` covers the specific P0 question of a previously
+instantiated finite weapon returning through reclaim. A controlled level-100
+Trader starts beside the original street scanner/reclaim pair with a QL75
+LIZARD in hand (13 rounds) and a separate 100-round energy-ammo stack. Its
+abilities/skills, one-health checkpoint, one fatal Leet hit and expedited reclaim
+availability are test setup, not earned progression or reclaim-timing evidence.
+
+Native removal retains the same weapon in ordinary inventory and removes its
+15 Psychic bonus. A production fatal combat outcome moves both exact items to
+reclaim; the native client performs its normal death return in playfield 705.
+The driver waits for the replacement world stream's actor readiness, picks the
+real reclaim booth and collects both rows through native clicks. The weapon's
+returned inventory row then emits a real equip request and successfully equips.
+Its FullUpdate carries stat 26=13, and the energy stack remains 100. Native skills
+show Psychic 215 from base 200, matching one server bonus of 15.
+
+After closing the original database, a fresh server and native client restore
+the same physical IDs, selected QL/endpoints, slots, quantities and ammunition.
+The worn weapon again arrives with 13 rounds and displays Psychic 215. Screenshots
+were inspected; no native/page errors occurred. The complete warm/cold check
+took 38.18s, with traces under `local/reclaim-weapon/20261102-112607/`.
+Focused Reclaim/Resurrection/Vektor Go checks passed in 71.067s. This records a
+necessary regression for the reported equipment-loss path; it found no additional
+production ownership defect and does not close the broader disappearance audit.
+
+The native return text also advertises resurrection shock, while current server
+return only restores 1 HP/nano. Original penalties, recovery and eligibility
+remain a separate TODO; this fixture's successful re-equip does not establish
+canonical qualification during shock.
+
+```sh
+AO_GAME_TEST=1 go test ./server -run '^TestBrowserReclaimWeapon$' -count=1 -timeout=4m -v
+```
+
Two WASM clients verified axe appearance, matching combat text and damage,
unequip icons and removal for the observer, and subsequent 3..5 fist hits.
Repeated equipment and equipped reconnect/server-restart checks retained item
diff --git a/docs/vektor-shotguns.md b/docs/vektor-shotguns.md
@@ -47,6 +47,14 @@ remain unresolved. This change does not add production stock, loot or reward
rules. QL180 is not an extension of the LIZARD pair, and no QL181..200 form is
invented.
+A bounded acquisition follow-up checked the local wiki mirror, period-player
+searches and later guides. The later German
+[Trader weapon guide](https://anarchyonline.fandom.com/de/wiki/Trader%3AWaffen_wahl)
+calls Vektor ND shop-buyable; hahnsoo's 2008 guide recommends it without locating
+the specific booth. Neither establishes 14.9.1 booth membership, minimum shop
+QL or stock generation. No production stock follows from those leads; the
+current acquisition gap remains open pending dated inventory evidence.
+
## Focused verification
`TestVektorQualitiesWearRemoveAndRecover` covers both stored anchors at the
diff --git a/server/browser_reclaim_weapon_test.go b/server/browser_reclaim_weapon_test.go
@@ -0,0 +1,152 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserReclaimWeapon(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the native retained-weapon reclaim check")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/reclaim-weapon", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.name, player.level, player.profession, player.appearance = "Reclaimweapon", 100, 7, 0x515
+ player.playfield, player.position = 705, [3]float32{598, 16.9, 331}
+ player.rotation = [4]float32{0, 0.70710677, 0, 0.70710677}
+ player.resurrectionTerminal, player.health, player.nano = 3221750465, 1, 1
+ player.stats.Abilities = characterAbilitiesStats{200, 200, 200, 200, 200, 200}
+ player.stats.Ranged.Shotgun = 300
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("reclaim-weapon")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.savePosition_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ for _, template := range []uint32{124261, 21609} {
+ if granted, err := world.grantItem_locked(player, template); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ }
+ player.inventory.Items[0].Quality, player.inventory.Items[0].Slot, player.inventory.Items[0].Ammo = 75, 6, 13
+ player.inventory.Items[1].Slot, player.inventory.Items[1].Count = 64, 100
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ enemy := &character{id: 9000001, npc: true, name: "Reclaim checkpoint Leet", level: 1,
+ playfield: 705, position: [3]float32{598, 16.9, 333}, rotation: [4]float32{0, 0, 0, 1},
+ monsterData: 17655, appearance: 229, health: 100, combatProfile: gamedata.NPCCombatProfiles[17655][1], geometry: world.geometry}
+ world.characters[enemy.id] = enemy
+ world.combatRoll = landedCombatRoll
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ testState := func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory, "health": player.health,
+ "playfield": player.playfield, "psychic": player.equipmentBonus(21)})
+ }
+ mux.HandleFunc("GET /test-state", testState)
+ mux.HandleFunc("POST /test-fatal-hit", func(w http.ResponseWriter, r *http.Request) {
+ world.updateMutex.Lock()
+ world.mutex.Lock()
+ updates := make(map[*worldClient][][]byte)
+ world.startAttack_locked(enemy, player, time.Now(), updates)
+ deadline := enemy.nextAttack
+ world.mutex.Unlock()
+ world.sendCombatUpdates(updates)
+ world.updateMutex.Unlock()
+ world.advanceCombat(deadline)
+ w.WriteHeader(http.StatusNoContent)
+ })
+ mux.HandleFunc("POST /test-ready-reclaim", func(w http.ResponseWriter, r *http.Request) {
+ world.updateMutex.Lock()
+ defer world.updateMutex.Unlock()
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ // Controlled clock setup isolates identity replay from the tested 75s delay.
+ inventory := player.inventory
+ for index := range inventory.Reclaim {
+ inventory.Reclaim[index].AvailableAt = time.Now().Add(-time.Second).UTC()
+ }
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Error(err)
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ w.WriteHeader(http.StatusNoContent)
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ defer cancel()
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ ticker := time.NewTicker(50 * time.Millisecond)
+ defer ticker.Stop()
+ for {
+ select {
+ case now := <-ticker.C:
+ world.advanceEquipment(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_reclaim_weapon.mjs"), host.URL, output, "live")
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ cancel()
+ <-stopped
+ t.Logf("Browser artifacts: %s", output)
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil {
+ t.Fatal(err)
+ }
+ host.Close()
+ if err := world.db.Close(); err != nil {
+ t.Fatal(err)
+ }
+ cold := newServer()
+ defer cold.db.Close()
+ if !slices.Equal(player.inventory.Items, cold.characters[1].inventory.Items) || len(cold.characters[1].inventory.Reclaim) != 0 || cold.characters[1].equipmentBonus(21) != 15 {
+ t.Fatal("cold recovery changed the reclaimed weapon, ammunition or Psychic bonus")
+ }
+ world, player = cold, cold.characters[1]
+ coldMux := http.NewServeMux()
+ coldMux.Handle("/", cold.httpHandler())
+ coldMux.HandleFunc("GET /test-state", testState)
+ coldHost := httptest.NewServer(coldMux)
+ defer coldHost.Close()
+ closeTestBrowserStreams(t, cold)
+ coldContext, coldCancel := context.WithTimeout(context.Background(), time.Minute)
+ defer coldCancel()
+ command = exec.CommandContext(coldContext, "node", filepath.Join(root, "tools/client/test_reclaim_weapon.mjs"), coldHost.URL, filepath.Join(output, "cold"), "cold")
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ if err := command.Run(); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/tools/client/test_reclaim_weapon.mjs b/tools/client/test_reclaim_weapon.mjs
@@ -0,0 +1,75 @@
+import assert from 'node:assert/strict';
+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']});
+const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+await context.addCookies([{name: 'ao_client', value: 'reclaim-weapon', url}]);
+const page = await context.newPage();
+const game = await GameTest.attach(page);
+const state = async () => (await page.request.get(url + '/test-state')).json();
+try {
+ await page.goto(url);
+ await game.ready();
+ assert(game.local().inventory.some(item => item.id === 1 && item.slot === 6));
+ assert.equal((await state()).psychic, 15);
+ if (phase === 'live') {
+ await game.key('KeyI');
+ await page.keyboard.press('Control+1');
+ await game.click(867, 206, 'right');
+ await game.wait('instantiated weapon returns to inventory', snapshot => game.local(snapshot).inventory.some(item => item.id === 1 && item.slot === 49));
+ assert.equal((await state()).psychic, 0);
+ await game.save(output + '/removed');
+
+ const sequence = game.sequence;
+ assert.equal((await page.request.post(url + '/test-fatal-hit')).status(), 204);
+ await game.wait('same-playfield death return', snapshot => snapshot.localId === 1 && game.local(snapshot)?.stats[27] === 1 &&
+ game.local(snapshot)?.inventory.length === 0 && game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 152), 30000);
+ await game.ready();
+ const dead = await state();
+ assert.equal(dead.playfield, 705);
+ assert.equal(dead.inventory.Reclaim.length, 2);
+ assert.equal(dead.inventory.Reclaim.find(entry => entry.Item.ID === 1).Item.Ammo, 13);
+ assert.equal((await page.request.post(url + '/test-ready-reclaim')).status(), 204);
+ const [x, y] = await game.pick(51059, 3221881537);
+ await game.click(x, y, 'right');
+ await game.wait('native reclaim window', snapshot => snapshot.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ await game.click(30, 45);
+ await game.wait('same weapon reclaimed', snapshot => game.local(snapshot).inventory.some(item => item.id === 1 && item.slot === 48));
+ await game.click(84, 45);
+ await game.wait('same energy stack reclaimed', snapshot => game.local(snapshot).inventory.some(item => item.id === 2 && item.count === 100));
+ await game.click(170, 8);
+ if (!game.state.regions.some(region => region[0] === 654 && region[1] === 0 && region[2] === 832 && region[3] === 182)) await game.key('KeyI');
+ await game.save(output + '/collected');
+ await game.click(681, 45, 'right');
+ await game.wait('reclaimed native weapon equips again', snapshot => game.local(snapshot).inventory.some(item => item.id === 1 && item.slot === 6));
+ }
+ const final = await state();
+ assert.equal(final.psychic, 15);
+ assert.equal(final.inventory.Items.find(item => item.ID === 1).Ammo, 13);
+ assert.equal(final.inventory.Items.find(item => item.ID === 2).Count, 100);
+ assert.equal(final.inventory.Reclaim, null);
+ assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot, item.quality, ...item.templates, item.count]).sort((a, b) => a[0] - b[0]), [
+ [1, 6, 75, 124260, 124261, 1], [2, 49, 1, 21609, 21609, 100],
+ ]);
+ await game.wait('loaded reclaimed weapon delivered', () => game.events.some(event =>
+ event.direction === 'framereceived' && event.opcode === '3b1d2268' && event.actor[1] === 1));
+ const event = game.events.findLast(event => event.direction === 'framereceived' && event.opcode === '3b1d2268' && event.actor[1] === 1);
+ const packet = Buffer.from(event.hex, 'hex');
+ const stats = new Map();
+ for (let offset = 59; offset + 8 <= packet.length - 4; offset += 8) stats.set(packet.readUInt32BE(offset), packet.readUInt32BE(offset + 4));
+ assert.equal(stats.get(26), 13);
+ await game.key('KeyU');
+ await game.save(output + '/psychic');
+ assert.equal(game.errors.length, 0);
+ console.log('PASS:', phase, 'same instantiated weapon, 13 loaded/100 carried rounds and exactly-once Psychic bonus after death/reclaim');
+} finally {
+ try { await game.save(output + '/final'); }
+ finally { await browser.close(); }
+}