aorecomp

Anarchy Online classic in the browser

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


commit 0c3df83d9a08b21a4cb9c170e338ed892bdb60db
parent b11c1c03501436a10b6a33c9bc64ac08f3bdf725
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 10:15:33 +0000

Save a resurrection location through an Omni-Med scanner

Diffstat:
MTODO.md | 4+++-
Mdocs/combat-client-protocol.md | 2+-
Mdocs/combat-client-reconstruction.md | 3++-
Adocs/insurance.md | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/player-resurrection.md | 14++++++++------
Mserver/control.go | 1+
Aserver/insurance.go | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/insurance_test.go | 201+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/loot.go | 4++--
Mserver/main.go | 8+++++++-
Mserver/resurrection.go | 7++++++-
Mserver/state.go | 11++++++-----
Mserver/users.go | 23++++++++++++++---------
13 files changed, 419 insertions(+), 27 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -133,7 +133,7 @@ recorded in [inventory behavior](docs/inventory.md). one living replacement appears with fresh resources and no old fight state. - [x] Resurrect a player through the native flow. Check: death leads to a valid resurrection location and usable character without reloading the browser. -- [ ] Save a resurrection location. Check: using one save terminal persists the +- [x] Save a resurrection location. Check: using one save terminal persists the location and a later death returns the character there. - [ ] Reclaim items after death. Check: the applicable items move to reclaim and can be recovered once, including after reconnect. @@ -144,6 +144,8 @@ The Leet's replacement lifecycle and explicitly provisional delay are recorded in [creature respawn](docs/npc-respawn.md). Native player return and provisional location/resources are recorded in [player resurrection](docs/player-resurrection.md). +The supported scanner, saved identity and provisional arrival/fee policy are +recorded in [insurance](docs/insurance.md). ## Loot and credits diff --git a/docs/combat-client-protocol.md b/docs/combat-client-protocol.md @@ -136,7 +136,7 @@ which can differ from object-field order. | SpecialAttackWeapon / `0x1d3c0f1c` | encoded weapon list, five i32 values `+24..+34` | Reader `0x10083f00`. Activation `0x10083fb0` rebuilds available weapon state and applies stats 118,119,120,149,51 (initiatives and Agg/Def). List layout described below. | | Skill / `0x3e205660` | i32 count, then count pairs `(i32 stat, i32 value)` | `0x10083d30` -> `0x10008c90`; activation `0x10083d80` assigns each stat. This is not evidence that a plain stat assignment starts a skill-lock countdown. | | Action / `0x2049527c` | i32 version **1**, i32 action `+20`, identity argument `+24` | Reader `0x100aea40`; activation `0x100aeaa0` dispatches to the actor/item action handler. Receiver rejects another version. Individual action contracts remain partial. | -| Resurrect / `0x445f2a0b` | two i32 values `+20,+24` | Reader `0x100b08d0`; activation `0x10080e20` assigns these to stats 27 and 214, then calls `0x10053230`. The server now handles the native action-152 return; insurance, reclaim and historical resource amounts remain unresolved. See [player resurrection](player-resurrection.md). | +| Resurrect / `0x445f2a0b` | two i32 values `+20,+24` | Reader `0x100b08d0`; activation `0x10080e20` assigns these to stats 27 and 214, then calls `0x10053230`. The server handles native action-152 return and one saved scanner; insurance fees, reclaim and historical resource amounts remain unresolved. See [player resurrection](player-resurrection.md). | `SpecialAttackWeapon` uses `0x100767d0`: an encoded count of `1009 * (count + 1)`, then four i32 values per entry. The reader stores these diff --git a/docs/combat-client-reconstruction.md b/docs/combat-client-reconstruction.md @@ -87,7 +87,8 @@ unknowns for each area: | Corpse loot | Native handlers and real combat/loot encounters | Fixed-item transfer persists; level-1 Leet corpses expire after a provisional 180 seconds; production drop tables remain unimplemented | | Creature respawn | Explicit provisional level-1 Leet delay; historical district units unresolved | One fresh replacement after 100 seconds; see [respawn](npc-respawn.md) | | Player resurrection | Native action 152 and Resurrect handler | Automatic native return with provisional location/resources; see [player resurrection](player-resurrection.md) | -| XP, reclaim and insurance | Separate rules and state required | Not implemented | +| Insurance return point | Shipped Omni-Med scanner and native Use/success response | One persistent saved scanner; arrival offset and free fee policy provisional; see [insurance](insurance.md) | +| XP, reclaim and insurance fees | Separate rules and state required | Not implemented | ## Implementation order and acceptance checks diff --git a/docs/insurance.md b/docs/insurance.md @@ -0,0 +1,105 @@ +# 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 +identity persists in `player.yaml` as `resurrection_terminal`. Death returns +the player beside that scanner, including after reconnect or server restart. +Unsaved characters keep the provisional starter return described in +[player resurrection](player-resurrection.md). + +This currently enables one scanner. 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. + +## Shipped resources + +The 14.9.1 resource database supplies these facts: + +- `server/gamedata/items/items_035.yaml`, template 117665, is the Omni-Med Cell + Structure Scanner. Its OnUse function 53032 (`SaveChar`) requires stat 33 + equal to 2, Omni affiliation. A separate failure function displays the + restriction for other factions. The corresponding Clan and ICC templates + are 117650 and 117651; they are not enabled by this milestone. +- Resource 1000026, instance 705, statel index 252 at payload offset 41125, + has a 104-byte entry for `51005:0xc00202c1`, template 117665. Its XYZ is + `[915, 20.1999912262, 578]`; source quaternion WZYX is + `[0.7071073055, 0, 0.7071061730, 0]`. +- The statel's HighLow descriptor assigns stat 362 the value 7051. The native + engine contains the string `e_ResurrectDest`; later enumerations give that + name to 362. The current investigation has not independently established + that numeric/name mapping or found a matching destination transform. +- Template 100281, About the Insurance Terminal, in `items_011.yaml` instructs + the player to right-click and says cost depends on level/location. + Template 117665 says XP is protected below level 20 and saving before then + can change the recovery location. These statements do not establish a + free-save level threshold or a price formula. +- Shipped `cd_image/text/help/Death and insurance.txt` says a new body appears + near the last saved scanner, and lower-level insurance is free. + +The scanner inventory is retained in `local/insurance-smoke/scanner-placements.json`. +A bounded scan of non-image world resource types found the values 7051/7052 +only in scanner descriptors, without a separate verified arrival record. + +## Native contract and server handling + +The target is original `anarchy-vanilla-14.9.1/kkr.dll`, SHA-256 +`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`. + +Native SaveChar handler `0x100c1da0` calls the return-only `0x1010ba00`; +it does not itself establish a server save. Evidence: +`ev_11a25ebb03c8b0852645cbb663f0676bf07fd77593ef189a1571b25fa20f06ca`. +CharacterAction receiver `0x1007d640` routes to `0x1006fa30`. Action 79 +displays the native insured message for the local character and assigns stats +49 and 236 from identity B's two integers. Evidence: +`ev_a72f5fcc86874822b1b63307e5a87629672d3ba8de1270fbeb43fe2e0bf7cd44`. +The export is `local/reports/insurance-1491-evidence.json`; REA was closed +before browser tests. + +The server validates the current session, loaded/alive state, both player +identities, Use command, target identity, playfield, affiliation and five-metre +three-dimensional range. It uses the same GenericCmd sequence watermark as +corpse use, so repeated or older commands cannot repeat an acknowledgement. +The profile is saved atomically before live state changes or success packets. +A failed write leaves the saved point unchanged and sends no success. +Socket writes occur outside the shared state mutex. + +A successful use completes GenericCmd and sends CharacterAction 79. Its saved +XP fields are zero because durable XP progression and insurance snapshots are +not implemented. This feature saves the return location; reclaim, XP loss, +fees and shock stat penalties remain separate work. Ordinary profile edits +and teleports preserve the saved scanner. Unknown scanner identities in saved +profiles fail loading rather than silently selecting another location. + +## Verification + +`server/insurance_test.go` covers native use followed by restart and death, +preservation through ordinary teleport/profile updates, faction and range +checks, invalid sessions/identities/actions, repeated concurrent uses, shared +Use sequencing, failed persistence and unknown saved identities. + +Two published WASM clients exercised the actual scanner. Right-click produced +the expected GenericCmd target and native insured message; the profile retained +the scanner through page reconnect and server restart. The fixture then moved +both clients to `[960.375, 16.5, 511.5]` (observer one metre north) for a real +encounter. The full-health 37 HP player hit the 100 HP profiled Leet once, +stopped attacking and died to its retaliation. Native action 152 returned the +player to the saved scanner at `[918, 20.7, 578]` with 1 HP/1 nano, without a +page reload. The observer saw the old body disappear; the surviving Leet had +90 HP and no fight state. The observer's saved scanner remained unset. + +After return, native walking reached `[919.75, 20.1875, 578]`; the client settled +onto the local ground. The equipped axe and owned Monster Parts remained +visible with the same identities. There were zero page errors and 15 expected +connection-refused messages during intentional restart. No client adapter +change was required. Test-owned browsers and the server were closed afterward. + +`local/insurance-smoke/verification.json` and `tmp_verify.py` retain the packet, +state and ownership checks. `scanner-use-packets.log`, `encounter-packets.log`, +the saved/returned profile snapshots and per-step PNG/JSON files retain the +native use, persistence, encounter and arrival evidence. + +The full maintained suite, `go test ./server/...`, passed after these changes. +Focused race checks also passed for `TestInsurance`, `TestResurrection` and +`TestLoot`, including concurrent and shared-sequence requests. diff --git a/docs/player-resurrection.md b/docs/player-resurrection.md @@ -1,8 +1,9 @@ # Player resurrection Player death now follows the native 14.9.1 resurrection request and zone -transition without reloading the browser. The return point is provisionally -playfield 705, XYZ `[960, 16.5, 510]`, in the existing Omni starter area. +transition without reloading the browser. For unsaved players the return point +is provisionally playfield 705, XYZ `[960, 16.5, 510]`, in the Omni starter area. +One [insurance scanner](insurance.md) now persists a different return location. Returned health and nano are provisionally 1 each. These are reconstruction choices, not verified historical server values. @@ -53,6 +54,7 @@ Only a ready, fully loaded, current session whose player is dead can request resurrection. The envelope must identify that session's own player. Repeated, stale, spoofed, alive and loading requests do nothing. +The return point comes from the saved scanner, or the unsaved starter default. The candidate return position is written atomically before changing live state or sending packets. A save failure leaves the dead character and session unchanged. On success the server clears posture, combat/recharge state and any @@ -64,10 +66,10 @@ equipment and inventory at the saved return point. Health and nano remain runtime state. Ordinary reconnect behavior still revives a defeated player with full health, and server restart initializes resources -from the saved character profile. This milestone does not implement insurance -terminals, saved resurrection points, item reclaim, XP loss or resurrection -shock stat penalties. Inventory remains owned across death. Those features -retain separate TODO entries. +from the saved character profile. One insurance terminal and its saved return +are now supported; other scanners, insurance fees, item reclaim, XP loss and +resurrection shock stat penalties remain unimplemented. Inventory remains +owned across death. See the [scanner evidence and limits](insurance.md). ## Verification diff --git a/server/control.go b/server/control.go @@ -236,6 +236,7 @@ func (server *server) updateUser_locked(destination userData) error { updated := destination.character() updated.inventory = character.inventory updated.browserTokenHash = character.browserTokenHash + updated.resurrectionTerminal = character.resurrectionTerminal updated.savedProfile = character.savedProfile updated.savedPosition = character.savedPosition updated.nextPositionSave = character.nextPositionSave diff --git a/server/insurance.go b/server/insurance.go @@ -0,0 +1,63 @@ +package main + +import ( + "encoding/binary" + "time" +) + +func (server *server) handleInsuranceUse(client *worldClient, body []byte) error { + server.updateMutex.Lock() + defer server.updateMutex.Unlock() + server.mutex.Lock() + player := server.characters[client.id] + if server.clients[client.id] != client || !client.ready || client.loading || player.health == 0 || + binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id || + binary.BigEndian.Uint32(body[16:20]) != 0 || binary.BigEndian.Uint32(body[24:28]) != 3 || + binary.BigEndian.Uint32(body[28:32]) != 1 || binary.BigEndian.Uint32(body[32:36]) != 50000 || + binary.BigEndian.Uint32(body[36:40]) != client.id { + server.mutex.Unlock() + return nil + } + sequence := binary.BigEndian.Uint32(body[20:24]) + if sequence <= client.useSequence { + server.mutex.Unlock() + return nil + } + client.useSequence = sequence + + // Shipped statel 51005:0xc00202c1 uses Omni-Med template 117665. + position := predictedPosition_locked(player, client, 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*x+y*y+z*z <= 5*5 + if accepted { + // Persist the scanner before acknowledging use or changing live state. + updated := *player + updated.resurrectionTerminal = 0xc00202c1 + if err := server.saveUser_locked(&updated); err != nil { + server.mutex.Unlock() + return err + } + *player = updated + } + server.mutex.Unlock() + + // GenericCmd completes the use; CharacterAction 79 confirms the save. + reply := append([]byte(nil), body[16:]...) + binary.BigEndian.PutUint32(reply, 2) + if accepted { + binary.BigEndian.PutUint32(reply, 1) + } + if err := client.send(n3Packet(0x52526858, 50000, client.id, reply)); err != nil { + return err + } + if accepted { + var action []byte + for _, value := range []uint32{79, 0, 0, 0, 0} { + action = binary.BigEndian.AppendUint32(action, value) + } + return client.send(n3Packet(0x5e477770, 50000, client.id, action)) + } + return nil +} diff --git a/server/insurance_test.go b/server/insurance_test.go @@ -0,0 +1,201 @@ +package main + +import ( + "encoding/binary" + "os" + "strings" + "sync" + "testing" +) + +func insuranceUseRequest(sequence uint32) []byte { + var body []byte + for _, value := range []uint32{0, sequence, 3, 1, 50000, 1, 51005, 0xc00202c1} { + body = binary.BigEndian.AppendUint32(body, value) + } + return n3Packet(0x52526858, 50000, 1, body) +} + +func TestInsuranceNativeUseSurvivesRestartAndReturnsAfterDeath(t *testing.T) { + useNPCData(t, testNPCData()) + world := newTestServer(t) + player := world.newCharacter() + player.playfield = 705 + player.position = [3]float32{918, 20.7, 578} + player.appearance = 0x515 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + connection := connectZoningClient(t, world, true) + + connection.Write(targetPacket(insuranceUseRequest(1))) + for _, key := range []uint32{0x52526858, 0x5e477770} { + packet, err := readPacket(connection) + if err != nil { + t.Fatal(err) + } + if binary.BigEndian.Uint32(packet[16:20]) != key || + key == 0x52526858 && binary.BigEndian.Uint32(packet[29:33]) != 1 || + key == 0x5e477770 && binary.BigEndian.Uint32(packet[29:33]) != 79 { + t.Fatalf("wrong native insurance acknowledgement: %x", packet) + } + } + connection.Close() + world = newServer() + player = world.characters[1] + destination := player.userData() + destination.Playfield = 950 + destination.Position = [3]float32{52, 14.75, 56} + if err := world.updateUser(destination); err != nil { + t.Fatal(err) + } + connection = connectZoningClient(t, world, true) + world.mutex.Lock() + player.health = 0 + world.mutex.Unlock() + connection.Write(targetPacket(resurrectionRequest(1))) + for range 3 { + if _, err := readPacket(connection); err != nil { + t.Fatal(err) + } + } + restarted := newServer() + + world.mutex.Lock() + defer world.mutex.Unlock() + if player.resurrectionTerminal != 0xc00202c1 || player.playfield != 705 || player.position != [3]float32{918, 20.7, 578} || player.health != 1 || player.nano != 1 { + t.Fatalf("death did not return to the scanner saved before restart: %+v", player) + } + if restarted.characters[1].resurrectionTerminal != 0xc00202c1 || restarted.characters[1].position != [3]float32{918, 20.7, 578} { + t.Fatal("resurrection erased the saved scanner or durable arrival") + } +} + +func TestInsuranceRejectsInvalidUseWithoutSaving(t *testing.T) { + for _, scenario := range []string{"Clan", "Neutral", "wrong zone", "too far", "dead", "loading", "unready", "replaced", "wrong owner", "wrong user", "wrong object", "wrong type", "reply", "wrong action", "11.0"} { + t.Run(scenario, func(t *testing.T) { + world, conn := newCombatWorld() + client, player := world.clients[1], world.characters[1] + player.playfield = 705 + player.position = [3]float32{918, 20.7, 578} + player.appearance = 0x515 + body := insuranceUseRequest(1)[20:] + switch scenario { + case "Clan": + player.appearance = 0x315 + case "Neutral": + player.appearance = 0x115 + case "wrong zone": + player.playfield = 950 + case "too far": + player.position[0] = 921 + case "dead": + player.health = 0 + case "loading": + client.loading = true + case "unready": + client.ready = false + case "replaced": + world.clients[1] = &worldClient{id: 1} + case "wrong owner": + binary.BigEndian.PutUint32(body[8:12], 2) + case "wrong user": + binary.BigEndian.PutUint32(body[36:40], 2) + case "wrong object": + binary.BigEndian.PutUint32(body[44:48], 0xc00802c1) + case "wrong type": + binary.BigEndian.PutUint32(body[40:44], 51050) + case "reply": + binary.BigEndian.PutUint32(body[16:20], 1) + case "wrong action": + binary.BigEndian.PutUint32(body[24:28], 2) + case "11.0": + client.target = false + } + + if err := world.handleInsuranceUse(client, body); err != nil { + t.Fatal(err) + } + + if player.resurrectionTerminal != 0 || player.savedProfile.ResurrectionTerminal != 0 { + t.Fatal("invalid use saved a resurrection terminal") + } + for _, packet := range conn.packets { + offset, bodyOffset := 16, 29 + if !client.target { + offset, bodyOffset = 20, 36 + } + if binary.BigEndian.Uint32(packet[offset:]) != 0x52526858 || binary.BigEndian.Uint32(packet[bodyOffset:]) != 2 { + t.Fatalf("invalid use received success: %x", packet) + } + } + }) + } +} + +func TestInsuranceRepeatedUsesShareTheGenericCommandSequence(t *testing.T) { + t.Chdir(t.TempDir()) + world, conn := newCombatWorld() + client, player := world.clients[1], world.characters[1] + player.playfield = 705 + player.position = [3]float32{918, 20.7, 578} + player.appearance = 0x515 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + + var uses sync.WaitGroup + for range 8 { + uses.Go(func() { + if err := world.handleInsuranceUse(client, insuranceUseRequest(2)[20:]); err != nil { + t.Error(err) + } + }) + } + uses.Wait() + world.handleLootUse(client, lootUseRequest(1)) + world.handleInsuranceUse(client, insuranceUseRequest(1)[20:]) + + if len(conn.packets) != 2 || client.useSequence != 2 || player.resurrectionTerminal != 0xc00202c1 { + t.Fatal("repeated or older use replayed insurance acknowledgement") + } +} + +func TestInsuranceSaveFailureDoesNotAcknowledgeOrChangeThePoint(t *testing.T) { + t.Chdir(t.TempDir()) + world, conn := newCombatWorld() + player := world.characters[1] + player.playfield = 705 + player.position = [3]float32{918, 20.7, 578} + player.appearance = 0x515 + if err := os.WriteFile("data", nil, 0600); err != nil { + t.Fatal(err) + } + + err := world.handleInsuranceUse(world.clients[1], insuranceUseRequest(1)[20:]) + + if err == nil || len(conn.packets) != 0 || player.resurrectionTerminal != 0 || player.savedProfile.ResurrectionTerminal != 0 { + t.Fatal("failed save changed or acknowledged the scanner") + } +} + +func TestInsuranceUnknownSavedScannerFailsLoading(t *testing.T) { + world := newTestServer(t) + player := world.newCharacter() + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + file, err := os.OpenFile("data/players/1/player.yaml", os.O_APPEND|os.O_WRONLY, 0600) + if err != nil { + t.Fatal(err) + } + file.WriteString("resurrection_terminal: 123\n") + file.Close() + + loaded := &server{characters: make(map[uint32]*character)} + err = loaded.loadUsers() + + if err == nil || !strings.Contains(err.Error(), "unknown resurrection terminal") { + t.Fatalf("unknown scanner was accepted: %v", err) + } +} diff --git a/server/loot.go b/server/loot.go @@ -110,10 +110,10 @@ func (server *server) handleLootUse(client *worldClient, body []byte) error { return nil } sequence := binary.BigEndian.Uint32(body[20:24]) - if sequence <= client.lootSequence { + if sequence <= client.useSequence { return nil } - client.lootSequence = sequence + client.useSequence = sequence corpse := server.characters[binary.BigEndian.Uint32(body[44:48])] reply := append([]byte(nil), body[16:]...) binary.BigEndian.PutUint32(reply, 2) diff --git a/server/main.go b/server/main.go @@ -406,7 +406,13 @@ func (server *server) serveWorldClient(client *worldClient) error { } switch binary.BigEndian.Uint32(body[0:4]) { case 0x52526858: - if err := server.handleLootUse(client, body); err != nil { + var err error + if len(body) == 48 && binary.BigEndian.Uint32(body[40:44]) == 51005 { + err = server.handleInsuranceUse(client, body) + } else { + err = server.handleLootUse(client, body) + } + if err != nil { return err } case 0x47537a24: diff --git a/server/resurrection.go b/server/resurrection.go @@ -16,11 +16,16 @@ func (server *server) handleResurrection(client *worldClient, body []byte) error return nil } - // Until insurance terminals exist, return to the known playable starter area. + // Unsaved players return to the known playable starter area. updated := *player updated.playfield = 705 updated.position = [3]float32{960, 16.5, 510} updated.rotation = [4]float32{0, 0.9238795, 0, -0.3826834} + if player.resurrectionTerminal == 0xc00202c1 { + // Provisional safe arrival beside the shipped Omni-Med scanner. + updated.position = [3]float32{918, 20.7, 578} + updated.rotation = [4]float32{0, 0.70710677, 0, 0.70710677} + } updated.returnDoor = nil updated.sitting = false // Starting health and nano are provisional until historical amounts are known. diff --git a/server/state.go b/server/state.go @@ -37,10 +37,11 @@ type character struct { npcDefinitionID string roaming *npcRoaming - browserTokenHash string - savedProfile playerProfile - savedPosition playerPosition - nextPositionSave time.Time + browserTokenHash string + resurrectionTerminal uint32 + savedProfile playerProfile + savedPosition playerPosition + nextPositionSave time.Time } type worldClient struct { @@ -59,7 +60,7 @@ type worldClient struct { dialogue *npcDialogue equipment *equipmentMove lootCorpse uint32 - lootSequence uint32 + useSequence uint32 } func (client *worldClient) send(packet []byte) error { diff --git a/server/users.go b/server/users.go @@ -36,14 +36,15 @@ type userData struct { } type playerProfile struct { - ID uint32 `yaml:"id"` - Name string `yaml:"name"` - Appearance uint16 `yaml:"appearance"` - MonsterData uint32 `yaml:"monster_data"` - Level uint16 `yaml:"level"` - Stats characterStats `yaml:"stats"` - Running bool `yaml:"running"` - BrowserTokenHash string `yaml:"browser_token_hash,omitempty"` + ID uint32 `yaml:"id"` + Name string `yaml:"name"` + Appearance uint16 `yaml:"appearance"` + MonsterData uint32 `yaml:"monster_data"` + Level uint16 `yaml:"level"` + Stats characterStats `yaml:"stats"` + Running bool `yaml:"running"` + BrowserTokenHash string `yaml:"browser_token_hash,omitempty"` + ResurrectionTerminal uint32 `yaml:"resurrection_terminal,omitempty"` } type playerPosition struct { @@ -167,6 +168,10 @@ func (server *server) loadUsers() error { return fmt.Errorf("duplicate user ID %d", user.ID) } server.characters[user.ID] = user.character() + if profile.ResurrectionTerminal != 0 && profile.ResurrectionTerminal != 0xc00202c1 { + return fmt.Errorf("%s: unknown resurrection terminal", path) + } + server.characters[user.ID].resurrectionTerminal = profile.ResurrectionTerminal inventoryPath := filepath.Join("data/players", file.Name(), "inventory.yaml") contents, err = os.ReadFile(inventoryPath) if err != nil && !os.IsNotExist(err) { @@ -205,7 +210,7 @@ func (server *server) users_locked() []userData { func (server *server) saveUser_locked(character *character) error { // Ordinary movement never rewrites identity, credentials or character properties. profile := playerProfile{character.id, character.name, character.appearance, character.monsterData, - character.level, character.baseStats(), character.running, character.browserTokenHash} + character.level, character.baseStats(), character.running, character.browserTokenHash, character.resurrectionTerminal} if profile == character.savedProfile { return nil }