aorecomp

Anarchy Online classic in the browser

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


docs/research-notes/shop-purchase-research/native/README.md (13788B)


Original 14.9.1 purchase protocol ledger

Read-only investigation, 2026-10-24. No server, database, client runtime or production source changes. REA session exported to evidence.json and closed. This bundle includes the imported access snapshot's prior records; new focused records are indexed below. Existing shop evidence was reused before follow-up.

Target anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Ghidra 12.1.2, REA 6.5.0, profile 17fae9135c0f647ce7271e2b74936949ebe245320c1606a223c86bce0b2b7bed. Opened with local/shop-room-research/access/kkr-access.snapshot.json. UI evidence was reused from local/shop-research/wire/gui-evidence.json, target ddr.dll SHA-256 3c937161de8f690351c3c08e158431417cee9ced77a41b677e7123b61a8c9883. All addresses below are original 0x10000000 image addresses; generated KKR C uses base 0x36000000 (subtract 0x26000000).

Answer and scope

The stock packet is a template/quality catalog, with no owned item identity, quantity, availability, generation seed, price or stock category code. A native purchase basket contains catalog references and a selected package count. It does not reserve or move a pre-existing owned item. Completing that basket does not itself create purchased inventory or debit player cash in the inspected client path. Those are authoritative server responsibilities.

Consequently, "the same stock-owned instance becomes player-owned" is not a requirement established by this native protocol: there is no stock instance ID on this wire. A reconstruction may create a durable item on Accept, or retain an internal pre-created stock instance, but the latter is a server design choice. Whichever is chosen, inventory delivery and reconnect must reference the same durable owned record. Historical stock membership and random generation remain outside this native evidence and are not invented here.

Observed: exact catalog and trade wire

The common server n3Packet prefix is key, subject.type, subject.id, pass-on (four big-endian u32 words). Layouts below begin immediately after that prefix.

ShopUpdateIIR_t, key 0x58362220, subject (51035,machineID):

Offset Encoding Meaning
0 u32 (entryCount + 1) * 1009
4 + 12*i u32 Low template ID
8 + 12*i u32 High template ID; native reader substitutes low when zero
12 + 12*i u32 Quality; native reader retains low 16 bits

Reader 0x100aa350 rejects nonpositive/nondivisible count tokens and counts at least 1000. Zero entries is valid but handler emits the GM warning. The reader stores each tuple as {quality,low,high}. 0x100a98b0 clears the old catalog, appends tuples and creates browse rows with identity (111,i), null auxiliary identity, ushort count 1 and flags 0. Indices start at zero and are determined exclusively by packet order. 0x100aa810 finds a tuple by identity's second word, returning a null tuple for out-of-range indices; it does not check the identity type. The server must validate page and bounds itself.

Sources: existing wire batch1.json, batch2.json, batch5.json; extracted reused-0x100a98b0.txt. Follow-up E1/E2/E3 below. A new ShopUpdate replaces the index meaning; it is not an incremental per-instance stock update. Safe handling of a catalog replacement during an active basket needs server policy and runtime verification.

TradeIIR_t, key 0x36284f6e, subject normally (50000,playerID):

Offset u32 word
0 Version = 1
4 Action
8, 12 A.type, A.id
16, 20 B.type, B.id

For purchase Add action 4 and Remove action 5, A is machine identity and B is (111,catalogIndex). Each Add selects exactly one additional package. Each Remove removes one package and drops the row at zero. There is no count field in either request. 0x100a96b0 invokes 0x1001e210 with the same catalog reference as both entry identities; an existing row's signed16 quantity is incremented. There is no observed saturation check in that increment. 0x100a97b0/0x1001e2e0 recalculate/subtract one unit quote on removal.

Existing wire batch8.json, Evidence ev_d975751d3e08996e446dae5c8d38729be2881957763cac0c6acba52a822e6951, retains the basket helpers. E4 retains removal. This is a package count, not the shop's remaining supply. The browse catalog's count 1 does not impose a one-package purchase limit.

Observed: admission, package size, cancel and completion

Sender N3Msg_TradeAddItem at 0x1001fb50 runs generic inventory admission, rejects equipped references (101..103), requires a free trade row, resolves the selected shop template and exempts page111 from the NoDrop-sale rejection. For page111 it calls 0x100781c0, rejecting a positive shortfall. That helper returns pendingNetBasket + newUnitBuyQuote - currentCash61. The echoed Add handler 0x10077aa0 repeats affordability and checks 0x10062a20(template,1) for an already-owned Unique item before adding the catalog selection. These client checks are not server authority; forged requests bypass them.

Native 0x100a9710 returns selected packages times template stat212, provided the template reports that stat and its type is not 51018 (weapons). Otherwise it returns selected packages. Its only direct caller 0x100782a0 uses it for stat412 (current quantity) requested on a trade entry. Thus the basket can display, for example, the charges in multiple kits instead of package count. This proves display quantity calculation; it does not prove historical stack merging, packing across slots, package-size admission or server caps. Those must remain explicit choices until a purchase runtime confirms them.

Native Accept button behavior is already observed/documented in docs/shops.md: SetCash action6/A=(0,0), then Accept action1/A=B=zero. N3Msg_TradeAccept 0x1001fa40 only constructs/sends action1; it does not mutate inventory or cash. The Accept echo updates acceptance UI, not durable success. Abort action2 restores staged sales, clears trade state and removes the machine transaction; the catalog remains. Removing a purchase selection does not create inventory.

Complete action3 handler 0x10077700 clears busy flag8, emits CMsg_TradeCompleted(true) and enters vending finalizer 0x100a99d0. The finalizer drains the player's sale TradeInv via 0x1002d620/0x1002d940, then clears the machine purchase selection with 0x1001e390 and removes the per-player machine transaction. It has no purchase-item allocation loop and no write to cash61. Its virtual+0x24 call resolves via vtable 0x1017436c to 0x100030d0, which merely writes the actor identity at object+0x24/+0x28; it is not a hidden purchase-delivery call. New E5/E6 corroborate this. Only 0x10077700 is a direct caller of the finalizer (E7).

Source generated paths: client/game/kkr.dll/lifted-0013.c:sub_3601FB50, lifted-0034.c:sub_36077AA0, sub_36077700, lifted-0050.c:sub_360A96B0, sub_360A9710, sub_360A99D0. Existing wire batch4/batch6 plus new E5..E12 preserve pseudocode.

Observed quote; inferred authoritative purchase price

Existing docs/research-notes/shop-research/pricing/findings.md already establishes:

base = T(stockItemPrice * terminalStat427 * binary64(0.01))
discountPercent = min(T(ComputerLiteracy161 * float32(0.025)), 90)
unitQuote = base - T(discountPercent * base * float32(0.01))
purchaseLineQuote = unitQuote * signed16(selectedPackageCount)

T truncates toward zero. Stock price74 uses the original QL interpolation and special quadratic price curve. 0x100a9610 quotes a whole package; it does not divide price by stat212. 0x100a9f60 uses that quote for pending basket purchase contributions. CL discounts are rounded per package before quantity. Exact constants/assembly are in pricing buy.json, sell-direct.json and initial-2/3/4.json. The purchase quote's 90% cap is observed; a later 80% rule must not override it.

This finalizer does not independently recompute/charge purchases on Accept. Therefore no distinct native accepted-purchase rounding formula was recovered. Using unitQuote * packageCount as server debit matches observed UI, but is an implementation inference, not a recovered historical server algorithm. Do not substitute sale-finalizer rounding, normalize buy price by charges, or round the CL reduction once after multiplying package count.

Owned-instance delivery and reconnect contract

Observed existing inventory protocol (docs/inventory.md, docs/inventory-stacks.md) supplies two different representations:

Inference for implementation: validate catalog index/tuple, eligibility, affordability, Unique rules, package quantity and inventory capacity at Accept; allocate the durable owned record(s) once; save ownership/count/template endpoints/QL and absolute cash atomically; only then publish inventory delivery, Complete and authoritative cash61. Repeated Accept and reconnect must reload the committed records, never allocate another copy from page111.

There is no native stock identity to preserve. AddTemplate's temporary null identity also means "identical nonzero native dynel ID before and after reconnect" is not established by that message. Durable server identity can be preserved while template actions continue to address page/slot. If a nonzero live native item identity must exist immediately, its exact supported object delivery route must be selected and exercised; do not invent an extra ID word in ShopUpdate or AddTemplate. A generic purchase grant should not silently claim that part verified.

New focused evidence index

All E1..E12 are in this directory's evidence.json; E13/E14 are prior evidence.

Label Procedure Evidence ID
E1 Shop reader100aa350 ev_93c995d1db78c190417a40765c1ae77d6262b551cbe8b91954e45f1f9a7cf6bb
E2 Shop writer100aa2d0 ev_d207c4da5f47beccba8a55ac3d9c90d40aae23f13af96e95f7449140736db567
E3 Catalog lookup100aa810 ev_d858cf58dd4a6304247c88a1f927bb4af076b8106d1d4ebd8372c9cee3ab7a6d
E4 Remove100a97b0 ev_057625c1406b09f6376063f377872439feaa019455afcf98d658a0cf26164985
E5 Finalizer100a99d0 ev_81f6a6cd3dc6e7d72ed9b9051e9aa9eb5dec90b90fbff8acf678a495080b29f1
E6 Actor setter100030d0 ev_2a6161dea2cf48330d6213c22e055eec4a42d60edf1202b1e1fd462862ff6d24
E7 Finalizer callers ev_ff53fc28634b10b1b507cf5db46cbd2a1e9446c7b72f77065056611cd1d4e258
E8 Affordability100781c0 ev_a70b7e186cea6e95a86485b1a5102851ac6e9bee91dcbc5c4532058a9badb360
E9 Package quantity100a9710 ev_ea9a267b8c47bed188cb5ad85d777b9b4eada71c29f6aeeb21b4892a0730efe4
E10 Trade stat100782a0 ev_0e2240e115d846fc99ee1f10809b07c9d6406ed36f2fb23e2aa8a217e994ac70
E11 Accept1001fa40 ev_5c26f6e16ffadf82588d144a09ecc3d6d882401f877cc3bcd65e8117eca59b59
E12 Clear basket1001e390 ev_ceb0a8338f2a937a76fb555f6d1a563931782f882c4d8e7e0737cacdfb6e9533
E13 AddTemplate reader1007cfe0 ev_51546b34f37c502e64f97b7f8d254e9cb41cf83c71b676217ffd69bc1ff2761a
E14 AddTemplate apply1005ef90 ev_7b4afe19deabc80973ba1b2ac210a5f9b66e9ac793f6521ed89d7b5eec615066

Remaining bounded gaps

Delivery follow-up: delivery.md establishes AddTemplate's explicit ushort charge count and generic type51022 template proxy support. Historical package packing remains unknown. equipment-admission.md establishes NPI slots 1,2,3,4,5,15 and the distinction between its authored Wear6/Intelligence>12 criterion and the native ItemType1 drag path selecting action8 without a Wear6 fallback. TemplateAction6/7 applies its wear/removal effects without a live FullUpdate; original server criterion enforcement remains unknown.

BUY icon follow-up: ui-basket.md establishes that TradeStart B=machine collides with the catalog classification branch and suppresses BUY icons. Use nonzero B distinct from both A=machine and actor; the reconstruction uses B=(111,0). Its exact historical literal remains unknown. New original DDR click/drop evidence is in ui-evidence.json; no extra icon packet is required by the inspected path.

  1. Catalog field schema and native basket protocol: answered statically.
  2. Stock generation/category membership/rotation: unresolved; no generator, random seed or inventory membership is transmitted here. Parent stock investigation owns historical sources. No full RDB scan was repeated.
  3. Buy quote: answered statically; authoritative historical server debit, caps and accepted-transfer rounding remain unobserved.
  4. Delivery/identity: normal inventory representations established; exact successful purchase packet ordering, package-to-stack packing, immediate nonzero native identity and reconnect behavior still need native runtime proof. This worker did not execute a purchase or mutate a runtime.
  5. Native Unique check across repeated basket selections versus owned items, refreshed catalogs during trade and client row capacity beyond one free row were not exhaustively traced. Server validation must not trust UI.