aorecomp

Anarchy Online classic in the browser

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


commit 83d9dba16c81d1c3f13efe9e8c90b8e1f80eeadb
parent 19224e2f58703d65d4d98061147cfb00c150f790
Author: anon <anon@example.com>
Date:   Sun,  1 Nov 2026 23:22:54 +0000

Support original Omni street insurance and reclaim

Use audited original scanner and reclaim placements through shared data, including saved-point validation and resurrection. Preserve the explicit provisional arrival transforms. Include reclaim booths in read-only native frame snapshots so the maintained generic picker can verify them.

Verified 46 Go roots and 163 results normally and under race, vet, C snapshot regression, 126 JavaScript checks, ordinary native travel/save/reclaim use, both page reconnects and fresh server/WASM recovery. All 37 owned instances and 111 physical records are retained. Earned death/return and ordinary level-ten reclaim collection remain open.

Diffstat:
MTODO.md | 18++++++++++++++++--
Mclient/runtime/browser_testing.c | 2+-
Mclient/tests/browser_testing.c | 14++++++++++++++
Mdocs/insurance.md | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mdocs/player-resurrection.md | 2+-
Mdocs/reclaim.md | 8+++++---
Mserver/control.go | 6++++--
Mserver/database.go | 3++-
Aserver/gamedata/insurance.yaml | 22++++++++++++++++++++++
Aserver/gamedata/insurance_test.go | 15+++++++++++++++
Mserver/gamedata/load.go | 15+++++++++++++++
Mserver/insurance.go | 15+++++++++------
Mserver/reclaim.go | 9+++++++--
Mserver/resurrection.go | 10++++++----
Aserver/street_insurance_test.go | 156+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 files changed, 328 insertions(+), 25 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -1032,12 +1032,26 @@ Historical outdoor give-up timing and obstacle navigation remain open. location and a later death returns the character there. - [x] Reclaim items after death. Check: the applicable items move to reclaim and can be recovered once, including after reconnect. -- [ ] [P1] Provide reachable insurance and reclaim coverage for all factions as +- [ ] [P0] Provide reachable insurance and reclaim coverage for all factions as progression reaches level 10. Admit original Clan/ICC scanners and reclaim placements through shared data and rules; verify ordinary travel, saved-return precedence, affiliation restrictions and recovery of the same item instances. - Only one Omni Entertainment scanner/reclaim booth is currently supported. + The earned-level-seven audit found blocked approaches to the first Omni + scanner's raised courtyard. The separately audited street-level Omni pair now + passes ordinary travel, native saving and empty reclaim open/close. Both page + reconnects and fresh server/WASM recovery retain all 37 owned instances, + 803 credits and cumulative insured XP 20875. Controlled tests cover its death + destination and exact item collection; the earned death/return continuation + and ordinary level-10 collection remain pending. Original courtyard access and + Clan/ICC coverage remain open. See [street insurance](docs/insurance.md#street-level-omni-pair). Unsaved training return must not imply that training contains a reclaim booth. +- [x] Include type 51059 reclaim booths in native frame snapshots. Check: + the maintained generic picker resolves the real typed booth after cold loading, + with read-only C traversal and preserved guest registers. The physical booth + is visible and ordinary native hover/selection/Use work. The C regression + reproduces the omitted type; its read-only filter now admits the real booth. + The matching published WASM and cold native generic-pick/open/close pass, + alongside all 126 JavaScript harness checks. See [street insurance](docs/insurance.md#street-level-omni-pair). - [ ] [P2] Apply the classic insurance/XP-loss policy. Check: recorded before/after XP and save-point cases match the documented 14.9.1 rule. Scanner snapshots and uninsured loss now commit atomically with death, with diff --git a/client/runtime/browser_testing.c b/client/runtime/browser_testing.c @@ -124,7 +124,7 @@ static void directory(FILE *output, uint32_t node, uint32_t nil, uint32_t local, if (node == nil) return; directory(output, MEM32(node), nil, local, count, local_id); uint32_t type = MEM32(node + 12), id = MEM32(node + 16), object = MEM32(node + 20); - if ((type == 50000 || type == 51005 || type == 51035 || type == 51050 || + if ((type == 50000 || type == 51005 || type == 51035 || type == 51050 || type == 51059 || type == 56001 || type == 56006) && MEM32(object + 0x60)) { if ((*count)++) fputc(',', output); actor(output, object, type, id, object == local); diff --git a/client/tests/browser_testing.c b/client/tests/browser_testing.c @@ -84,6 +84,19 @@ static void snapshot_copies_native_state_without_changing_guest_registers(void) assert(g_eax == 123 && g_esp == 456); } +static void snapshots_include_reclaim_booths_without_mutation(void) +{ + MEM32(0x50000304) = 0x50000600; + MEM32(0x5000070c) = 51059; + + browser_test_request(); + browser_test_frame(); + + assert(strstr(snapshot, "\"type\":51059,\"id\":99,\"position\":[89,115,151],\"screenPosition\":[89,115,151]")); + assert(MEM32(0x5000070c) == 51059 && MEM32(0x50000710) == 99); + assert(g_eax == 123 && g_esp == 456); +} + static void completed_picks_record_the_query_pixel_and_result(void) { guest_map("test action view", 0x2b0e0000, 0x10000); @@ -156,6 +169,7 @@ int main(void) snapshots_do_not_advance_the_pick_generation(); snapshots_observe_directory_clear_and_new_frames(); snapshots_observe_active_local_actions_without_mutation(); + snapshots_include_reclaim_booths_without_mutation(); free(snapshot); puts("PASS: frame snapshots, native inventory, directory clearing and guest state preservation"); } diff --git a/docs/insurance.md b/docs/insurance.md @@ -1,7 +1,7 @@ # Saving a resurrection location -The shipped Omni-Med scanner `51005:0xc00202c1` in Omni Entertainment can now -save a player's resurrection location through native right-click Use. Its +The two admitted original Omni-Med scanners in Omni Entertainment save a player's +resurrection location through native right-click Use. The selected scanner's identity persists in SQLite as `resurrection_terminal`, also exposed in the control editor. Death returns the player beside that scanner, including after reconnect or server restart. @@ -9,11 +9,14 @@ Unsaved characters return to their affiliated training entrance with a usable backyard association, under the provisional policy described in [player resurrection](player-resurrection.md). -This currently enables one scanner. Saving has no fee; the higher-level price +This enables two scanners through `server/gamedata/insurance.yaml`. +Saving has no fee; the higher-level price formula has not been recovered. The exact historical arrival transform is also unknown. The current return is explicitly provisional: playfield 705, XYZ `[918, 20.7, 578]`, facing east, three metres beside the scanner with human ground clearance. It is not presented as the shipped resurrection destination. +The street-level scanner `51005:0xc00802c1` uses the same rule at +`[598, 16.9, 329]`, facing west. Neither transform is an original server measurement. ## Shipped resources @@ -44,6 +47,55 @@ The scanner inventory is retained in `local/insurance-smoke/scanner-placements.j A bounded scan of non-image world resource types found the values 7051/7052 only in scanner descriptors, without a separate verified arrival record. +## Street-level Omni pair + +Original resource `1000026/705`, statel 263 at offset 42113, is the second Omni-Med +scanner 117665: type 51005, instance `0xc00802c1`, position +`[601, 16.400100708007812, 329]`. Its complete 104-byte record uses the same +descriptor as the first scanner except for stat 362, 7052 instead of 7051. Its original +orientation faces west. Statel 264 at offset 42221 places reclaim 37180, +type 51059, instance `0xc00a02c1`, at `[601, 16.400100708007812, 331]`. + +Both complete original item records match the maintained catalog, including +Omni affiliation on SaveChar 53032 and every companion descriptor. Full statel +bytes, resource offsets, payload hashes and the selected original index digest +are independently checked in `local/earned-death/terminals/original.json`. + +The shared data selects each saved arrival, including after cold loading and +unrelated profile validation. Generic Use checks the requested typed identity, +its own position, the current session and affiliation before saving. Reclaim +Use also checks its requested booth's position; proximity to another enabled +booth cannot authorize a remote identity. The subsequent identityless private +container actions accept proximity to either admitted reclaim placement. + +The retained level-seven Enforcer reached the new scanner through ordinary +native walking, selected its actual 51005 identity and saved cumulative XP 20875. +All 30 owned items, 803 credits and earned skills remained unchanged. The preceding +raised-courtyard approach attempts stopped at authored collision faces in both +native and server observations; they do not establish that every original +approach is blocked. Original courtyard access and Clan/ICC coverage remain open. + +The actual adjacent reclaim accepts native Use, opens an empty private window +and closes it again. Both page reconnects retain the same scanner, insured XP, +all 37 owned items and full resources. Thug's Delight expires normally during +travel; no earned death or level-ten item transfer is claimed by this run. + +The snapshot's world-type filter now includes reclaim type 51059. The standalone +C regression reproduces the omission and verifies read-only metadata and guest +register preservation. After publishing the matching WASM bundle, a fresh +server and two fresh clients resolve the real booth through `GameTest.pick`, +open/close its private window and reconnect both pages. Native stat 236 retains +20875. Independent SQL checks retain all 111 physical records, slots, charges, +qualities, wallets, skills and mission facts. + +The related Go selection passes 46 roots and 163 results normally and under +the race detector, plus vet. The new scanner regression fails against the +previous routing. All 126 JavaScript harness checks and the C snapshot check +pass. The ordinary hot and cold WASM checks pass in 723.23s and 37.17s. +Original payloads, packet decoding, ownership reports and cleanup evidence +remain in `local/earned-death/`. Actual earned death/return and ordinary +level-ten reclaim collection remain progression checks. + ## Native contract and server handling The target is original `anarchy-vanilla-14.9.1/kkr.dll`, SHA-256 diff --git a/docs/player-resurrection.md b/docs/player-resurrection.md @@ -3,7 +3,7 @@ Player death follows the native 14.9.1 resurrection request and zone transition without reloading the browser. Unsaved players return to their current faction's training entrance, using the same authored door and placement as character -creation. One [insurance scanner](insurance.md) persists a different return location. +creation. Selected [insurance scanners](insurance.md) persist a different return location. Returned health and nano are provisionally 1 each. These are reconstruction choices, not verified historical server values. diff --git a/docs/reclaim.md b/docs/reclaim.md @@ -2,14 +2,16 @@ Level 10 and higher players now send ordinary inventory items to private reclaim storage when defeated in PvE. Equipment and NoDrop items stay with the -player. One shipped reclaim booth in Omni Entertainment supports native use, +player. Two selected original reclaim booths in Omni Entertainment support native use, contents, close/reopen and collection into the next free inventory slot. Ownership and availability survive reconnect and server restart. Unsaved resurrection uses the affiliated training entrance. This does not add -reclaim to training: the only supported booth remains in Omni Entertainment. +reclaim to training: both admitted booths are in Omni Entertainment. Reachable Clan/ICC insurance and reclaim coverage is still required for normal progression into levels where inventory enters reclaim. +The original street-level pair and its typed placement checks are described in +[street insurance](insurance.md#street-level-omni-pair). The collection delay is provisionally 75 seconds from the killing blow. This uses the native DeadTimer fallback, not a recovered historical server timer. @@ -70,7 +72,7 @@ successful acknowledgement schedules native Use through `0x10087a70`, `0x1004ccc0` and `0x1004d780`. Booth implementation `0x1009b260` then emits CharacterAction 109 with zero identity arguments. Closing an existing window follows the same Use path and emits CharacterAction 110. These actions carry -no booth identity, so the server checks proximity to the supported booth. +no booth identity, so the server checks proximity to an admitted booth. `BankCorpseIIR_t`, key `0x52213420`, opens the private container. Reader `0x1007d1a0` delegates to proxy reader `0x101516d0` and inventory reader diff --git a/server/control.go b/server/control.go @@ -136,8 +136,10 @@ func (server *server) editUser(w http.ResponseWriter, r *http.Request) { if err == nil { err = server.validateUser_locked(updated.userData()) } - if err == nil && data.ResurrectionTerminal != 0 && data.ResurrectionTerminal != 0xc00202c1 { - err = fmt.Errorf("unknown resurrection terminal") + if err == nil && data.ResurrectionTerminal != 0 { + if _, known := gamedata.InsuranceTerminals.Scanners[data.ResurrectionTerminal]; !known { + err = fmt.Errorf("unknown resurrection terminal") + } } if err == nil { updated.inventory, err = (characterItemReferences{data.Inventory, data.Equipment, data.Bank}).inventory(server.items, server.nextItem) diff --git a/server/database.go b/server/database.go @@ -1,6 +1,7 @@ package main import ( + "ao/server/gamedata" "database/sql" _ "embed" "fmt" @@ -224,7 +225,7 @@ func (server *server) loadPlayers() error { if err := server.validateUser_locked(player.userData()); err != nil { return fmt.Errorf("player %d: %w", player.id, err) } - if record.Profile.ResurrectionTerminal != 0 && record.Profile.ResurrectionTerminal != 0xc00202c1 { + if _, known := gamedata.InsuranceTerminals.Scanners[record.Profile.ResurrectionTerminal]; record.Profile.ResurrectionTerminal != 0 && !known { return fmt.Errorf("player %d: unknown resurrection terminal", player.id) } player.nextPositionSave = time.Now().Add(time.Duration(player.id%20) * time.Second) diff --git a/server/gamedata/insurance.yaml b/server/gamedata/insurance.yaml @@ -0,0 +1,22 @@ +# Selected original 14.9.1 Omni-Med 117665 and Insurance Reclaim 37180 statels. +# Arrival transforms are provisional positions three metres in front of each scanner. +scanners: + 3221357249: + playfield: 705 + position: [915, 20.19999122619629, 578] + arrival: + position: [918, 20.7, 578] + rotation: [0, 0.70710677, 0, 0.70710677] + 3221750465: + playfield: 705 + position: [601, 16.400100708007812, 329] + arrival: + position: [598, 16.9, 329] + rotation: [0, -0.70710677, 0, 0.70710677] +reclaim: + 3221816001: + playfield: 705 + position: [915, 20.20009994506836, 580] + 3221881537: + playfield: 705 + position: [601, 16.400100708007812, 331] diff --git a/server/gamedata/insurance_test.go b/server/gamedata/insurance_test.go @@ -0,0 +1,15 @@ +package gamedata + +import "testing" + +func TestInsuranceTerminalsMatchSelectedOriginalPlacements(t *testing.T) { + scanner := InsuranceTerminals.Scanners[0xc00802c1] + reclaim := InsuranceTerminals.Reclaim[0xc00a02c1] + + if len(InsuranceTerminals.Scanners) != 2 || len(InsuranceTerminals.Reclaim) != 2 || scanner.Playfield != 705 || + scanner.Position != [3]float32{601, 16.4001, 329} || scanner.Arrival.Position != [3]float32{598, 16.9, 329} || + scanner.Arrival.Rotation != [4]float32{0, -.70710677, 0, .70710677} || reclaim.Playfield != 705 || + reclaim.Position != [3]float32{601, 16.4001, 331} { + t.Fatal("selected original insurance placements or provisional arrival changed") + } +} diff --git a/server/gamedata/load.go b/server/gamedata/load.go @@ -45,6 +45,20 @@ var ( Playfield uint32 `yaml:"playfield"` Position [3]float32 `yaml:"position"` } + InsuranceTerminals struct { + Scanners map[uint32]struct { + Playfield uint32 `yaml:"playfield"` + Position [3]float32 `yaml:"position"` + Arrival struct { + Position [3]float32 `yaml:"position"` + Rotation [4]float32 `yaml:"rotation"` + } `yaml:"arrival"` + } `yaml:"scanners"` + Reclaim map[uint32]struct { + Playfield uint32 `yaml:"playfield"` + Position [3]float32 `yaml:"position"` + } `yaml:"reclaim"` + } ProfessionTitles map[uint16]struct { Health [6]uint32 `yaml:"health"` Nano [6]uint32 `yaml:"nano"` @@ -85,6 +99,7 @@ func init() { loadYAML("playfields.yaml", &Playfields) loadYAML("player_appearances.yaml", &PlayerAppearances) loadYAML("banks.yaml", &BankTerminals) + loadYAML("insurance.yaml", &InsuranceTerminals) loadYAML("shops.yaml", &ShopMachines) loadYAML("mission_booths.yaml", &MissionBooths) loadYAML("missions.yaml", &MissionTemplates) diff --git a/server/insurance.go b/server/insurance.go @@ -36,11 +36,12 @@ func (server *server) handleTerminalUse(client *worldClient, body []byte) error return server.useWorldItem_locked(client, body, placement) } - // Shipped statel 51005:0xc00202c1 uses Omni-Med template 117665. + // Selected original scanners share Omni-Med template 117665's side criterion. + scanner, knownScanner := gamedata.InsuranceTerminals.Scanners[binary.BigEndian.Uint32(body[44:48])] position := predictedPosition_locked(player, time.Now()) - x, y, z := position[0]-915, position[1]-20.199991, position[2]-578 - accepted := client.target && player.playfield == 705 && player.appearance>>9&3 == 2 && - binary.BigEndian.Uint32(body[40:44]) == 51005 && binary.BigEndian.Uint32(body[44:48]) == 0xc00202c1 && + x, y, z := position[0]-scanner.Position[0], position[1]-scanner.Position[1], position[2]-scanner.Position[2] + accepted := client.target && knownScanner && player.playfield == scanner.Playfield && player.appearance>>9&3 == 2 && + binary.BigEndian.Uint32(body[40:44]) == 51005 && x*x+y*y+z*z <= 5*5 reclaim := binary.BigEndian.Uint32(body[40:44]) == 51059 grid := binary.BigEndian.Uint32(body[40:44]) == 51005 && binary.BigEndian.Uint32(body[44:48]) == 0xc0040320 @@ -62,14 +63,16 @@ func (server *server) handleTerminalUse(client *worldClient, body []byte) error destination.Rotation = [4]float32{0, -0.9999775, 0, 0.006704932} destination.ReturnDoor = nil } else if reclaim { - accepted = client.target && binary.BigEndian.Uint32(body[44:48]) == 0xc00902c1 && server.nearReclaim_locked(client) + terminal, known := gamedata.InsuranceTerminals.Reclaim[binary.BigEndian.Uint32(body[44:48])] + x, y, z := position[0]-terminal.Position[0], position[1]-terminal.Position[1], position[2]-terminal.Position[2] + accepted = client.target && known && player.playfield == terminal.Playfield && x*x+y*y+z*z <= 25 } else { accepted = accepted && len(player.inventory.Reclaim) == 0 } if accepted && !reclaim && !grid { // Persist the scanner before acknowledging use or changing live state. updated := *player - updated.resurrectionTerminal = 0xc00202c1 + updated.resurrectionTerminal = binary.BigEndian.Uint32(body[44:48]) lower, _ := updated.experienceBounds() updated.insuredExperience = lower + updated.experience if err := server.saveUser_locked(&updated); err != nil { diff --git a/server/reclaim.go b/server/reclaim.go @@ -30,8 +30,13 @@ func (player *character) collectReclaim(now time.Time) { func (server *server) nearReclaim_locked(client *worldClient) bool { player := server.characters[client.id] position := predictedPosition_locked(player, time.Now()) - x, y, z := position[0]-915, position[1]-20.2001, position[2]-580 - return player.playfield == 705 && x*x+y*y+z*z <= 5*5 + for _, terminal := range gamedata.InsuranceTerminals.Reclaim { + x, y, z := position[0]-terminal.Position[0], position[1]-terminal.Position[1], position[2]-terminal.Position[2] + if player.playfield == terminal.Playfield && x*x+y*y+z*z <= 25 { + return true + } + } + return false } func reclaimInventoryPacket(player *character, slots []uint32) []byte { diff --git a/server/resurrection.go b/server/resurrection.go @@ -1,6 +1,7 @@ package main import ( + "ao/server/gamedata" "encoding/binary" "time" ) @@ -35,10 +36,11 @@ func (server *server) handleResurrection(client *worldClient, body []byte) error } updated.playfield, updated.position, updated.rotation, updated.returnDoor = start.Playfield, start.Position, start.Rotation, start.ReturnDoor } else { - // Provisional safe arrival beside the shipped Omni-Med scanner. - updated.playfield = 705 - updated.position = [3]float32{918, 20.7, 578} - updated.rotation = [4]float32{0, 0.70710677, 0, 0.70710677} + // The selected scanner supplies its provisional safe arrival transform. + scanner := gamedata.InsuranceTerminals.Scanners[player.resurrectionTerminal] + updated.playfield = scanner.Playfield + updated.position = scanner.Arrival.Position + updated.rotation = scanner.Arrival.Rotation updated.returnDoor = nil } updated.sitting = false diff --git a/server/street_insurance_test.go b/server/street_insurance_test.go @@ -0,0 +1,156 @@ +package main + +import ( + "encoding/binary" + "reflect" + "slices" + "testing" + "time" +) + +func TestStreetInsuranceRetainsItsScannerAcrossDeathAndColdReturn(t *testing.T) { + world, output := newReclaimWorld(t) + loadResurrectionLocations(t, world) + player, client := world.characters[1], world.clients[1] + player.level, player.experience = 7, 225 + player.position = [3]float32{598, 16.9, 329} + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + items := slices.Clone(player.inventory.Items) + request := insuranceUseRequest(1)[20:] + binary.BigEndian.PutUint32(request[44:48], 0xc00802c1) + + if err := world.handleTerminalUse(client, request); err != nil { + t.Fatal(err) + } + insured := newTestInventoryServer(t).characters[1] + defeatReclaimPlayer(t, world) + dead := newTestInventoryServer(t).characters[1] + if err := world.handleResurrection(client, resurrectionRequest(1)[20:]); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if insured.resurrectionTerminal != 0xc00802c1 || insured.insuredExperience != 20875 || + dead.health != 0 || dead.experience != 225 || dead.insuredExperience != 20875 || + len(dead.inventory.Reclaim) != 0 || !slices.Equal(dead.inventory.Items, items) { + t.Fatal("street insurance or below-ten death lost its saved point, XP or belongings") + } + for _, current := range []*character{player, restored} { + if current.resurrectionTerminal != 0xc00802c1 || current.playfield != 705 || + current.position != [3]float32{598, 16.9, 329} || current.rotation != [4]float32{0, -.70710677, 0, .70710677} || + current.health != 1 || current.nano != 1 || current.experience != 225 || current.insuredExperience != 20875 || + !slices.Equal(current.inventory.Items, items) || len(current.inventory.Reclaim) != 0 { + t.Fatal("street-scanner return changed its transform, resources or retained items", current.userData()) + } + } + returns := 0 + for _, packet := range output.packets { + if binary.BigEndian.Uint32(packet[16:20]) == 0x445f2a0b { + returns++ + } + } + if returns != 1 { + t.Fatal("street-scanner return was missing or repeated", returns) + } +} + +func TestStreetInsuranceRejectsRemoteOrForeignTypedTargets(t *testing.T) { + for _, scenario := range []string{"Clan", "Neutral", "far", "wrong world", "remote scanner", "reclaim type", "reclaim identity", "unknown"} { + t.Run(scenario, func(t *testing.T) { + world, output := newReclaimWorld(t) + player, client := world.characters[1], world.clients[1] + player.position = [3]float32{598, 16.9, 329} + request := insuranceUseRequest(1)[20:] + binary.BigEndian.PutUint32(request[44:48], 0xc00802c1) + switch scenario { + case "Clan": + player.appearance = 0x315 + case "Neutral": + player.appearance = 0x115 + case "far": + player.position[0] = 595 + case "wrong world": + player.playfield = 950 + case "remote scanner": + binary.BigEndian.PutUint32(request[44:48], 0xc00202c1) + case "reclaim type": + binary.BigEndian.PutUint32(request[40:44], 51059) + case "reclaim identity": + binary.BigEndian.PutUint32(request[44:48], 0xc00a02c1) + case "unknown": + binary.BigEndian.PutUint32(request[44:48], 0xdeadbeef) + } + before := player.inventory + + if err := world.handleTerminalUse(client, request); err != nil { + t.Fatal(err) + } + + if player.resurrectionTerminal != 0 || player.insuredExperience != 0 || !reflect.DeepEqual(player.inventory, before) || + len(output.packets) != 1 || binary.BigEndian.Uint32(output.packets[0][29:33]) != 2 { + t.Fatal("invalid street-scanner use changed state or received success") + } + }) + } +} + +func TestStreetReclaimCollectsTheSameInstanceOnceAcrossColdLoad(t *testing.T) { + world, output := newReclaimWorld(t) + player, client := world.characters[1], world.clients[1] + player.position = [3]float32{598, 16.9, 331} + inventory := player.inventory + inventory.Reclaim = []reclaimItem{{inventory.Items[2], time.Now().Add(-time.Second).UTC()}} + inventory.Items = slices.Clone(inventory.Items[:2]) + if err := world.saveInventory_locked(player, inventory); err != nil { + t.Fatal(err) + } + request := insuranceUseRequest(1)[20:] + binary.BigEndian.PutUint32(request[40:44], 51059) + binary.BigEndian.PutUint32(request[44:48], 0xc00a02c1) + + if err := world.handleTerminalUse(client, request); err != nil { + t.Fatal(err) + } + if err := world.handleReclaim(client, reclaimRequest(109)); err != nil { + t.Fatal(err) + } + if err := world.handleInventory(client, reclaimTakeRequest(0)); err != nil { + t.Fatal(err) + } + packets := len(output.packets) + if err := world.handleInventory(client, reclaimTakeRequest(0)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + expected := []ownedItem{ + {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 6, Count: 1}, + {ID: 2, Type: 51018, Template: 121567, Quality: 1, Slot: 64, Count: 1}, + {ID: 3, Type: 51005, Template: 42640, Quality: 1, Slot: 65, Count: 1}, + } + if packets != 3 || len(output.packets) != packets || binary.BigEndian.Uint32(output.packets[0][29:33]) != 1 || + !slices.Equal(player.inventory.Items, expected) || !slices.Equal(restored.inventory.Items, expected) || + len(player.inventory.Reclaim) != 0 || len(restored.inventory.Reclaim) != 0 { + t.Fatal("street reclaim lost or duplicated its item or native response") + } +} + +func TestStreetReclaimUseRequiresTheRequestedBooth(t *testing.T) { + world, output := newReclaimWorld(t) + player, client := world.characters[1], world.clients[1] + player.position = [3]float32{598, 16.9, 331} + request := insuranceUseRequest(1)[20:] + binary.BigEndian.PutUint32(request[40:44], 51059) + binary.BigEndian.PutUint32(request[44:48], 0xc00902c1) + before := player.inventory + + if err := world.handleTerminalUse(client, request); err != nil { + t.Fatal(err) + } + + if len(output.packets) != 1 || binary.BigEndian.Uint32(output.packets[0][29:33]) != 2 || !reflect.DeepEqual(player.inventory, before) { + t.Fatal("proximity to one reclaim booth admitted a different remote identity") + } +}