aorecomp

Anarchy Online classic in the browser

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


docs/inventory-stacks.md (23320B)


Inventory stacks in 14.9.1

The supported stack is Essence of Pure Jealousy, template 152030, exact QL 42, identity type 51005. Its original record is in server/gamedata/items/items_078.yaml, with Can stat 30 = 513, flags 0x00400821, Energy 26 = 3 and Clip 212 = 3. Its description explicitly instructs Ctrl-clicking to separate a charge. It has no action/effect sections. New fixture grants use its three-charge catalog quantity. Production drops and tradeskill use remain separate features.

Stackability now follows the original Can stat 30, bit 9, for ordinary type 51005 items. This also permits creation's charged startup kits to persist and use the existing stack operations. It does not implement their use effects or establish every item's merge cap, deletion effects or creation quantity.

Auno's historical 12.8 record already includes the splitting instruction. Its current record and dated comments include a December 23, 2002 player report placing it in Steps of Madness. These corroborate the shipped item; they do not establish a historical stack maximum or drop rule. The shipped The Inventory Window.txt independently documents Ctrl-left-click splitting.

Native protocol

Evidence comes from original 14.9.1 kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. The retained bundles are local/reports/stack-protocol-1491-evidence.json (56 records) and local/reports/stack-resync-1491-evidence.json (44 records).

Both operations use CharacterAction 0x5e477770, with five network-order DWORDs after the message header:

Action Fields
52, split 52, sourcePage, sourceSlot, 0, retainedSourceCount
53, join 53, keptPage, keptSlot, removedPage, removedSlot

N3Msg_SplitItem at 0x10022d50 checks the original count and available space, applies the split locally through 0x1005edb0, then sends action 52. The final field is the count retained in the source. The first free ordinary slot receives the difference. The native search starts at 48 and ends at 77; server saved slots remain 64..93. An unchanged response does not split again, because the current source count already equals the retained count. Evidence: ev_602e0a0586dda4b99775a519b2ed33d5bc615ab035fad5777711bd513ed19b98 and ev_e501da0bcfc60b0bd90c7bc5fd33a29ad54cef983996514cc598828682277fb8.

N3Msg_JoinItems at 0x10022ba0 waits for its response. Both identities must be different slots in the same page, both item Can values must contain 0x200, and low/high template and QL must match. Response helper 0x1005ec30 keeps the first slot and adds the second slot's count before removing it. The generated-source helper is in client/game/kkr.dll/lifted-0029.c. Direction and checks are supported by ev_22f06fb27128af42a5babde5a290d6fd9f24bcd92d075f86a813261a0a2e60ae and ev_d87a842dd8417af8e91dcb61a97596d71ff6fce8b6bca2b6110cdabd783afcc6.

Stack mutations require inventory entry flag 0x1. Essence and other template items use flag 1, including worn template equipment. The equipped Kinetic Axe and portable Chests use flag 2 for their separate live identities. Local split clones use 0x21 and a zero instance identity. The row stores a ushort quantity at offset 6 and its QL/low/high triple at offsets 16/20/24. Persistent server IDs remain owned state, while stack requests address page/slot and carry no new instance ID or operation nonce.

The join helper performs a literal 16-bit addition and can wrap. The server rejects sums above 65535 to preserve quantity. This is the representation ceiling, not a recovered classic server stack cap. Neither catalog Clip 3 nor price stat 74 = 50000 establishes a merge maximum. The historical server cap remains unresolved. Overflow assembly evidence: ev_e650f59cb6fa2ba4d648045ef820df9906bafaacc81b90e200adaede6597eec4.

Overflow refusal feedback

An ordinary native join of controlled one-charge and 65535-charge stacks sends action 53 and hides its removed source while awaiting the response. Silently refusing the sum leaves that source dummy with an empty cursor, despite both instances remaining owned. The overflow guard now restores the validated removed ordinary source using the existing two ContainerAddItem GUI moves, without a successful join acknowledgement or storage writes. Both quantities and final placements stay unchanged. This does not change the representation ceiling or establish the historical server's stack limit.

TestStackOverflowRefusalRestoresRemovedSource checks both directions, exact source feedback, zero checkpoint writes and cold ownership. The existing ceiling regression still accepts 40000 plus 25535 and refuses 40000 plus 25536. The overflow refusal scenario in tests/e2e/browser.test.mjs sends two real joins from the same source, verifies both usable icons and all 65536 charges, then checks page replay and cold identities. These fixture quantities are controlled; no acquisition or earned-progression claim is made. Baseline failures and native captures are retained under local/stack-overflow/.

Related Go checks pass 96 roots and 377 results; focused race checks pass three roots and 11 results. Vet and Node syntax checks pass. The native run completes in 18.30 seconds with three clean, complete traces. Independent trace checks and source hashes are in local/stack-overflow/verification.json.

Persistence and rejection

Each instance has a ushort count in the world database. The supported Essence and QL 1 Simple Nano Kit can have counts above one. FullCharacter, corpse and reclaim entries serialize the quantity rather than a constant one. Atomic replacement of the shared store commits the counts, slot references and any newly allocated ID together, after saving successfully.

A split requires 1 <= retained < currentCount and an empty ordinary slot. The server gives the new stack the first free slot and a fresh global ID. An immediate repeated retained count preserves ownership. A known carried bag closes its window: the same request can also come from a stale quantity and an unowned optimistic clone. The ordinary page rebuilds its supported stacks for the same reason, preserving individual items and worn modifiers. The bank page retains its no-op handling; its native UI does not establish the same gesture. A repeated join finds the removed slot empty. The wire cannot distinguish every replay after subsequent slot reuse or a later merge; it has no previous-count or operation token. Every accepted operation still conserves the total quantity.

Stale ordinary quantities

A native three-charge laboratory can optimistically split after an earlier controlled consumption has left only one authoritative charge. Its action52 retains one, so the old equality branch sent no correction and left an unowned two-charge clone beside the real source. The ordinary equality branch now uses the existing stack-page correction, retaining individual items and worn effects while removing optimistic clones. It performs no ownership writes or allocation; duplicate requests remain idempotent for storage.

TestDepletedStackSplitCorrectsWithoutWriting checks both ordinary slot boundaries, repeated requests, exact selected endpoints/count/placement and zero checkpoint writes. TestBrowserDepletedStackSplit reproduces the old phantom with real Ctrl-click input. The fixed 18-second check permits normal cursor placement and immediate same-page Use of the one remaining QL2 charge, healing 1 -> 38 and retiring only that laboratory. Page replay and a separate database load preserve the worn axe and final item counter 2. The stale consumption is controlled setup, not earned progression or a claim about period timing. Baseline/native captures and an independent trace audit are retained under local/depleted-stack-split/.

Replaced ordinary sources

If a nonstackable item replaces a stale ordinary stack source, silently refusing its native split leaves the old row and an unowned clone. Preserving every individual-item slot during stack correction cannot repair that replaced row. An ordinary split now detects this case before pending-equipment refusal and rebuilds the affected source along with supported stacks. Unrelated individual items and equipment remain intact. Native weapon/container delivery retires only the affected live identity before recreating its correct subclass; known open backpack handles close before that container is recreated. First-free delivery and logical-slot restoration use the same correction path.

TestReplacedStackSplitCorrectsWithoutWriting covers loaded weapons, filled backpacks and ordinary nonstackable items at slots 64/93, repeated requests and a separate admitted equip. Ownership, quantities, loaded rounds, allocation and the pending move/deadline remain unchanged, with no checkpoint writes. TestBrowserReplacedStackSplit reproduces the original stale laboratory/phantom after a controlled bank exchange. Real Ctrl-click restores pistol ID2, QL2, endpoints 123742/123743 and three loaded rounds. Same-page native Use equips it; page replay and a separate database load retain it and laboratory ID1's three banked charges. The admitted equipment deadline is advanced explicitly, keeping this a short transfer/correction check rather than earned-progression evidence. Captures and the independent trace audit are in local/replaced-stack-split/.

Reviewed family anchors

Same-QL stacks identified by opposite endpoints of one reviewed family now join through the shared stack handler. Compatibility follows the native selected low/high template pair and quality, rather than equality of stored anchors. The kept physical instance retains its own stored anchor, slot and selected QL; only its count changes, and the removed physical instance is retired atomically. Different endpoint pairs, qualities, types and pages remain incompatible.

The baseline native reproduction used QL2 laboratories stored as 25812 and 25811. Both native entries had endpoints 25812/25811, so ordinary input sent action 53, but the server's raw-ID comparison silently refused it and left the removed source hidden. A second QL101 case reverses the kept anchor. Controlled three- and five-charge fixtures verify sixteen conserved charges across both joins, exact page replay and cold ownership. These are selected-quality contracts, not historical acquisition evidence.

Public-handler checks cover all three reviewed medical families at QL1/2/101/200, both kept anchors, ordinary/bank/packed-backpack pages and repeated requests. Bank cases exercise the shared server handler; the original bank UI does not produce a same-bank join gesture. Original DDR evidence and its limits remain in bank gestures. Baseline failures, native captures and source checks are retained under local/stack-family/.

Related Go checks pass 20 roots and 181 results; the expanded negative checks pass another root and 18 results. Focused race checks pass three roots and 94 results in 147.079 seconds. Vet and Node syntax checks pass. The native run completes in 17.68 seconds with five clean, complete traces. Independent request, acknowledgement and identity checks are in local/stack-family/verification.json.

The original client does not roll back a rejected optimistic split. A plain FullCharacter overlays only non-null rows and reapplies equipment, so it cannot remove a provisional clone safely. That behavior is supported by ev_331fd15acd45f210966ad41148a5960706f3a66f90d7daa3d710e0e9e5d29ba1. The server instead rebuilds only the supported ordinary stacks:

  1. Preserve occupied individual-item slots except a replaced split source, and preserve all equipment.
  2. Delete the other ordinary slots using native action 112, removing any provisional supported-stack clones. Neither supported template has deletion event functions.
  3. Deliver authoritative stacks and any replaced source in slot order. Stacks use AddTemplate 0x052e2f0c, body {low, high, QL, count}; individual sources use normal item delivery. Both choose the first free ordinary slot.
  4. Move it to its saved slot with the existing own-player ContainerAddItem response when needed.

This correction policy uses recovered native operations; it is not proof of how the original server rejected splits. It preserves individual live-item identities and avoids reapplying worn effects. AddTemplate creates template proxies without transmitting a persistent ID; reconnect supplies the saved IDs. Native proof: ev_51546b34f37c502e64f97b7f8d254e9cb41cf83c71b676217ffd69bc1ff2761a, ev_7b4afe19deabc80973ba1b2ac210a5f9b66e9ac793f6521ed89d7b5eec615066, and ev_78e48f17a73e495dccf184968e44268af825c92b3d9bd79d86ccd44c30c86806. Apparent ATR activation calls on these paths resolve to original 0x1010def0, a RET 4 stub, and must not be filled in as a missing adapter method.

Selected-quality stack resynchronization

The ordinary-stack rebuild resolves each instance's low/high pair before sending AddTemplate. Repeating its stored anchor instead changed the native contract of an intermediate-quality stack. A controlled refused QL2 laboratory split exposed 25811/25811 after starting with 25812/25811; storage still retained the same QL and three charges. Rebuild now preserves the selected pair, including collapsed exact endpoints, without changing ownership or the admitted equipment move.

TestStackSplitRefusalPreservesSelectedEndpoints checks both stored anchors of all three medical families at QL1/2/100/101/199/200 through the public inventory handler. Feedback retains the correct endpoints, QL and count with no durable writes; equipment completion and cold loading retain both original identities. The focused WASM check refuses real Ctrl-splits of QL2/101 laboratories while server equipment completion is held past the local animation. It preserves both endpoint pairs and all six charges, then completes the weapon and normally uses the restored QL2 laboratory for 37 health and one charge. Page/cold recovery retains the same instances. The controlled level, skills, health and supplies are test conditions, not earned progression. Evidence is retained under local/selected-stack-resync/.

Related Go checks pass 37 roots and 293 results; focused race checks pass three roots and 59 results in 107.654 seconds. Vet and Node syntax checks pass. The native run completes in 20.89 seconds with four clean, complete traces. Independent split/rebuild/use checks and source hashes are in local/selected-stack-resync/verification.json.

Stacks inside the supported backpack use page 107's packed handle/slot positions. Their optimistic-split correction uses the native Chest InventoryUpdate replacement instead of rebuilding ordinary inventory.

Join during pending equipment

A controlled late-completion checkpoint reproduced a hidden ordinary-stack source. The local equipment bar had ended while the server's admitted weapon move still awaited completion. Dragging one compatible stack onto another sent action 53, keeping the first identity and removing the second. The server refused the join without replying. Counts remained three plus three in storage, but the removed source's cell stayed dummy with an empty cursor.

The pending-equipment handler now validates the removed ordinary stack and restores its source through two ContainerAddItem GUI moves. Their temporary slot excludes both admitted equipment slots. Both stack positions and counts finish unchanged; the refused operation writes no database state or new identity and preserves the equipment move/deadline. It sends no successful join acknowledgement. After the admitted move completes, the same join can keep its normal identity and consolidate all six charges. Unknown, foreign-page and admitted sources remain ignored.

CharacterAction 146 is not used here: original kkr.dll function 10062960 stops the equipment-delay timer before source refresh. Its existing original evidence is ev_25a2e47151e712e04a9aee10cc6ae5c3b8efd8f18353f2a2896b9cea7735dbb9, with ordinary-page refresh in 100624b0, evidence ev_61d1c5f099044724b2a7a112f62381870d1411303dd74b6a3e17f3636c1a8440. Retained dossiers and limits are in local/bank-failure-research/feedback/. The original client's ordinary-grid refresh can also make its weapon source icon visible again. Preservation is checked against the unchanged admitted server move and its eventual native completion, not a requirement to retain every temporary dummy icon.

TestPendingStackJoin* covers both merge directions during wear and removal, exact source feedback, unchanged database state, admitted slots/deadline, normal retry and cold counts/ownership. TestBrowserStackJoinDuringPendingEquipment uses real equipment and join gestures, reproduces the refused source, completes the weapon move and retries the same join. Page replay and a fresh database reader retain the exact weapon and surviving six-charge stack. The fixture holds server completion past the local bar; it does not establish historical concurrent-inventory permission or the original server's refusal packet choice. Related Go checks pass 67 roots/289 results; focused race checks pass 5/16 and vet is clean. The native check completes in 19.25 seconds with three clean, complete traces. Captures, baseline failures, source hashes and limits are in local/pending-stack/verification-summary.json.

Stale ordinary join targets

A controlled missed refresh reproduces a hidden ordinary source without changing ownership. Three QL2 laboratories start with3/5/7 charges. An earlier committed merge retires ID1 into ID2, leaving8 charges in slot65 and ID3's7 charges in slot66. The native window still shows the old target in slot64. Dragging the real source onto it sends action53 and empties the cursor, but the missing target previously caused a silent return. The seven-charge source stayed dummy/hidden; both surviving instances and all fifteen charges remained in storage.

The complementary case drags the consumed ID1 onto the still-owned ID2. Its missing removed source also previously caused a silent return. The cursor clears and the ghost becomes hidden, while the visible kept stack still reports5 charges instead of8. No second ownership change is needed to repair this state.

The handler validates the surviving removed or kept entry as an owned ordinary stack, restores its GUI entry through the existing two ContainerAddItem swaps, then uses the ordinary-stack rebuild described above. This removes ghosts and sends the authoritative selected endpoints, QL and counts. It writes no inventory or allocation state and sends no successful join acknowledgement. Requests without a known owned stack, with an individual item instead, or with foreign pages or out-of-range slots remain ignored. Pending equipment retains its separate refusal path. This uses recovered native operations, without establishing the original server's refusal sequence.

TestStaleStackJoinRestoresOwnedSourceWithoutWrites checks repeated requests, source validation, both missing-entry directions, ordered restoration, exact selected endpoints, no writes and cold ownership. TestBrowserStaleStackJoin uses real inventory gestures to reproduce the missing source, restore usable8/7-charge rows and immediately retry against the correct target. Only that retry receives a successful action53; ID2 then retains15 charges through page replay and cold Go loading, with allocation still3. The earlier merge is controlled fixture state, not earned progression. The maintained fixture now runs both directions separately, with five clean traces each. They pass in17.64s/17.80s; captures are in local/stale-stack-join/20261103-164641/ and 20261103-164659/. The missing-source negative capture is local/stale-stack-join/20261103-164449/; the earlier missing-target baseline remains at 20261103-163358/. Related checks pass16 Go roots/168 results in69.151s. Repeated and concurrent joins retain one successful acknowledgement; ordinary repeats additionally resynchronize current rows. Bank/backpack reply behavior is unchanged. The focused race run passes3 roots/16 results in98.372s; vet and Node syntax checks pass. Independent request/reply, selected-contract, trace-completeness and source-hash checks are retained in local/stale-stack-source/validation.json.

Verification

server/stacks_test.go exercises grant quantities, merge direction, source retention and first-free allocation, repeat/concurrent requests, restart, unsigned-short overflow, full inventory, disk-write failures, invalid and foreign requests, corpse/reclaim encoding and migration of pre-quantity saves. A real world connection verifies actions 52/53 and that retained count 65 is not translated as an inventory slot. Rejected-split tests verify hole restoration and preservation of individual items and equipped armor.

The browser input adapter now preserves native Ctrl-left-click. Its previous global conversion to a right-click prevented the shipped inventory split gesture. client/tests/browser_camera.c reproduces that regression against the old adapter and verifies the corrected button/modifier state alongside right-button camera, wheel, focus-loss, key/text and touch behavior. Other camera controls retain their existing native input paths.

The matching rebuilt WASM bundle was exercised with two Chromium clients in local/stack-smoke/. Actual inventory gestures joined two three-charge stacks to six, Ctrl-clicked them into one plus five, and joined them again. A fixture rejected the next optimistic split through the production correction path: the native inventory returned to six without changing the pistol, worn item identities, displayed AC 6 or attack rating 400. After placing the selected item, the restored stack could be split again. This does not claim that the native cursor selection is cleared by the correction.

The second owner independently split three into one plus two. Both clients reconnected after a server restart with unchanged saved slots, counts and IDs; a subsequent split allocated ID 114 after the previous global high-water mark 113. Ten read-only native heap snapshots matched the authoritative quantities. There were no client exceptions; sixteen connection refusals were expected during the intentional restart. The clients and fixture server were closed afterward. tmp_verify.py retains these checks beside screenshots and packet captures. The served Brotli executable was decompressed and matched against the tested build, and every published manifest digest was checked.

The focused C input fixture failed against the old Ctrl-click mapping and passed with the correction in both Chromium and Firefox. The browser control JavaScript tests and all three WASM publishing tests also passed. The complete maintained server suite, go test ./server/... -count=1, passed with ao/server completing in 84.361 seconds. The focused race run over stacks, inventory, equipment, armor, attack rating, overequipping, character stats, reclaim and combat passed in 136.415 seconds.