Original player trading contract
Two-player trading supports ordinary items, charged stacks, filled backpacks, free gifts and credits through the native trade windows. Both players consent before one SQLite transaction transfers ownership and cash. Cancellation keeps ownership and restores the native first-free layout. The server uses original client operations; the composed remote-template delivery sequence is a tested reconstruction, not a recovered historical server implementation.
Research is retained in docs/research-notes/player-trade-research/native/README.md and its
exported KKR/DDR/EER evidence. The shipped help file
cd_image/text/help/The Trade Window.txt independently describes both players
pressing ACCEPT, free gifts, entering cash with Enter, and the green opponent
acceptance indicator. Its SHA-256 is
315fbe0b3b1f7ef4be7cf01e688779f4ddd38c20fd2cb920782730c33445723e.
The source ledger is local/player-trade-research/sources/source-ledger.json.
Wire contract
TradeIIR key 0x36284f6e has six network-order DWORDs:
1, action, A.type, A.id, B.type, B.id. The outer N3 subject is separate.
Let P be the offering player and Q the other player; zero means (0,0).
| Action | Subject; A; B | Meaning |
|---|---|---|
| 0 | P; player Q; zero | Start; recursively initializes both player trade helpers |
| 1 | Q; zero; zero | Notify Q that its opponent accepted |
| 2 | P; (0,showMessage); zero |
Abort; recursively restores both players' offers |
| 3 | P; zero; zero | Complete P's outgoing items and cash; does not recurse |
| 4 | P; player P; (104,sourceSlot) |
Move an ordinary owned row into TradeInv |
| 5 | P; player P; (108,tradeSlot) |
Return one owned offer to ordinary inventory |
| 6 | P; (0,signedCash); zero |
Set P's offered cash |
| 7 | Q; player P; actual item identity | Add P's actual item to Q's peer display |
| 8 | Q; player P; actual item identity | Remove that peer row by actual identity |
Start can be sent unchanged to both clients. It needs neither vending catalog initialization nor a shop GUI tag. After an atomic transfer, both Complete directions must reach both clients, followed by any absolute cash corrections. An own-subject Accept echo would light the wrong opponent indicator.
KKR Start/Abort/Complete handlers are 0x10077370, 0x100774a0 and 0x10077700; the dispatcher is 0x100780b0. Ordinary native slots 48..77 correspond to server slots 64..93. Each player has thirty TradeInv slots, allocated first-free from zero. Removing an offer leaves other trade slots stable.
Restoration and consent
KKR Remove helper 0x10060090 returns the selected row to the first free ordinary slot. Abort scans TradeInv in ascending order and restores each row first-free. For example, offering saved slots 64 and 70 with slot 65 empty then cancelling returns them to 64 and 65. The shop implementation uses this same restoration rule and commits the layout before acknowledging cancellation or removal.
Offers remain durably owned until completion. When returning one row, remove all offered roots from the prospective ordinary layout, restore the selected row first-free, then reserve space for still-offered roots. Otherwise the returned row can collide with another offer's saved source slot. Draft source snapshots must follow these reservations. Preserve IDs, counts, QL, ammunition and container contents; cancellation changes placement, not ownership.
Enter commits the cash field locally through DDR SetCashMessage 0x10049410 and parser 0x10049090; it does not transmit Cash6. DDR Accept handler 0x10048870 sends Cash6 before Accept1 even if cash is unchanged. It sets a one-shot flag reset by TradeStart. Incoming Accept invokes the local callback; DDR 0x10048e70 lights the opponent's green lamp. No Unaccept action or second confirmation stage was recovered. Actions 7/8 are peer item operations. A later 2009 forum report of a confirmation dialog does not establish that behavior in 14.9.1.
The accepted player's offer is fixed. Once either player accepts, the other
player may add items or increase cash, improving the terms already accepted.
Removing items is rejected; reducing cash cancels the trade. This permits the
native Cash6-on-Accept sequence without silently approving a worse basket.
Simply clearing acceptance cannot make the one-shot UI send Accept again.
This monotonic consent rule is server policy inferred from the native contract;
the historical server's exact policy remains unproven. The protocol has no
basket revision or session nonce. Source details and the superseded blanket
freeze recommendation are in docs/research-notes/player-trade-research/native/cash-consent.md.
Restrictions and peer rows
The original start producer 0x1001f840 requires a different SimpleChar target within five units. No faction restriction was recovered. Offering equipped items, foreign items, NoDrop roots or items directly inside a container is rejected by the client. Ordinary filled backpacks are supported, but common validator 0x10060510 rejects any NoDrop or Unique child through 0x1008bdd0. Original server-error strings also describe recipient capacity and Unique duplicates; they do not establish exact server counting rules.
Rejected completion now uses the original FeedbackIIR key 0x50544d19, whose
body is one catalog-ID DWORD. Full recipients receive 24 and their partners 21;
duplicate Unique recipients receive 48 and their partners 47. The original
client supplies the text. Both inventories restore durably before Abort and
feedback; failed restoration leaves the draft retryable and sends neither.
The IDs, reader and native chat delivery are recovered client behavior. Selecting
the participant according to the text's perspective is reconstruction policy;
historical server routing and multi-error priority remain unproven. Research:
docs/research-notes/player-trade-research/native/feedback.md.
Peer Add7 reaches 0x10061b40 then row constructor 0x1002d870, which explicitly creates flags 0x22 and count one. QL and templates come from actual item stats 701/702/703. Neither Energy26 nor MultipleCount412 populates the row quantity. Peer page 208's stat412 reads the row itself in 0x1005de70. Complete preserves that row's count; its 0x1002dd90 call sets a dirty flag, not quantity. Consequently a full item dynel plus Add7 is insufficient for the correct displayed count of a charged template stack.
For template rows, the server instead sends AddTemplate key 0x052e2f0c
with the offering player's outer identity and the low/high templates, QL and
full count. KKR receiver 0x1007d090 supports a remote SimpleChar; helper
0x1005ef90 creates its first-free ordinary row. Trade4 on that same actor moves
the whole counted row into TradeInv. Native page208 displays the correct count,
and Complete transfers it intact into the recipient's ordinary inventory.
Portable backpacks use their actual ChestFullUpdate plus peer Add7; those roots
have count one and retain a usable container identity.
The template mirror has a temporary null native instance ID, as ordinary AddTemplate grants do. The server never allocates a replacement item: persistent IDs, QL, charges, ammunition and bag children travel unchanged. Cold reconnect restores native rows from those same persistent IDs.
Template peer removal uses Trade5 on the offering actor, then CharacterAction112
clears its restored remote ordinary scratch row. Abort restores all peer rows,
so cleanup clears the same number of ordinary slots from64. Complete also fills
the remote actor's ordinary inventory with outgoing local offers; those mirrors
are cleared afterward. Local owned rows are preserved. Without cleanup,
repeated sessions could fill invisible remote inventory and stop completion.
Evidence: docs/research-notes/player-trade-research/native/remote-template-delivery.md.
Persistence, lifecycle and verification
Each draft is shared by the exact two client sessions. Offered roots stay owned until commitment and are unavailable to conflicting item use, reload, shop/bank, loot and reclaim operations. An inventory move/delete/split cancels the draft before the original request can act on a newly restored slot. Departure, replacement, control edits, zoning, death or leaving the five-unit range cancel the draft. Every request also revalidates both participants.
Completion rechecks exact offered rows and restrictions, removes all outgoing roots from detached candidate inventories, then allocates incoming items in TradeInv order. Capacity and Unique checks use these prospective inventories, so a full inventory can swap items and outgoing Unique roots free eligibility. Unique checks use carried/worn items and carried bag contents, matching current inventory acquisition policy; exact historical bank/reclaim inclusion remains unproven. Filled bags may not contain NoDrop or Unique children.
Both players' placements and credit metadata commit in one existing SQLite transaction. Failed persistence publishes neither side or completion packet. After commitment, a failed reply disconnects/resynchronizes the affected client; it cannot reverse or repeat ownership. Both native Complete directions precede absolute local cash correction. No new item identity is allocated by a trade.
Tests cover admission, malformed ownership/pages, cash bounds/overflow,
consent, capacity swaps, Unique duplicates/swaps, bag contents, loaded weapons,
failed first/second persistence, cancellation retry, conflicting actions,
movement/control edits, death/reclaim, concurrent acceptance and lost replies.
The actual two-client GPU WASM captures are in
local/player-trade-live-smoke/. They verify both 25/50-charge baskets, a
500/200-credit exchange, empty and filled backpack gifts, NoDrop and duplicate
Unique rejection, disconnect cancellation and 32 offer/cancel cycles without
remote-row accumulation. Cold restart verifies durable identities, quantities,
balances and backpack contents. The clients use ordinary mouse/keyboard input;
heap and SQLite probes only inspect the resulting state.
An earned level-seven Enforcer also sold seven spare items for 663 credits, then lent exactly 1000 of its 1209 credits to the unchanged level-one observer. Both native cash-only trade consents completed before either wallet changed. The observer then satisfied the original Backyard1 exit's credit qualification and entered Omni-1 Entertainment without a debit. A second ordinary trade returned all 1000 credits. The settled wallets were again 1209/0, with all 25 owner items and seven observer items unchanged. No item offers or new identities were involved.
The stopped database conserves all 107 physical item/location rows after the
seven sales. Two fresh WASM clients recovered those wallets, ownership,
progression and insurance state exactly. Per-stage wire captures retain both
cash/consent directions and each client's two Complete messages. City traffic
exceeds one bounded trace, so the return-trade audit merges the saved stages
by event sequence. Evidence and independent verifiers are under
local/earned-eight/, including sales-verified.json,
prepared-verified.json and prepared-cold-verified.json.
Stale owned offer sources
A controlled missed-refresh fixture isolates a stale native offer after an earlier committed merge. The client still shows QL2 Treatment Laboratories with 3/5/7 charges, but the durable inventory contains only the 8/7 survivors. Offering the consumed source sends a real Add4 for the empty ordinary slot. Both native trade windows cancel, yet the owner's ghost and old counts remain.
For an authenticated Add with a valid, missing ordinary slot, cancellation now precedes the owner's shared stack refresh. The peer receives cancellation without inventory reconstruction. An empty draft has no placement restoration to persist, so cancellation skips its transaction; offered roots still restore atomically before cancellation is published. Repeated stale requests after cancellation cannot add an offer, transfer cash or allocate another item.
TestPlayerTradeStaleOfferRefreshesOnlyOwnerWithoutWrites checks both cancellation
directions, selected endpoints, an unrelated live weapon, the peer's retained
items/cash, zero checkpoint writes and exact cold ownership. The two-client
TestBrowserStalePlayerTradeOffer verifies real pickup/offer input, removal of
the ghost, restored 8/7 charges, a same-page retry displaying eight charges to
the peer, cancellation, both page reloads and cold conservation of fifteen
charges. This uses a controlled checkpoint rather than earned progression.
The failing capture is local/stale-player-offer/20261103-180015/; the corrected
34-second run is local/stale-player-offer/20261103-180405/. The focused write
audit also reproduced two character checkpoint updates and one world-header
update on empty-draft cancellation; the corrected handler makes none.
The broader disappearance audit remains open.
Instantiated loaded weapons
TestBrowserTradedWeapon closes a specific native coverage gap in the P0
disappearing-equipment audit. A controlled QL50 Cheap Kerans is worn and removed
before offering it, so both clients already know physical weapon ID1. Real
input cancels one offer, offers the same item again and completes both players'
consent. The recipient's anonymous template row immediately supports wear,
remove and rewear as that same physical ID, without a reconnect. One ordinary
shot consumes a loaded round and deals2 HP; both clients see the impact.
The giver retains its separate100-bullet stack, no weapon and no Sense bonus. The recipient retains the QL50 weapon with12 of its original13 loaded rounds, the selected160476/160477 endpoints and exactly one+2 Sense bonus. Page replay and a fresh server preserve those two physical item/location rows, unchanged wallets and raw skills/abilities. The level200, abilities300 and trained skills are controlled, cap-checked setup; this is not earned progression evidence. The gift does not establish additional historical trade policies.
The accepted run local/traded-weapon/20261103-084609 passes in88.52s
(warm61.30, cold27.21), or96.128s including Go. Independent packet and SQLite
checks verify that ID1 changes parent from player1 to player2, one shot leaves12
rounds and both snapshots retain exact ownership. All eight native traces have
no errors or dropped events. Camera placement and a guessed window height
caused the earlier fixture stops, before the handoff was exercised; no product
defect was reproduced. The broader disappearance audit remains open.
A cold-only run from that accepted warm database opens the giver's100-bullet
inventory and the recipient's worn-weapon panel with the native12-round HUD.
Both captures were reviewed; no trading or combat was repeated. Evidence is
local/traded-weapon-cold-inventory/20261103-084947 (20.10s, Go27.725s).
All ten combined traces are error-free without dropped events; the independent
report is local/traded-weapon/verification.json. The focused player-trade
suite passes20 groups and65 results in16.846s; vet, JavaScript syntax, gofmt
and whitespace checks pass.
Inventory refusals during player trade
The focused TestBrowserReclaimDuringPlayerTrade now also follows its collected
part through an ordinary-source deposit into an already-open owned backpack.
The actual page104/48 -> bag2/111 request aborts the empty trade and receives
source cancellation146. Both inventories remain unchanged. A second real pickup
and same-window deposit retry move that exact part1 into bag2/slot0. Page replay
reopens the bag with its child; cold Go loading retains both identities and an
empty peer inventory, with allocator2.
This route already worked; no server behavior change was needed. The fixture now keeps the unrelated peer's allocation cache unchanged and distinguishes the reset reclaim-window snapshot from durable ownership after page reload. Reordering cells inside ordinary inventory was observed to remain local and emit no InventoryMove; it does not reproduce the server's rejection branch.
The accepted controlled run local/trade-reclaim/20261104-110859 passes in14.84s
(Go22.458s). It uses one real WASM owner and a nearby controlled peer acting
through public trade handlers. It is not earned progression or a two-native-client
trade-acceptance check. Independent packet/state audits and captures are under
local/trade-inventory-drag/; the broader disappearance audit remains open.