commit def5bee6265e80b8fb820f1ec52d5b0e2f117671
parent a09c08322ae1503adfbfc328fcc5bf9b3cd91ecb
Author: anon <anon@example.com>
Date: Tue, 27 Oct 2026 14:14:49 +0000
Keep unsaved resurrection on affiliated training routes
Diffstat:
13 files changed, 382 insertions(+), 61 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -631,15 +631,20 @@ for exact records, protocol, tests and remaining reconstruction assumptions.
[native death and return](docs/starter-progression.md#native-death-and-return).
- [ ] [P1] Recover historical complex allocation and unsaved resurrection rules.
Creation currently assigns the first supported complex for the chosen faction;
- unsaved death still uses a provisional destination. Establish the original
- rules before replacing these policies. The shipped training grounds contain
- no reclaim placement; do not invent one.
-- [ ] [P0] Keep unsaved Clan/neutral deaths on a usable faction-appropriate return
- route. A fresh Clan Atrox NT's ordinary Salamander Boss defeat used the current
- Omni Entertainment fallback, retaining items and XP but stranding its training
- progression across factions. Recover the original initial checkpoint policy
- and reuse authored starter/scanner destinations; test all three sides, saved
- overrides, failed writes, reconnect and a normal return to training.
+ unsaved death reuses that faction's authored training entrance and preserves
+ a valid numbered backyard association. This fixes cross-faction stranding,
+ but does not establish the original initial insurance binding or allocation.
+ Recover those rules before replacing these policies. The shipped training
+ grounds contain no reclaim placement; do not invent one.
+- [x] Keep unsaved deaths on a usable faction-appropriate return route. Check:
+ reuse creation's authored training entrance and retain a valid numbered
+ backyard; saved insurance overrides the current affiliation. All three sides,
+ foreign/shop/unknown context, failed or ignored writes, failed COMMIT, retry
+ and cold retention pass. Six normally created WASM characters verified three
+ ordinary combat deaths, faction returns, backyard/training round trips and
+ exact retention of all 36 issued item instances after a cold restart. The
+ historical initial checkpoint policy remains the separate research above.
+ See [player resurrection](docs/player-resurrection.md).
- [ ] [P1] Deliver the authored explanation when a backyard city exit rejects a
player. Check: the original level-2-or-1,000-credit message appears once per
entry, without moving the player, charging credits or repeating every simulation
@@ -744,6 +749,12 @@ 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
+ 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.
+ Unsaved training return must not imply that training contains a reclaim booth.
- [ ] [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/docs/insurance.md b/docs/insurance.md
@@ -5,7 +5,8 @@ save a player's resurrection location through native right-click Use. Its
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.
-Unsaved characters keep the provisional starter return described in
+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
diff --git a/docs/player-resurrection.md b/docs/player-resurrection.md
@@ -1,9 +1,9 @@
# Player resurrection
-Player death now follows the native 14.9.1 resurrection request and zone
-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.
+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.
Returned health and nano are provisionally 1 each. These are reconstruction
choices, not verified historical server values.
@@ -54,11 +54,28 @@ 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 return point comes from the saved scanner, or the affiliated training entrance.
+An unsaved character retains its numbered backyard if that authored entrance
+leads to the affiliated training ground. Foreign, shop and unknown return doors
+are replaced by creation's lowest supported backyard. Saved insurance overrides
+the current affiliation and clears the training return context.
+
+| Unsaved affiliation | Training | Default backyard | Arrival XYZ |
+| --- | --- | --- | --- |
+| Neutral | 954 | Borealis 1 / 3060 | 239.886292, 6.167057, 72.431137 |
+| Clan | 952 | Tir 1 / 3100 | 42.737694, 14.75, 70.091897 |
+| Omni | 950 | Entertainment 1 / 3000 | 52.597332, 14.75, 57.636177 |
+
+This is a reconstruction policy that keeps fresh deaths on a usable return route.
+The original initial insurance binding, backyard allocation and exact death
+arrival have not been recovered. Shipped help establishes return to a saved
+scanner, but does not identify the checkpoint before the first save. The
+original training resources contain no reclaim terminal; none is invented here.
+
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
-old door return, restores the provisional resources, and sends Resurrect to
+unrelated door return, restores the provisional resources, and sends Resurrect to
nearby observers and the player. It then uses the existing teleport and world
redirect sequence. The departing session is removed before another request can
take effect. The replacement world session initializes the same character,
@@ -81,6 +98,38 @@ with the player. See the [scanner evidence and limits](insurance.md).
## Verification
+`server/initial_resurrection_test.go` covers all three affiliations, authored
+entrances, valid alternate backyard associations, rejected foreign/shop/unknown
+context, saved-scanner precedence after affiliation changes, retained equipment,
+inventory and XP across database reopen. Failed or ignored UPDATEs and failed
+COMMITs leave both live and durable state unchanged, publish no packets and allow
+one successful retry with the original association.
+
+The affiliated-return change passes the complete `go test ./server/... -count=1`
+suite: 1,471 top-level tests and 15,140 results (server 1740.407s, gamedata
+7.981s). Its focused selection passes 24 top-level tests / 92 results; the race
+selection passes 15 / 49 (337.074s). Vet and the server build pass. Frozen source,
+server, published client and read-only probe hashes match the tested inputs.
+Logs and verification scripts are under `local/initial-return/`.
+
+Three fresh Solitus Enforcers, each with a separately created observer, verified
+ordinary Leet defeats in Neutral, Clan and Omni training. No admin provisioning
+or edited positions, enemies, stats or rewards were used. Each client sent one
+automatic action 152, received one Resurrect with 1 HP/1 nano, and completed the
+redirect and ready handshake at its affiliated entrance. Each then walked to
+its own backyard and back into training. The observers received one death and
+one resurrection for their partner.
+
+After a clean preview restart, the same six characters loaded normally with
+all 36 issued item instances, charges and slots intact in SQLite and native
+inventories. Their level, XP, IP, credits and return associations were retained;
+earlier earned QA state was unchanged. Strict stream-offset decoding verifies
+the three death/return sequences and no death/return replay on cold reconnect.
+Screenshots were inspected on the GPU/OpenGL client; recorded browser-error
+lists are empty. Both clients close between faction runs. The single shared
+preview remains on HTTPS 8443. `native-verification.json`,
+`automation-verification.json` and `preview-verification.json` record the checks.
+
`server/resurrection_test.go` covers the native request/response order, durable
arrival before reconnect, retained inventory after restart, movement after the
new world handshake, concurrent repeated requests, both observers, stale and
@@ -100,9 +149,9 @@ killing hits. Closing the player tab immediately after action 99 left zero
health and the committed XP/reclaim state in SQLite. A fresh tab automatically
sent action 152 and returned to the saved scanner with 1 HP/1 nano. A second
interrupted death survived a clean server restart and automatically returned
-to the unsaved starter default with the same resources. Both retained progress
-1000, insured cumulative XP 140850, IP 1500 and the same reclaim item. A later
-living reload retained 7 HP/13 nano; walking afterward reached SQLite position
+to the then-configured unsaved starter default with the same resources. Both
+retained progress 1000, insured cumulative XP 140850, IP 1500 and the same
+reclaim item. A later living reload retained 7 HP/13 nano; walking afterward reached SQLite position
`[955.625, 16.375, 505.625]` without another death or return.
Independent stream decoding confirms one death replay and one native return
@@ -122,9 +171,9 @@ and the wider death/insurance/session-replacement selection (120.675s).
Two published WASM clients exercised a full-health 37 HP player's defeat by the
profiled 100 HP Leet. The native client sent action 152 automatically and
-returned with 1 HP/1 nano at `[960, 16.5, 510]`, without a page reload. The
-observer saw the living player return without a second body. Walking changed
-the server position to `[958.625, 16.375, 508.625]`; the equipped QL 1 Kinetic
+returned with 1 HP/1 nano at the then-configured `[960, 16.5, 510]`, without a
+page reload. The observer saw the living player return without a second body.
+Walking changed the server position to `[958.625, 16.375, 508.625]`; the equipped QL 1 Kinetic
Axe and owned Monster Parts remained visible. A second native attack damaged
the same surviving Leet and led to another death/automatic return. That second
encounter used a low-health fixture adjustment. Neither death required a
diff --git a/docs/reclaim.md b/docs/reclaim.md
@@ -6,6 +6,11 @@ player. One shipped reclaim booth in Omni Entertainment supports 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.
+Reachable Clan/ICC insurance and reclaim coverage is still required for normal
+progression into levels where inventory enters reclaim.
+
The collection delay is provisionally 75 seconds from the killing blow. This
uses the native DeadTimer fallback, not a recovered historical server timer.
Uncollected items accumulate across deaths without expiry; each keeps its own
diff --git a/docs/zoning.md b/docs/zoning.md
@@ -101,10 +101,12 @@ envelope policies described for whom-pahs below. Their endpoints and source
transforms are shipped data; these placement policies remain reconstruction.
Movement and return context follow the normal periodic position checkpoint.
-The routing change does not establish or change the historical unsaved death
-location. The original resources have no reclaim placement in the three shared
-training grounds. The current resurrection default remains provisional; no
-training reclaim terminal is invented. The complete ordinary starter progression
+Unsaved resurrection uses the same affiliated training entrance as creation and
+retains a valid numbered backyard association. Its initial checkpoint policy is
+provisional; the historical unsaved death location remains unknown. See
+[player resurrection](player-resurrection.md). The original resources have no
+reclaim placement in the three shared training grounds; no training reclaim
+terminal is invented. The complete ordinary starter progression
scenario is still open, including recovery supplies and a normally earned level-up.
`TestBackyard*`, `TestBrowserCreationBackyardReturnSurvivesRestart` and
diff --git a/server/browser_creation.go b/server/browser_creation.go
@@ -65,32 +65,13 @@ func (server *server) browserCreation(r *http.Request) (*character, error) {
}
appearance := appearanceFields{Race: selected.Race, Breed: selected.Breed, Sex: selected.Sex, Fatness: uint16(build), Side: uint16(side)}
data := userData{Appearance: appearance.packed(), HeadMesh: selected.Mesh, Height: uint16(height),
- Profession: uint16(profession), Level: 1, Running: true, Playfield: []uint32{954, 952, 950}[side]}
+ Profession: uint16(profession), Level: 1, Running: true}
- // Enter just beyond the authored backyard door, using the normal zone clearance.
- door := server.zoneLinks["target"][data.Playfield].Doors[0]
- data.Position, data.Rotation = door.Position, door.Rotation
- x, y, z, w := door.Rotation[0], door.Rotation[1], door.Rotation[2], door.Rotation[3]
- data.Position[0] += 2.5 * (2*x*z + 2*y*w)
- data.Position[2] += 2.5 * (1 - 2*x*x - 2*y*y)
- ground, _ := server.terrain[data.Playfield].elevation(data.Position[0], data.Position[2])
- data.Position[1] = ground + 0.75
-
- // Assign the first supported backyard; its original allocation policy is unknown.
- for playfield, zone := range server.zoneLinks["target"] {
- for _, entrance := range zone.Doors {
- if entrance.Destination != data.Playfield || entrance.DestinationDoor != door.ID {
- continue
- }
- if data.ReturnDoor == nil || playfield < data.ReturnDoor.Playfield ||
- playfield == data.ReturnDoor.Playfield && entrance.ID < data.ReturnDoor.Door {
- data.ReturnDoor = &doorOrigin{playfield, entrance.ID}
- }
- }
- }
- if data.ReturnDoor == nil {
- return nil, fmt.Errorf("training ground has no backyard entrance")
+ start, err := server.startingPosition(appearance.Side)
+ if err != nil {
+ return nil, err
}
+ data.Playfield, data.Position, data.Rotation, data.ReturnDoor = start.Playfield, start.Position, start.Rotation, start.ReturnDoor
return data.character(), nil
}
diff --git a/server/initial_resurrection_test.go b/server/initial_resurrection_test.go
@@ -0,0 +1,216 @@
+package main
+
+import (
+ "ao/server/assets"
+ "fmt"
+ "math"
+ "slices"
+ "testing"
+)
+
+var initialReturnCases = []struct {
+ name string
+ side uint16
+ training uint32
+ position [3]float32
+ backyard, door uint32
+}{
+ {"Neutral", 0, 954, [3]float32{239.886292, 6.1670566, 72.431137}, 3060, 3876588532},
+ {"Clan", 1, 952, [3]float32{42.737694, 14.75, 70.091897}, 3100, 3876588572},
+ {"Omni", 2, 950, [3]float32{52.597332, 14.75, 57.636177}, 3000, 3876588472},
+}
+
+func loadResurrectionLocations(t *testing.T, world *server) {
+ t.Helper()
+ var err error
+ world.zoneLinks, err = readZoneLinks()
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.terrain, err = readTerrain()
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestUnsavedResurrectionUsesAffiliatedTrainingAndRetainsBelongings(t *testing.T) {
+ for _, scenario := range initialReturnCases {
+ t.Run(scenario.name, func(t *testing.T) {
+ useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.appearance = player.appearance&^0x600 | scenario.side<<9
+ player.playfield, player.health, player.nano, player.experience = 705, 0, 0, 100
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ items := []ownedItem{{ID: 17, Type: 51018, Template: 121567, Quality: 1, Slot: 6, Count: 1}, {ID: 18, Type: 51005, Template: 42640, Quality: 1, Slot: 64, Count: 1}}
+ if err := world.saveInventory_locked(player, playerInventory{LastID: 18, Items: items}); err != nil {
+ t.Fatal(err)
+ }
+ conn := &combatTestConn{}
+ client := &worldClient{id: player.id, conn: conn, target: true, ready: true}
+ world.clients[player.id] = client
+
+ if err := world.handleResurrection(client, resurrectionRequest(player.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+
+ for _, current := range []*character{player, cold.characters[player.id]} {
+ if current.playfield != scenario.training || current.returnDoor == nil || *current.returnDoor != (doorOrigin{scenario.backyard, scenario.door}) ||
+ current.health != 1 || current.nano != 1 || current.experience != 100 || !slices.Equal(current.inventory.Items, items) {
+ t.Fatal("unsaved return crossed factions or lost earned state", current.playfield, current.returnDoor, current.inventory)
+ }
+ for index, want := range scenario.position {
+ if math.Abs(float64(current.position[index]-want)) > .0001 {
+ t.Fatal("return missed the authored training entrance", current.position)
+ }
+ }
+ }
+ if len(conn.packets) != 3 || world.clients[player.id] != nil || client.ready {
+ t.Fatal("return did not finish one native transition")
+ }
+ })
+ }
+}
+
+func TestUnsavedResurrectionKeepsAValidNumberedBackyard(t *testing.T) {
+ for _, scenario := range initialReturnCases {
+ t.Run(scenario.name, func(t *testing.T) {
+ useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.appearance = player.appearance&^0x600 | scenario.side<<9
+ player.playfield = scenario.training
+ player.health = 0
+ player.returnDoor = &doorOrigin{scenario.backyard + 1, scenario.door + 1}
+ wanted := *player.returnDoor
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true}
+ world.clients[player.id] = client
+
+ if err := world.handleResurrection(client, resurrectionRequest(player.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+
+ if player.playfield != scenario.training || player.returnDoor == nil || *player.returnDoor != wanted || cold.characters[player.id].returnDoor == nil || *cold.characters[player.id].returnDoor != wanted {
+ t.Fatal("death replaced the associated numbered backyard", player.returnDoor, cold.characters[player.id].returnDoor)
+ }
+ })
+ }
+}
+
+func TestSavedInsuranceReturnOverridesTheCurrentAffiliation(t *testing.T) {
+ for _, scenario := range initialReturnCases {
+ t.Run(scenario.name, func(t *testing.T) {
+ useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.appearance, player.resurrectionTerminal = 0x515, 0xc00202c1
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ player.appearance = player.appearance&^0x600 | scenario.side<<9
+ player.health = 0
+ player.returnDoor = &doorOrigin{scenario.backyard, scenario.door}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true}
+ world.clients[player.id] = client
+
+ if err := world.handleResurrection(client, resurrectionRequest(player.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+
+ for _, current := range []*character{player, cold.characters[player.id]} {
+ if current.playfield != 705 || current.position != [3]float32{918, 20.7, 578} || current.returnDoor != nil || current.resurrectionTerminal != 0xc00202c1 {
+ t.Fatal("initial return replaced the saved scanner", current.playfield, current.position, current.returnDoor)
+ }
+ }
+ })
+ }
+}
+
+func TestUnsavedResurrectionFailedWritesKeepTheOldLocationAndCanRetry(t *testing.T) {
+ for _, scenario := range initialReturnCases {
+ for _, failure := range []struct{ name, statement string }{
+ {"update", "CREATE TRIGGER reject_initial_return BEFORE UPDATE OF health ON characters WHEN NEW.id=1 AND NEW.health>0 BEGIN SELECT RAISE(FAIL,'return'); END"},
+ {"ignored update", "CREATE TRIGGER reject_initial_return BEFORE UPDATE OF health ON characters WHEN NEW.id=1 AND NEW.health>0 BEGIN SELECT RAISE(IGNORE); END"},
+ {"commit", "CREATE TABLE pending_initial_return (player_id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER reject_initial_return AFTER UPDATE OF health ON characters WHEN NEW.id=1 AND NEW.health>0 BEGIN INSERT INTO pending_initial_return VALUES(999999); END"},
+ } {
+ t.Run(scenario.name+"/"+failure.name, func(t *testing.T) {
+ useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.appearance = player.appearance&^0x600 | scenario.side<<9
+ player.health, player.nano = 0, 0
+ player.returnDoor = &doorOrigin{scenario.backyard + 1, scenario.door + 1}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ before := player.record()
+ conn := &combatTestConn{}
+ client := &worldClient{id: player.id, conn: conn, target: true, ready: true}
+ world.clients[player.id] = client
+ if _, err := world.db.Exec(failure.statement); err != nil {
+ t.Fatal(err)
+ }
+
+ err := world.handleResurrection(client, resurrectionRequest(player.id)[20:])
+ cold := newTestInventoryServer(t)
+
+ if err == nil || player.record() != before || cold.characters[player.id].record() != before || world.clients[player.id] != client || !client.ready || len(conn.packets) != 0 {
+ t.Fatal("failed initial return changed durable state or published success", err, player.playfield, player.returnDoor)
+ }
+ if _, err := world.db.Exec("DROP TRIGGER reject_initial_return"); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := world.handleResurrection(client, resurrectionRequest(player.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ retried := newTestInventoryServer(t).characters[player.id]
+
+ if retried.playfield != scenario.training || retried.health != 1 || retried.nano != 1 || retried.returnDoor == nil || *retried.returnDoor != (doorOrigin{scenario.backyard + 1, scenario.door + 1}) || len(conn.packets) != 3 {
+ t.Fatal("retry lost the numbered backyard or repeated the transition", retried.playfield, retried.returnDoor, len(conn.packets))
+ }
+ })
+ }
+ }
+}
+
+func TestUnsavedResurrectionRejectsUnrelatedReturnDoorContext(t *testing.T) {
+ for _, origin := range []doorOrigin{{3000, 3876588472}, {705, 0xc01102c1}, {3100, 1}} {
+ t.Run(fmt.Sprint(origin), func(t *testing.T) {
+ useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.appearance, player.health = 0x315, 0
+ player.returnDoor = &origin
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true}
+ world.clients[player.id] = client
+
+ if err := world.handleResurrection(client, resurrectionRequest(player.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.playfield != 952 || player.returnDoor == nil || *player.returnDoor != (doorOrigin{3100, 3876588572}) {
+ t.Fatal("unrelated door context selected the initial return", player.playfield, player.returnDoor)
+ }
+ })
+ }
+}
diff --git a/server/insurance_experience_test.go b/server/insurance_experience_test.go
@@ -171,6 +171,7 @@ func TestInsuranceExperienceDeathPreservesProtectedProgress(t *testing.T) {
func TestInsuranceExperienceSurvivesResurrectionWithoutAnotherLoss(t *testing.T) {
world, output := newBuffedDeathWorld(t)
+ loadResurrectionLocations(t, world)
player := world.characters[1]
player.level, player.experience, player.insuredExperience = 20, 1500, 140850
if err := world.saveUser_locked(player); err != nil {
diff --git a/server/player_death_test.go b/server/player_death_test.go
@@ -140,6 +140,7 @@ func TestPlayerDeathRefundsPendingCastWithoutRestoringItsBuff(t *testing.T) {
func TestPlayerResurrectionDoesNotReplayRemovedBuffs(t *testing.T) {
world, conn := newBuffedDeathWorld(t)
+ loadResurrectionLocations(t, world)
defeatReclaimPlayer(t, world)
conn.packets = nil
diff --git a/server/resurrection.go b/server/resurrection.go
@@ -16,17 +16,31 @@ func (server *server) handleResurrection(client *worldClient, body []byte) error
return nil
}
- // Unsaved players return to the known playable starter area.
+ // An explicit scanner overrides the affiliated training fallback.
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 {
+ if player.resurrectionTerminal == 0 {
+ start, err := server.startingPosition(unpackAppearance(player.appearance).Side)
+ if err != nil {
+ server.mutex.Unlock()
+ return err
+ }
+ // Keep a real numbered backyard, rather than an unrelated shop return.
+ if player.returnDoor != nil {
+ for _, door := range server.zoneLinks["target"][player.returnDoor.Playfield].Doors {
+ if door.ID == player.returnDoor.Door && door.Destination == start.Playfield {
+ start.ReturnDoor = player.returnDoor
+ break
+ }
+ }
+ }
+ 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}
+ updated.returnDoor = nil
}
- updated.returnDoor = nil
updated.sitting = false
// Starting health and nano are provisional until historical amounts are known.
updated.health, updated.nano = 1, 1
diff --git a/server/resurrection_reconnect_test.go b/server/resurrection_reconnect_test.go
@@ -32,6 +32,7 @@ func pendingResurrectionWorld(t *testing.T, saved bool) *server {
func reconnectResurrectionPlayer(t *testing.T, world *server, messages ...[]byte) [][]byte {
t.Helper()
+ loadResurrectionLocations(t, world)
host, peer := net.Pipe()
defer host.Close()
defer peer.Close()
@@ -128,11 +129,13 @@ func TestResurrectionReconnectResumesPendingDeath(t *testing.T) {
t.Fatal(err)
}
- position := [3]float32{960, 16.5, 510}
+ position := [3]float32{52.597332, 14.75, 57.636177}
+ playfield := uint32(950)
if saved {
position = [3]float32{918, 20.7, 578}
+ playfield = 705
}
- if writes != 1 || player.health != 1 || restored.health != 1 || restored.nano != 1 || restored.playfield != 705 || restored.position != position ||
+ if writes != 1 || player.health != 1 || restored.health != 1 || restored.nano != 1 || restored.playfield != playfield || restored.position != position ||
restored.experience != 1000 || restored.insuredExperience != 140850 || restored.stats.ImprovementPoints != 1500 ||
len(restored.activeNanos) != 0 || !reflect.DeepEqual(restored.inventory, durableBelongings) {
t.Fatal("resurrection lost durable state or restored resources more than once")
diff --git a/server/resurrection_test.go b/server/resurrection_test.go
@@ -1,6 +1,7 @@
package main
import (
+ "ao/server/assets"
"encoding/binary"
"os"
"slices"
@@ -17,6 +18,7 @@ func resurrectionRequest(owner uint32) []byte {
func TestResurrectionNativeRequestRedirectsAndPersistsBeforeReconnect(t *testing.T) {
useNPCData(t, testNPCData())
+ useResources(t, assets.Files)
world := newTestServer(t)
player := world.newCharacter()
if err := world.saveUser_locked(player); err != nil {
@@ -54,7 +56,7 @@ func TestResurrectionNativeRequestRedirectsAndPersistsBeforeReconnect(t *testing
world.mutex.Lock()
movement := *player
world.mutex.Unlock()
- movement.position[0] = 961
+ movement.position[0]++
connection.Write(targetPacket(npcMovementPacket(&movement, 2)))
ping := systemPacket(1, nil)
binary.BigEndian.PutUint16(ping[2:4], 11)
@@ -64,18 +66,19 @@ func TestResurrectionNativeRequestRedirectsAndPersistsBeforeReconnect(t *testing
}
arrived := restarted.characters[1]
- if arrived.playfield != 705 || arrived.position != [3]float32{960, 16.5, 510} || arrived.returnDoor != nil || !slices.Equal(arrived.inventory.Items, []ownedItem{item}) {
+ if arrived.playfield != 952 || arrived.position != [3]float32{42.737694, 14.75, 70.091897} || arrived.returnDoor == nil || *arrived.returnDoor != (doorOrigin{3100, 3876588572}) || !slices.Equal(arrived.inventory.Items, []ownedItem{item}) {
t.Fatalf("resurrection arrival or belongings did not persist: %+v", arrived)
}
world.mutex.Lock()
defer world.mutex.Unlock()
- if player.health != 1 || player.nano != 1 || player.position != [3]float32{961, 16.5, 510} || !world.clients[1].ready || world.clients[1].loading {
+ if player.health != 1 || player.nano != 1 || player.position != [3]float32{43.625, 14.75, 70} || !world.clients[1].ready || world.clients[1].loading {
t.Fatalf("resurrected character cannot play: %+v", player)
}
}
func TestResurrectionOnlyOnceAndClearsCombatForBothObservers(t *testing.T) {
world, conn := newCombatWorld()
+ loadResurrectionLocations(t, world)
t.Chdir(t.TempDir())
player := world.characters[1]
if err := world.saveUser_locked(player); err != nil {
@@ -157,6 +160,7 @@ func TestResurrectionRejectsInvalidRequests(t *testing.T) {
func TestResurrectionSaveFailureLeavesDeadCharacterAndSessionUnchanged(t *testing.T) {
world, conn := newCombatWorld()
+ loadResurrectionLocations(t, world)
t.Chdir(t.TempDir())
if err := os.WriteFile("data", nil, 0600); err != nil {
t.Fatal(err)
diff --git a/server/starting.go b/server/starting.go
@@ -0,0 +1,33 @@
+package main
+
+import "fmt"
+
+func (server *server) startingPosition(side uint16) (playerPosition, error) {
+ data := playerPosition{Playfield: []uint32{954, 952, 950}[side]}
+
+ // Enter just beyond the authored backyard door, using the normal zone clearance.
+ door := server.zoneLinks["target"][data.Playfield].Doors[0]
+ data.Position, data.Rotation = door.Position, door.Rotation
+ x, y, z, w := door.Rotation[0], door.Rotation[1], door.Rotation[2], door.Rotation[3]
+ data.Position[0] += 2.5 * (2*x*z + 2*y*w)
+ data.Position[2] += 2.5 * (1 - 2*x*x - 2*y*y)
+ ground, _ := server.terrain[data.Playfield].elevation(data.Position[0], data.Position[2])
+ data.Position[1] = ground + 0.75
+
+ // Assign the first supported backyard; its original allocation policy is unknown.
+ for playfield, zone := range server.zoneLinks["target"] {
+ for _, entrance := range zone.Doors {
+ if entrance.Destination != data.Playfield || entrance.DestinationDoor != door.ID {
+ continue
+ }
+ if data.ReturnDoor == nil || playfield < data.ReturnDoor.Playfield ||
+ playfield == data.ReturnDoor.Playfield && entrance.ID < data.ReturnDoor.Door {
+ data.ReturnDoor = &doorOrigin{playfield, entrance.ID}
+ }
+ }
+ }
+ if data.ReturnDoor == nil {
+ return playerPosition{}, fmt.Errorf("training ground has no backyard entrance")
+ }
+ return data, nil
+}