aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit ad56d2b5f9255d9c9959b8dc8ac0f8cbe0a475f7
parent 705480837e3c71e3ebd423faef372d7fd0ea9108
Author: anon <anon@example.com>
Date:   Wed,  4 Nov 2026 08:03:30 +0000

Correct stale non-hand equipment sources and their effects

Diffstat:
MTODO.md | 10++++++++++
Mdocs/inventory.md | 2+-
Mdocs/stat-equipment.md | 37+++++++++++++++++++++++++++++++++++++
Mserver/browser_stale_inventory_move_test.go | 20+++++++++++++++++---
Mserver/equipment.go | 8++++----
Mserver/inventory.go | 7++++---
Mserver/main.go | 6+++---
Mserver/stale_armor_move_test.go | 6+++---
Mserver/stale_implant_move_test.go | 6+++---
Mserver/stale_inventory_move_test.go | 6+++---
Aserver/stale_non_hand_move_test.go | 168+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/state.go | 2+-
Mtools/client/test_stale_inventory_move.mjs | 26++++++++++++++++----------
13 files changed, 270 insertions(+), 34 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -4114,6 +4114,16 @@ and server restarts. Turn every reproduced bug into a focused regression test. both directions during wear/removal without writes or deadline changes. No product defect reproduced on this path; see [backpack joins](docs/backpacks.md#stack-join-during-pending-equipment). +- [x] [P0] Correct empty stale HUD/utility, belt and deck removal sources. + Reproduction: retain a native page101:9 memory after a controlled earlier bank + transfer empties its row, then remove it normally; the baseline sent no reply. + Cancellation, exact published unwear once and source clearing now require no + ownership writes. A short native check verifies NCU10 ->8 ->10 through same-page + withdrawal/reinstallation with the original10-second delay. The belt and other + item remain intact, and page/cold loading conserve all three IDs. Go checks + cover all13 non-hand positions and retain separate weapon-hand behavior. This + controlled stale-view fixture leaves the broader disappearance audit open; + see [stale non-hand sources](docs/stat-equipment.md#stale-non-hand-sources). - [x] [P0] Clear stale installed-implant sources and their native effects. Reproduction: install chest implant101173, retain its native page103:37 view while a controlled earlier bank transfer empties that source, then remove it diff --git a/docs/inventory.md b/docs/inventory.md @@ -273,7 +273,7 @@ The maintained translations are `client/game/kkr.dll/lifted-0039.c::sub_360849C0` and `client/game/kkr.dll/lifted-0028.c::sub_3605E980`. -Each connection now retains the exact armor/implant-removal packet prepared from its +Each connection now retains the exact non-weapon removal packet prepared from its published FullCharacter, updating it only after normal equipment commits. An authenticated empty page102 source receives cancellation, that last-published OnUnWear once when present, then clearing of its own row. The packet is consumed diff --git a/docs/stat-equipment.md b/docs/stat-equipment.md @@ -83,6 +83,43 @@ Complete procedures, hashes and Evidence IDs are retained in `delivery.md`, with exported REA bundles. No historical server implementation or charged purchase packing rule is claimed from these client procedures. +## Stale non-hand sources + +A controlled earlier bank transfer leaves a QL1 memory visible at page101:9 +after its authoritative row is empty. Its native right-click removal previously +received no reply. The Go baseline also reproduces silence for utility161699 +at101:3. The focused defect and completion check extend the P0 disappearing-item +audit; they do not require earning equipment or progression. + +The connection's exact published unwear cache now includes all supported page101 +non-hand positions:1..5,7,9..15. It uses the actual worn slot directly. An empty +source receives cancellation146, its last-published TemplateAction7 once when +known, then clearing112 of that source. Duplicates cannot subtract effects +again. Unknown templates are never guessed from bank contents. The separate +right-hand correction and unsupported left-hand guard retain their behavior. +The original [belt/deck protocol](belts-ncu.md#native-protocol-and-evidence) and +[unwear receiver](inventory.md#stale-worn-armor-sources) establish these messages. + +`TestStaleNonHandMove` covers all13 empty source positions and explicit first, +last and automatic destinations. Public wear fixtures also verify exact +utility/memory removal metadata, duplicate requests, no database writes or +allocations, cold ownership, foreign targets/pages and pending equipment. + +`TestBrowserStaleMemoryMove` uses real native input for stale removal, same-page +bank withdrawal and reinstallation with the original10-second equip delay. +Manual Stats-window inspection confirms maximum NCU10 ->8 ->10 and a cleared, +then restored, Deck1 icon. The belt remains installed. Page replay and cold Go +loading retain memory1 at9, part2 at65 and belt3 at7, zero cash and allocator3. +The26.44-second verified run is +`local/stale-inventory-move/20261103-235815/9/`; all five native trace error/drop +counters are zero. The baseline is +`local/stale-inventory-move/20261103-235451/9/`. Packet ordering, exact ownership, +manual screenshot observations and source hashes are retained in +`local/stale-non-hand-move/validation.json`. This is controlled stale-view +evidence; the broader disappearance audit remains open. +The final related Go run passes80 roots/567 results; focused race checks pass53 +results. Vet and driver syntax checks pass. + ## Verification `server/utility_equipment_test.go` exercises public inventory moves for all six diff --git a/server/browser_stale_inventory_move_test.go b/server/browser_stale_inventory_move_test.go @@ -33,6 +33,10 @@ func TestBrowserStaleImplantMove(t *testing.T) { testBrowserStaleInventoryMove(t, 37) } +func TestBrowserStaleMemoryMove(t *testing.T) { + testBrowserStaleInventoryMove(t, 9) +} + func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) { t.Helper() if os.Getenv("AO_GAME_TEST") != "1" { @@ -63,6 +67,11 @@ func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) { if sourceSlot == 37 { inventory.Items[0].Type, inventory.Items[0].Template = 51022, 101173 } + if sourceSlot == 9 { + inventory.Items[0].Type, inventory.Items[0].Template = 51022, 36779 + inventory.LastID = 3 + inventory.Items = append(inventory.Items, ownedItem{ID: 3, Type: 51022, Template: 36783, Quality: 1, Slot: 7, Count: 1}) + } if err := world.saveInventory_locked(player, inventory); err != nil { t.Fatal(err) } @@ -77,8 +86,9 @@ func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) { } json.NewEncoder(w).Encode(struct { playerInventory - Armor [8]int32 - }{player.inventory, armor}) + Armor [8]int32 + MaximumNCU uint32 + }{player.inventory, armor, player.maximumNCU()}) }) // Isolate an earlier bank transfer without refreshing its old source. mux.HandleFunc("POST /test-stale-view", func(w http.ResponseWriter, r *http.Request) { @@ -134,6 +144,10 @@ func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) { if sourceSlot == 37 { expected[0].Type, expected[0].Template, expected[0].Slot = 51022, 101173, 37 } + if sourceSlot == 9 { + expected[0].Type, expected[0].Template, expected[0].Slot = 51022, 36779, 9 + expected = append(expected, ownedItem{ID: 3, Type: 51022, Template: 36783, Quality: 1, Slot: 7, Count: 1}) + } for _, actual := range []playerInventory{player.inventory, cold.characters[1].inventory} { items := slices.Clone(actual.Items) slices.SortFunc(items, func(a, b ownedItem) int { return cmp.Compare(a.ID, b.ID) }) @@ -141,7 +155,7 @@ func testBrowserStaleInventoryMove(t *testing.T, sourceSlot uint32) { t.Fatal("stale ordinary move lost the banked item or changed another instance", actual) } } - if world.nextItem != 2 || cold.nextItem != 2 { + if world.nextItem != inventory.LastID || cold.nextItem != inventory.LastID { t.Fatal("stale ordinary move allocated another instance") } } diff --git a/server/equipment.go b/server/equipment.go @@ -288,8 +288,8 @@ func (server *server) advanceEquipment(now time.Time) { // Commit the old-speed prediction and ordered wear effects together. *character = motion for _, removed := range removedItems { - if removed.Slot >= 16 && removed.Slot <= 45 { - client.wornRemoval[removed.Slot-16] = nil + if removed.Slot > 0 && removed.Slot <= 45 { + client.wornRemoval[removed.Slot] = nil } if !removed.isWieldableWeapon() { server.queueCombat_locked(updates, character, character, equipmentActionPacket(character.id, removed, 7)) @@ -311,8 +311,8 @@ func (server *server) advanceEquipment(now time.Time) { updates[client] = append(updates[client], itemMovePacket(client.id, move.source, move.requestedSlot)) if move.destination < 64 && !item.isWieldableWeapon() { server.queueCombat_locked(updates, character, character, equipmentActionPacket(character.id, character.inventory.Items[index], 6)) - if move.destination >= 16 && move.destination <= 45 { - client.wornRemoval[move.destination-16] = equipmentActionPacket(character.id, character.inventory.Items[index], 7) + if move.destination > 0 && move.destination <= 45 { + client.wornRemoval[move.destination] = equipmentActionPacket(character.id, character.inventory.Items[index], 7) } } if move.source == 6 || move.destination == 6 { diff --git a/server/inventory.go b/server/inventory.go @@ -382,18 +382,19 @@ func (server *server) handleInventory(client *worldClient, body []byte) error { return nil } if index < 0 && client.equipment == nil && key == 0x47537a24 && - (sourceType == 102 && sourceSlot >= 16 && sourceSlot < 32 || sourceType == 103 && sourceSlot >= 33 && sourceSlot <= 45) && + (sourceType == 101 && sourceSlot > 0 && sourceSlot < 16 && sourceSlot != 6 && sourceSlot != 8 || + sourceType == 102 && sourceSlot >= 16 && sourceSlot < 32 || sourceType == 103 && sourceSlot >= 33 && sourceSlot <= 45) && binary.BigEndian.Uint32(body[24:28]) == 50000 && binary.BigEndian.Uint32(body[28:32]) == client.id && (destination == 111 || destination >= 64 && destination < 94) { // Clear the stale worn row without deleting its detached physical instance. if err := client.send(characterActionPacket(client.id, [5]uint32{146, sourceType, sourceSlot})); err != nil { return err } - if packet := client.wornRemoval[sourceSlot-16]; packet != nil { + if packet := client.wornRemoval[sourceSlot]; packet != nil { if err := client.send(packet); err != nil { return err } - client.wornRemoval[sourceSlot-16] = nil + client.wornRemoval[sourceSlot] = nil } return client.send(characterActionPacket(client.id, [5]uint32{112, sourceType, sourceSlot})) } diff --git a/server/main.go b/server/main.go @@ -409,10 +409,10 @@ func (server *server) serveWorldClient(client *worldClient) error { } updates = append(updates, fullCharacterPacket(character)) // Retain the exact native unwear contract while its source row is published. - client.wornRemoval = [30][]byte{} + client.wornRemoval = [46][]byte{} for _, item := range character.inventory.Items { - if item.Slot >= 16 && item.Slot <= 45 { - client.wornRemoval[item.Slot-16] = equipmentActionPacket(character.id, item, 7) + if item.Slot > 0 && item.Slot <= 45 && !item.isWieldableWeapon() { + client.wornRemoval[item.Slot] = equipmentActionPacket(character.id, item, 7) } } petUpdates := petOwnerPackets(character) diff --git a/server/stale_armor_move_test.go b/server/stale_armor_move_test.go @@ -82,7 +82,7 @@ func TestStaleArmorMoveUnwearsOnlyItsPublishedTemplateOnce(t *testing.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 != 2 || cold.nextItem != 2 || len(output.packets) != 5 || client.wornRemoval[2] != nil { + world.nextItem != 2 || cold.nextItem != 2 || len(output.packets) != 5 || client.wornRemoval[18] != nil { t.Fatal("stale armor correction changed ownership, allocation or repeated its unwear", err, len(output.packets)) } for index, action := range map[int]uint32{0: 146, 2: 112, 3: 146, 4: 112} { @@ -132,7 +132,7 @@ func TestStaleArmorMovePreservesInvalidAndPendingRequests(t *testing.T) { } } pending := client.equipment - removal := slices.Clone(client.wornRemoval[2]) + removal := slices.Clone(client.wornRemoval[18]) before, err := readTestItemStore(world) if err != nil { t.Fatal(err) @@ -144,7 +144,7 @@ func TestStaleArmorMovePreservesInvalidAndPendingRequests(t *testing.T) { after, readErr := readTestItemStore(world) if err != nil || readErr != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 || - len(output.packets) != 0 || !bytes.Equal(removal, client.wornRemoval[2]) || client.equipment != pending { + len(output.packets) != 0 || !bytes.Equal(removal, client.wornRemoval[18]) || client.equipment != pending { t.Fatal("invalid stale armor request changed ownership, pending wear or published metadata", err, readErr) } }) diff --git a/server/stale_implant_move_test.go b/server/stale_implant_move_test.go @@ -57,7 +57,7 @@ func TestStaleImplantMoveUnwearsItsPublishedTemplateOnce(t *testing.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 != 2 || cold.nextItem != 2 || len(output.packets) != 5 || client.wornRemoval[21] != nil { + world.nextItem != 2 || cold.nextItem != 2 || len(output.packets) != 5 || client.wornRemoval[37] != nil { t.Fatal("stale implant did not correct exactly once without changing ownership", err, len(output.packets)) } for index, action := range map[int]uint32{0: 146, 2: 112, 3: 146, 4: 112} { @@ -130,7 +130,7 @@ func TestStaleImplantMovePreservesInvalidAndPendingRequests(t *testing.T) { } } pending := client.equipment - removal := slices.Clone(client.wornRemoval[21]) + removal := slices.Clone(client.wornRemoval[37]) before, err := readTestItemStore(world) if err != nil { t.Fatal(err) @@ -142,7 +142,7 @@ func TestStaleImplantMovePreservesInvalidAndPendingRequests(t *testing.T) { after, readErr := readTestItemStore(world) if err != nil || readErr != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 || - len(output.packets) != 0 || !bytes.Equal(removal, client.wornRemoval[21]) || client.equipment != pending { + len(output.packets) != 0 || !bytes.Equal(removal, client.wornRemoval[37]) || client.equipment != pending { t.Fatal("invalid implant removal changed ownership, pending wear or its published effect", err, readErr) } }) diff --git a/server/stale_inventory_move_test.go b/server/stale_inventory_move_test.go @@ -151,7 +151,7 @@ func TestStaleRightHandMoveClearsOnlyEmptySourceWithoutWrites(t *testing.T) { } func TestStaleRightHandMoveIgnoresInvalidOrPendingRequests(t *testing.T) { - for _, scenario := range []string{"foreign actor", "foreign target", "wrong page", "other worn slot", "invalid destination", "pending equipment"} { + for _, scenario := range []string{"foreign actor", "foreign target", "wrong page", "unsupported left hand", "invalid destination", "pending equipment"} { t.Run(scenario, func(t *testing.T) { world, output := newEquipmentWorld(t) client := world.clients[1] @@ -163,8 +163,8 @@ func TestStaleRightHandMoveIgnoresInvalidOrPendingRequests(t *testing.T) { 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 "unsupported left hand": + binary.BigEndian.PutUint32(request[20:24], 8) case "invalid destination": binary.BigEndian.PutUint32(request[32:36], 94) case "pending equipment": diff --git a/server/stale_non_hand_move_test.go b/server/stale_non_hand_move_test.go @@ -0,0 +1,168 @@ +package main + +import ( + "bytes" + "encoding/binary" + "fmt" + "reflect" + "slices" + "testing" +) + +func newStaleNonHandMoveWorld(t *testing.T, source uint32) (*server, *combatTestConn) { + t.Helper() + world, output := newEquipmentWorld(t) + player, client := world.characters[1], world.clients[1] + templates := []uint32{161699} + moves := [][2]uint32{{65, source}} + if source == 9 { + templates = []uint32{36783, 36779} + moves = [][2]uint32{{65, 7}, {66, 9}} + } + for _, template := range templates { + if granted, err := world.grantItem_locked(player, template); err != nil || !granted { + t.Fatal(granted, err) + } + } + for _, move := range moves { + if err := world.handleInventory(client, inventoryMovePacket(1, move[0], move[1])[20:]); err != nil || client.equipment == nil { + t.Fatal("fixture non-hand equipment did not start installation", move, err) + } + world.advanceEquipment(client.equipment.readyAt) + } + + // Complete an earlier transfer while retaining the published native source. + inventory := player.inventory + inventory.Items = slices.Clone(inventory.Items) + index := slices.IndexFunc(inventory.Items, func(item ownedItem) bool { return item.Slot == source }) + item := inventory.Items[index] + item.Slot = 0 + inventory.Bank = []ownedItem{item} + inventory.Items = slices.Delete(inventory.Items, index, index+1) + if err := world.saveInventory_locked(player, inventory); err != nil { + t.Fatal(err) + } + output.packets = nil + return world, output +} + +func TestStaleNonHandMoveUnwearsItsPublishedTemplateOnce(t *testing.T) { + for _, source := range []uint32{3, 9} { + t.Run(fmt.Sprint(source), func(t *testing.T) { + world, output := newStaleNonHandMoveWorld(t, source) + player, client := world.characters[1], world.clients[1] + inventory := player.inventory + before, err := readTestItemStore(world) + if err != nil { + t.Fatal(err) + } + auditCheckpointWrites(t, world) + + for range 2 { + if err := world.handleInventory(client, itemMovePacket(1, source, 111)[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 != inventory.LastID || cold.nextItem != inventory.LastID || len(output.packets) != 5 { + t.Fatal("stale non-hand source did not correct once without changing ownership", err, len(output.packets)) + } + for index, action := range map[int]uint32{0: 146, 2: 112, 3: 146, 4: 112} { + packet := output.packets[index] + if binary.BigEndian.Uint32(packet[16:20]) != 0x5e477770 || binary.BigEndian.Uint32(packet[29:33]) != action || + binary.BigEndian.Uint32(packet[33:37]) != 101 || binary.BigEndian.Uint32(packet[37:41]) != source { + t.Fatalf("non-hand correction addressed another source: %x", packet) + } + } + template := uint32(161699) + if source == 9 { + template = 36779 + } + unwear := output.packets[1] + words := []uint32{} + for offset := 29; offset < 65; offset += 4 { + words = append(words, binary.BigEndian.Uint32(unwear[offset:])) + } + if binary.BigEndian.Uint32(unwear[16:20]) != 0x35505644 || + !slices.Equal(words, []uint32{template, template, 1, 1, 7, 101, source, 0, 0}) { + t.Fatal("non-hand correction did not undo its exact published effect", words) + } + }) + } +} + +func TestStaleNonHandMoveClearsOnlyTheRequestedEmptyRow(t *testing.T) { + world, output := newEquipmentWorld(t) + auditCheckpointWrites(t, world) + for _, source := range []uint32{1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13, 14, 15} { + for _, destination := range []uint32{64, 93, 111} { + t.Run(fmt.Sprintf("%d/%d", source, destination), func(t *testing.T) { + output.packets = nil + + err := world.handleInventory(world.clients[1], itemMovePacket(1, source, destination)[20:]) + + if err != nil || len(output.packets) != 2 || len(checkpointWrites(t, world)) != 0 { + t.Fatal("empty non-hand source did not receive cancellation and clearing", err, len(output.packets)) + } + for index, action := range []uint32{146, 112} { + packet := output.packets[index] + if binary.BigEndian.Uint32(packet[29:33]) != action || binary.BigEndian.Uint32(packet[33:37]) != 101 || + binary.BigEndian.Uint32(packet[37:41]) != source { + t.Fatalf("non-hand correction addressed another row: %x", packet) + } + } + }) + } + } +} + +func TestStaleNonHandMovePreservesInvalidAndPendingRequests(t *testing.T) { + for _, scenario := range []string{"foreign actor", "foreign target", "target type", "wrong page", "source before", "source after", "left hand", "invalid destination", "pending equipment"} { + t.Run(scenario, func(t *testing.T) { + world, output := newStaleNonHandMoveWorld(t, 3) + client := world.clients[1] + request := itemMovePacket(1, 3, 111)[20:] + switch scenario { + case "foreign actor": + binary.BigEndian.PutUint32(request[8:], 2) + case "foreign target": + binary.BigEndian.PutUint32(request[28:], 2) + case "target type": + binary.BigEndian.PutUint32(request[24:], 51017) + case "wrong page": + binary.BigEndian.PutUint32(request[16:], 102) + case "source before": + binary.BigEndian.PutUint32(request[20:], 0) + case "source after": + binary.BigEndian.PutUint32(request[20:], 16) + case "left hand": + binary.BigEndian.PutUint32(request[20:], 8) + case "invalid destination": + binary.BigEndian.PutUint32(request[32:], 94) + case "pending equipment": + if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil || client.equipment == nil { + t.Fatal("fixture weapon did not start wear", err) + } + } + pending := client.equipment + before, err := readTestItemStore(world) + if err != nil { + t.Fatal(err) + } + auditCheckpointWrites(t, world) + output.packets = nil + + err = world.handleInventory(client, request) + after, readErr := readTestItemStore(world) + + if err != nil || readErr != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 || + len(output.packets) != 0 || client.equipment != pending { + t.Fatal("invalid non-hand removal changed ownership or pending wear", err, readErr) + } + }) + } +} diff --git a/server/state.go b/server/state.go @@ -87,7 +87,7 @@ type worldClient struct { npcs map[uint32]bool dialogue *npcDialogue equipment *equipmentMove - wornRemoval [30][]byte + wornRemoval [46][]byte nanoCast *nanoCast reloadUntil time.Time lootCorpse uint32 diff --git a/tools/client/test_stale_inventory_move.mjs b/tools/client/test_stale_inventory_move.mjs @@ -5,9 +5,11 @@ import {GameTest} from './game_test.mjs'; const {chromium} = createRequire(import.meta.url)('playwright'); const [url, output, sourceSlot] = process.argv.slice(2); -const sourcePage = sourceSlot === '6' ? 101 : sourceSlot === '18' ? 102 : sourceSlot === '37' ? 103 : 104; +const sourcePage = sourceSlot === '6' || sourceSlot === '9' ? 101 : sourceSlot === '18' ? 102 : sourceSlot === '37' ? 103 : 104; const nativeSlot = sourcePage === 104 ? 48 : Number(sourceSlot); -const wornSlot = sourcePage === 102 ? 18 : sourcePage === 103 ? 37 : 6; +const wornSlot = sourcePage === 104 ? 6 : Number(sourceSlot); +const retained = sourceSlot === '9' ? [[2, 65], [3, 7]] : [[2, 65]]; +const expected = [[1, wornSlot], ...retained]; 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']}); @@ -27,7 +29,7 @@ try { 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); }; - const saveArmor = async label => { + const saveStats = async label => { await page.keyboard.press('Control+9'); const open = state => state.regions.some(([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606); @@ -49,15 +51,16 @@ try { } assert(sourcePresent() && cell(104, 49)); evidence.initial = await server(); - if (sourcePage === 102 || sourcePage === 103) await saveArmor('initial-armor'); + if (sourcePage === 102 || sourcePage === 103 || sourceSlot === '9') await saveStats('initial-armor'); 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.Items.map(item => [item.ID, item.Slot]), retained); assert.deepEqual(evidence.transferred.Bank.map(item => [item.ID, item.Slot]), [[1, 0]]); await game.save(output + '/stale'); const sequence = game.sequence; if (sourcePage === 102) await game.click(927, 94, 'right'); else if (sourcePage === 103) await game.click(927, 148, 'right'); + else if (sourceSlot === '9') await game.click(867, 262, 'right'); else 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 && @@ -68,7 +71,7 @@ try { event.direction === 'framereceived' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 146)); await game.wait('empty authoritative source cleared', () => !sourcePresent() && cell(104, 49) && game.state.dragged[0] === 0); assert.deepEqual(await server(), evidence.transferred); - if (sourcePage === 102 || sourcePage === 103) await saveArmor('refused'); + if (sourcePage === 102 || sourcePage === 103 || sourceSlot === '9') await saveStats('refused'); else await game.save(output + '/refused'); // The correction must leave the actual banked instance available on this page. @@ -82,18 +85,21 @@ try { const retry = game.sequence; await click(cell(104, 48), 'right'); await game.wait('valid same-page wear completes', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === wornSlot) && - game.events.some(event => event.sequence > retry && event.direction === 'framereceived' && event.opcode === '47537a24')); + game.events.some(event => event.sequence > retry && event.direction === 'framereceived' && event.opcode === '47537a24'), 15000); evidence.after = await server(); - assert.deepEqual(evidence.after.Items.map(item => [item.ID, item.Slot]).sort((a, b) => a[0] - b[0]), [[1, wornSlot], [2, 65]]); + assert.deepEqual(evidence.after.Items.map(item => [item.ID, item.Slot]).sort((a, b) => a[0] - b[0]), expected); assert.equal(evidence.after.Bank.length, 0); assert.deepEqual(evidence.after.Armor, evidence.initial.Armor); - if (sourcePage === 102 || sourcePage === 103) await saveArmor('moved'); + assert.equal(evidence.after.MaximumNCU, evidence.initial.MaximumNCU); + if (sourceSlot === '9') assert.deepEqual([evidence.initial.MaximumNCU, evidence.transferred.MaximumNCU, evidence.after.MaximumNCU], [10, 8, 10]); + if (sourcePage === 102 || sourcePage === 103 || sourceSlot === '9') await saveStats('moved'); else await game.save(output + '/moved'); await page.reload(); await game.ready(); await page.waitForFunction(() => touchRegion(500, 400)?.world === true); await game.snapshot(); - assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot]).sort((a, b) => a[0] - b[0]), [[1, wornSlot], [2, 49]]); + assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot]).sort((a, b) => a[0] - b[0]), + expected.map(([id, slot]) => [id, slot >= 64 ? slot - 16 : slot])); assert.deepEqual(await server(), evidence.after); assert.deepEqual(game.errors, []); console.log('PASS: stale inventory source cleared, exact banked item withdrawn/moved and both instances retained through page/cold recovery');