aorecomp

Anarchy Online classic in the browser

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


docs/research-notes/starter-weapon-research/inventory-reuse/findings.md (6955B)


Returned weapon inventory rows: original 14.9.1 client

Scope

Read-only original kkr.dll SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Ghidra 12.1.2 / bridge 12.1.4. Parent supplied the actual WASM observation: Meta Shield 121566 inventory row changes flag 1 to 2 on equip, survives unwear/retirement/move with flag 2, and no subsequent equip request is emitted. No runtime/client/server was started here and no implementation source edited. Full evidence and reusable snapshot are in this directory. REA target closed.

Root cause: answered, high confidence

  1. 10063340 attaches a live item to its parent. For an occupied inventory position it writes the live identity and calls 1002d310(slot,2). For page 1, slot 6 or 8, it also binds the weapon holder and invokes the WeaponItem equip callback. Thus creation itself changes the row kind. Evidence ev_8565b1dc163d3baca6f7edaba73ba92601f92e2a4b9a5d6dbabcd06474e60fdc. Flag setter: ev_dbcee3c897a035ff0b167b5a1fb42c13cb2df118079aeadcbf4fc859da25c07f.
  2. Row kind helpers 1002d710/1002d7b0 test flag bits 1 and 2 respectively. Template rows are accepted directly by possession helper 100619d0. Live rows require their dynel, except the explicit Chest fallback. 1002d980 resolves the row identity through GetDynel and SimpleItem cast. Evidence: ev_16480a45215d0af2a983e7add032f833c8fbeb56ff1a96a22138a5c52a4838df, ev_40cdad40c32876ccadfd43e11808ea806890c74a128840f7ca49f91a171fd15d, ev_ab99d17dff3a02abec7f6f085558c9a6663f26bbf9c34a6b0930fa7bd47c21f7, ev_f2d86a85a27c45e62b015c3b7f87f274eb48ed47c00c5ed7cf5149d2e6f543b4.
  3. UseItem 1002acd0 tests possession before deriving item type and making an equip request. Therefore a retired dynel behind flag 2 can prevent any request, independently of server validation. Evidence ev_26f560d019ca61b07db283078cb524be17bb14d6e3e53b7ef8c9a5f70db45788.
  4. ContainerMove helper 1005dd60 swaps whole row pointers via 1002d380; moving to ordinary inventory does not restore flag 1. Evidence ev_910a33cb4702112aa3fed9b72a812be94a21132d71135ab06f3a3c72639347c1, ev_174bb14886b746facb56f981da680c4693fe4b52a9f4d84c4ed582fd4cf078cb.

This is the same representation/lifetime problem documented for template vehicles in docs/vehicles.md, but live WeaponItem attachment forces flag 2.

InventoryUpdate cannot patch an ordinary row: answered

InventoryUpdate 0x4e536976 reader 100b0c20 reads encoded rows, target identity, index, open boolean. Activation 100b0cd0 resolves the target: Chest targets replace Chest contents; SimpleChar targets call 10062ec0(list,index). That function handles only index 110, the overflow container. It does nothing for ordinary inventory pages/slots. Using a normal-player InventoryUpdate to repair one row would not work.

Evidence:

No one-row packet preserving persistent identity and resetting flag 1 was established in this bounded pass. Existing Delete + AddTemplate reconstructs template rows without transmitting the persistent instance identity; full FullCharacter refresh has worn-initialization effects. Neither is required for the lifetime correction below.

Retain owner dynel until accepted re-equip: supported reconstruction

Evidence: ev_6eb78611bf2ab79a8a2be49e39d3f34fa64c5d381bd62fa5e1db91f8b893d217, ev_d5ddccab2da0a0c924f3cc81f723236a285ec6f3c0bdb8f2a91eced9b6f0b80d, ev_1b59c280459a0da247727b8694a3eac1b2442371d09ce9b0cadbcb83b7046210, ev_47108529ce3d378a168ded85439255a09cf31abe1120401b8664870e905f6858, ev_b26d8ee7657a823e04a45f49baf537b71eb29483eedfd245121eda5d40f04694.

Recommended sequence, agreed with parent:

This is reconstruction policy from native contracts, not a captured historical server sequence. Actual parent two-client testing must verify AC/effects, holder, appearance, actions, row identity/count and repeated reuse.

Cleanup beyond equipment: partially answered

1002d620 removes a row by destroying the 32-byte row and clearing the slot; it does not resolve or destroy its live dynel. Bulk clear 1002d660 does the same. A retained weapon therefore needs explicit owner Quit when deleted or ownership is removed, after the acknowledgement has consumed its source row. Evidence ev_86ca1a740e2b45c63527659f8b1a3f1c89ab16fc3b681a4e33ed1cf630e001bd, ev_d88710a022c0b87c52fac73a1f8e12279dceae3584232f228959d901d96e51c3.

Native bag-to-player transfer 1005fb40 resolves live rows through their dynel, requires IsInTree, moves the row and reparents the object. Do not retire a retained weapon before the transfer path consumes it. For bank or ownership removal, retire afterward and ensure any surviving destination representation is template-backed or has its own valid dynel. Existing BankIIR/Chest snapshots use flag 3 for template weapons. Full retained-weapon bank/bag transfer and deletion sequences remain runtime test boundaries. Evidence ev_46dd6a681c2e5ad41e32b7501270057b3867816afe10f5367e2c3f29c750a59e.

Existing exact Quit/DieDeep analysis is retained in docs/research-notes/fast-attack-research/native/re-equip.md: no direct inventory mutation in the Quit receiver or DieDeep body, but deeper native tree/parent callbacks are not exhaustively proved. This pass inspected WeaponItem and SimpleItem destruction (100ac240 ->10092640 ->1009cc20); they release item-owned resources, then invoke base dynel cleanup. No direct owner-row deletion appeared there. The remaining base callbacks should not be claimed safe in every container state solely from static evidence.