commit cd07b489c530795d9ed5426e2f69a2d7dac62f53
parent 2f4d2982e3e60a846df671e7a2578ae5831c0493
Author: anon <anon@example.com>
Date: Wed, 28 Oct 2026 00:55:04 +0000
Verify mission isolation across shared gameplay handlers
Diffstat:
3 files changed, 456 insertions(+), 8 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1543,14 +1543,15 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md).
the authored cash and selected-quality item reward; qualifying token/XP remains open. The approach volume
and 2.5-unit arrival offsets remain provisional.
See [mission interiors](docs/mission-interiors.md#key-gated-live-entry-and-atomic-return).
-- [ ] [P0] Verify private-instance boundaries across the complete playable loop.
- Check movement, visibility, combat, nanos, loot, inspection, trading and vicinity
- chat between same-instance guests and different owners at identical coordinates.
- Existing runtime IDs separate geometry and shared broadcast/inspection paths;
- expand negative and reconnect coverage as mission enemies/objectives are added.
- NPC/corpse/objective retirement now shares assignment revocation and occupant
- evacuation in one transaction. Complete the remaining cross-instance negative
- cases, including nanos, inspection, trade and vicinity chat.
+- [x] [P0] Verify private-instance boundaries across the complete playable loop.
+ Two accepted worlds and a copied-key guest at identical coordinates now cover
+ movement, visibility, combat/loot, nanos, inspection, trade, objective pickup
+ and vicinity/history. Stale interest, departed cast targets, late trade acceptance
+ and stale corpse windows cannot bypass the runtime world. Cold checks retain
+ exact ownership and leave another assignment untouched after retirement.
+ Two GPU WASM clients verify separate populations/chat/combat, shared guest
+ inspection/buffs/trade, departure cancellation, reconnect, cold restart and
+ isolated native abandonment. See [mission isolation](docs/mission-isolation.md).
- [ ] [P1] Recover original mission-door style and access policy.
The extractor decodes298 rooms from four ACD libraries and3692 door placements
with53 templates. Shared builders preserve authored door flags and optional QL;
diff --git a/docs/mission-isolation.md b/docs/mission-isolation.md
@@ -0,0 +1,77 @@
+# Private mission isolation
+
+The supported fixed-mission loop uses each accepted assignment's persisted
+runtime playfield ID as its instance boundary. A shared generator, exterior,
+room or actor position does not make two assignments the same world. Guests in
+the same runtime world receive ordinary shared gameplay; ownership and corpse
+entitlement remain separate checks.
+
+`server/mission_boundaries_test.go` accepts two real mission offers, populates
+both private worlds, and admits a third player through a copied key bound to the
+first assignment. All three stand at identical interior coordinates. Requests
+then go through the normal gameplay handlers rather than a separate isolation
+predicate.
+
+| Path | Different runtime worlds | Owner and same-world guest |
+| --- | --- | --- |
+| Actor interest and movement | No foreign population or relayed pose | Guest receives the owner's movement |
+| Player/NPC inspection | No reply or absorbed health-bonus state, even with stale known-NPC IDs | Requested represented actor replies |
+| Harmful and friendly nanos | Admission reserves nothing; a departing target cancels completion and durably refunds once | Damage/effects and observer delivery work after a clear retry |
+| Player trade | No draft; late acceptance after departure cancels and restores the original axe | The same axe transfers once and survives restart |
+| Vicinity and history | Say, whisper, shout and emote exclude the other mission, including saved history | Owner and guest receive the message and retain the exact runtime world in history |
+| Combat and corpse loot | Stale interest cannot authorize combat; entitlement cannot authorize remote cash/item pickup | Shared kill, cash and exact-instance pickup survive restart |
+| Floor objective | Another assignment cannot take the book at the same coordinates | Guest picks up the original instance; only same-world observers lose its floor model |
+| Retirement | The other owner's journal, key, door, objective and five NPC lives remain | Owner and copied-key guest return outside before the world is removed |
+
+A checkpoint after retirement cannot recreate the deleted population. Existing
+mission tests additionally cover SQL failure/retry, concurrent assignment and
+reward requests, completed-world retention, copied-key cleanup and startup
+expiry. Existing visibility tests cover periodic/control nanos and obstruction
+refund failures through the same admission/completion machinery.
+
+## Native verification
+
+Two owned, unmodified WASM clients ran on the GPU against the sole HTTPS8443
+preview. Visitors2/3 accepted missions43/45 and walked through the actual keyed
+entrance into worlds65541/65542. Controlled interior placements and casting
+skills isolate protocol/world behavior; this is not an ordinary fresh-character
+progression or historical balance check.
+
+At the same interior coordinates, read-only native actor-directory lookups show
+only each world's five original Leet IDs and its own player. Each client's T
+inspection resolves its own Leet. A vicinity message sent in65541 is absent from
+the other client's chat stream. Winter's Bite deals13 cold damage to1068625;
+only the caster's client receives that result.
+
+A control-panel placement then puts Visitor3 into65541 as a controlled guest.
+This does not test native key duplication; the copied-key admission path is
+covered by the Go fixture. Both clients now resolve both players. Ctrl+Tab and T
+show Visitor3's player information, shared vicinity reaches both, and Strength
+Boost27169 delivers the native effect to both observers. Native modifier maps
+show +12 strength on the recipient and0 on the caster. Right-clicking the guest
+opens trade on both clients. Returning the guest to65542 cancels the draft and
+removes the remote actor. Browser reconnect preserves the separation.
+
+Screenshots, original WebSocket streams, native snapshots and assertion-based
+accounting are retained under `local/mission-boundary-research/`. The direct
+handler tests establish forged-request rejection; an absent native target alone
+does not prove server enforcement. No gameplay rule or client patch was needed
+to satisfy these checks.
+
+A cold server restart also preserves both running world IDs, each world's exact
+five NPC IDs and the recipient-only saved buff. Native journal abandonment then
+retires the first world without disturbing the second player's private world,
+original population or journal. Test-only visitors and their state are removed
+afterward, with the preview stopped for database cleanup and all unrelated rows
+and identity counters checked unchanged.
+
+## Regression results
+
+The selected mission, chat, trade, inspection, combat, nano and pickup run passes
+215 test functions and1178 test/subtest results across `./server/...`. Race
+detection passes13 functions and19 results, including the eight new boundary
+tests and concurrent mission/trade lifecycle checks. Build and
+`go vet ./server/...` pass. Logs are retained beside the native captures. No
+page exceptions or adapter aborts were recorded; baseline resource404 console
+messages remain. Owned browsers are closed, and one preview remains on the
+default game ports and HTTPS8443.
diff --git a/server/mission_boundaries_test.go b/server/mission_boundaries_test.go
@@ -0,0 +1,370 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "testing"
+ "time"
+)
+
+func newMissionBoundaryWorld(t *testing.T) (*server, [3]*combatTestConn) {
+ t.Helper()
+ world, owner := newMissionEncounterOfferWorld(t)
+ outputs := [3]*combatTestConn{owner, {}, {}}
+ for _, id := range []uint32{2, 3} {
+ data := world.characters[1].userData()
+ data.ID, data.Name = id, fmt.Sprintf("Mission player %d", id)
+ world.characters[id] = data.character()
+ world.clients[id] = &worldClient{id: id, target: true, ready: true, conn: outputs[id-1], npcs: make(map[uint32]bool)}
+ if err := world.saveUser_locked(world.characters[id]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(world.characters[id], playerInventory{Credits: 5}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ request := missionOffersRequest()
+ binary.BigEndian.PutUint32(request[8:12], 2)
+ if err := world.handleMissionOffers(world.clients[2], request); err != nil {
+ t.Fatal(err)
+ }
+ for _, id := range []uint32{1, 2} {
+ request := missionAcceptanceRequest(*world.clients[id].missionOffer)
+ binary.BigEndian.PutUint32(request[8:12], id)
+ if err := world.handleMissionAcceptance(world.clients[id], request); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // A copied key admits the guest to the first owner's world, not the second's.
+ if granted, err := world.grantItem_locked(world.characters[3], 28577); err != nil || !granted {
+ t.Fatal("copy mission key", granted, err)
+ }
+ if _, err := world.db.Exec("INSERT INTO mission_keys VALUES (?,?)", world.nextItem, world.characters[1].missions[0].id); err != nil {
+ t.Fatal(err)
+ }
+ for _, id := range []uint32{1, 2, 3} {
+ client, player := world.clients[id], world.characters[id]
+ player.geometry = world.geometry
+ player.position, player.rotation = [3]float32{89.30216, 115.75, 152.5}, [4]float32{0, 1, 0, 0}
+ if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil {
+ t.Fatal(err)
+ }
+ expected := uint32(65536)
+ if id == 2 {
+ expected = 65537
+ }
+ if player.playfield != expected {
+ t.Fatal("keyed entry selected a different assignment", id, player.playfield)
+ }
+ world.clients[id], client.ready, client.loading = client, true, false
+ player.position, player.rotation = [3]float32{15, .011, 43}, [4]float32{0, 0, 0, 1}
+ player.movement = playerMovement{}
+ if err := world.savePosition_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ world.updateNPCInterest_locked(client, time.Now())
+ }
+ for _, output := range outputs {
+ output.packets = nil
+ }
+ return world, outputs
+}
+
+func TestMissionBoundariesInspectOnlyRepresentedActorsInTheSameWorld(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ client := world.clients[1]
+ client.npcs[2000006] = true // A stale interest entry must not bypass the world check.
+
+ for _, id := range []uint32{2, 2000006, 3, 2000001} {
+ if err := world.handleCharacterInfo(client, teamRequest(1, 105, id, 0)); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ if len(outputs[0].packets) != 2 || len(outputs[1].packets) != 0 || len(outputs[2].packets) != 0 ||
+ binary.BigEndian.Uint32(outputs[0].packets[0][24:28]) != 3 || binary.BigEndian.Uint32(outputs[0].packets[1][24:28]) != 2000001 ||
+ len(client.absorbedBonuses) != 2 {
+ t.Fatal("inspection crossed a runtime world or failed for its guest", outputs[0].packets, client.absorbedBonuses)
+ }
+ cold := reloadMissionEntranceWorld(t)
+ if cold.characters[1].playfield != 65536 || cold.characters[2].playfield != 65537 || cold.characters[3].playfield != 65536 {
+ t.Fatal("cold loading merged owner and guest worlds")
+ }
+}
+
+func TestMissionBoundariesNanosRejectForeignWorldAndRefundDepartedTargets(t *testing.T) {
+ for _, friendly := range []bool{false, true} {
+ t.Run(map[bool]string{false: "harmful", true: "friendly"}[friendly], func(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.profession, player.nano = 8, 100
+ player.stats.Body.NanoPool = 200
+ player.stats.NanoAiding.PsychologicalModification, player.stats.NanoAiding.MatterCreation = 7, 6
+ player.stats.NanoAiding.MatterMetamorphosis, player.stats.NanoAiding.BiologicalMetamorphosis = 39, 33
+ player.inventory.LearnedNanos = []uint32{29618, 27169}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ program, foreign, local := uint32(29618), uint32(2000006), uint32(2000001)
+ if friendly {
+ program, foreign, local = 27169, 2, 3
+ }
+ client.npcs[foreign] = true
+ before := world.characters[foreign].health
+
+ if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, foreign, 53019, program})[20:]); err != nil {
+ t.Fatal(err)
+ }
+
+ if client.nanoCast != nil || player.nano != 100 || player.nanoReserved != 0 || world.characters[foreign].health != before ||
+ len(world.characters[foreign].activeNanos) != 0 || len(outputs[1].packets) != 0 || len(outputs[2].packets) != 0 {
+ t.Fatal("foreign-world cast changed resources, effects or observer state")
+ }
+ if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, local, 53019, program})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.nanoCast == nil || player.nanoReserved == 0 {
+ t.Fatal("same-world cast was not admitted")
+ }
+ deadline := client.nanoCast.readyAt.Add(time.Nanosecond)
+ target := world.characters[local]
+ health := target.health
+ target.playfield = 65537
+ world.advanceNanos(deadline)
+ world.advanceNanos(deadline.Add(time.Second))
+ cold := reloadMissionEntranceWorld(t)
+ if client.nanoCast != nil || player.nano != 100 || player.nanoReserved != 0 || !player.nanoRechargeUntil.IsZero() ||
+ cold.characters[1].nano != 100 || cold.characters[1].nanoReserved != 0 || target.health != health || len(target.activeNanos) != 0 ||
+ len(outputs[1].packets) != 0 {
+ t.Fatal("departed cast target received an outcome or refund was not durable")
+ }
+ target.playfield = 65536
+ outputs[0].packets, outputs[2].packets = nil, nil
+ if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, local, 53019, program})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.nanoCast == nil {
+ t.Fatal("same-world retry was not admitted")
+ }
+ world.advanceNanos(client.nanoCast.readyAt.Add(time.Nanosecond))
+ if player.nano >= 100 || len(outputs[1].packets) != 0 || len(outputs[2].packets) == 0 ||
+ friendly && len(target.activeNanos) != 1 || !friendly && target.health >= 100 {
+ t.Fatal("clear same-world retry failed or broadcast into the other instance")
+ }
+ })
+ }
+}
+
+func TestMissionBoundariesTradeAdmissionAndDepartureConserveOwnership(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ playerTradeRequest(t, world, 1, 0, [2]uint32{50000, 2}, [2]uint32{})
+ after, err := readTestItemStore(world)
+
+ if err != nil || !bytes.Equal(before, after) || world.clients[1].trade != nil || world.clients[2].trade != nil ||
+ len(outputs[0].packets) != 0 || len(outputs[1].packets) != 0 || len(outputs[2].packets) != 0 {
+ t.Fatal("foreign-world trade changed ownership or opened a window", err)
+ }
+ playerTradeRequest(t, world, 1, 0, [2]uint32{50000, 3}, [2]uint32{})
+ playerTradeRequest(t, world, 1, 4, [2]uint32{50000, 1}, [2]uint32{104, 64})
+ playerTradeRequest(t, world, 1, 1, [2]uint32{}, [2]uint32{})
+ world.characters[3].playfield = 65537
+ playerTradeRequest(t, world, 3, 1, [2]uint32{}, [2]uint32{})
+ cold := reloadMissionEntranceWorld(t)
+ if world.clients[1].trade != nil || world.clients[3].trade != nil || len(outputs[1].packets) != 0 ||
+ !reflect.DeepEqual(cold.characters[1].inventory, world.characters[1].inventory) ||
+ !reflect.DeepEqual(cold.characters[3].inventory, world.characters[3].inventory) ||
+ world.characters[1].inventory.Items[0].ID != 1 || world.characters[1].inventory.Items[0].Slot != 64 || len(world.characters[3].inventory.Items) != 1 {
+ t.Fatal("late trade acceptance transferred an item across worlds or lost the restored axe")
+ }
+}
+
+func TestMissionBoundariesVicinityAndHistoryStayInsideTheRuntimeWorld(t *testing.T) {
+ for kind := range uint32(4) {
+ t.Run(fmt.Sprint(kind), func(t *testing.T) {
+ world, _ := newMissionBoundaryWorld(t)
+ world.chats = make(map[uint32]*chatClient)
+ outputs := [3]*combatTestConn{{}, {}, {}}
+ for _, id := range []uint32{1, 2, 3} {
+ world.chats[id] = &chatClient{id: id, conn: outputs[id-1]}
+ }
+
+ world.sendVicinity(world.clients[1], kind, "private mission message", nil)
+
+ if len(outputs[0].packets) != 2 || len(outputs[1].packets) != 0 || len(outputs[2].packets) != 2 ||
+ !bytes.Equal(outputs[0].packets[1], outputs[2].packets[1]) || binary.BigEndian.Uint16(outputs[0].packets[1]) != 34 {
+ t.Fatal("vicinity delivery crossed a runtime world or omitted its guest")
+ }
+ cold := reloadMissionEntranceWorld(t)
+ for _, id := range []uint32{1, 2, 3} {
+ history, err := cold.chatHistory_locked(id)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if id == 2 {
+ if len(history) != 0 {
+ t.Fatal("private vicinity history leaked after restart", history)
+ }
+ } else if len(history) != 1 || history[0].Playfield != 65536 || history[0].Message != "private mission message" {
+ t.Fatal("same-world chat history lost its exact runtime world", id, history)
+ }
+ }
+ })
+ }
+}
+
+func TestMissionBoundariesCombatAndLootCannotReachAnotherWorld(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ player, client, npc := world.characters[1], world.clients[1], world.characters[2000001]
+ client.npcs[2000006] = true
+ world.clients[2].npcs[npc.id] = true
+ world.combatRoll = func(uint32) uint32 { return 0 }
+
+ if err := world.handleCombat(client, attackPacket(1, 2000006)[20:]); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.fighting != 0 || world.characters[2000006].health != 100 || len(world.fighting) != 0 || len(outputs[1].packets) != 0 || len(outputs[2].packets) != 0 {
+ t.Fatal("forged known-actor attack crossed the runtime world")
+ }
+ npc.health = 1
+ if err := world.handleCombat(client, attackPacket(1, npc.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceCombat(player.nextAttack)
+ if npc.corpse == nil || npc.corpse.looter != 1 || len(npc.corpse.items) != 1 || player.experience != 100 || len(outputs[1].packets) != 0 || len(outputs[2].packets) == 0 {
+ t.Fatal("same-world kill did not isolate damage, rewards and corpse creation")
+ }
+ item := npc.corpse.items[0].ID
+ request := lootUseRequest(1)
+ binary.BigEndian.PutUint32(request[44:48], npc.id)
+ player.playfield = 65537
+ if err := world.handleLootUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+ if client.lootCorpse != 0 || npc.corpse.credits != 1 || len(npc.corpse.items) != 1 || player.inventory.Credits != 4 {
+ t.Fatal("entitled player collected a corpse from a different world")
+ }
+ player.playfield = 65536
+ binary.BigEndian.PutUint32(request[20:24], 2)
+ if err := world.handleLootUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+ if client.lootCorpse != npc.id || npc.corpse.credits != 0 || player.inventory.Credits != 5 {
+ t.Fatal("same-world corpse opening failed to collect its cash")
+ }
+ player.playfield = 65537
+ if err := world.handleInventory(client, lootTakeRequest()); err != nil {
+ t.Fatal(err)
+ }
+ if len(npc.corpse.items) != 1 || world.items[item].Template != 42640 {
+ t.Fatal("stale loot window transferred its item across worlds")
+ }
+ player.playfield = 65536
+ if err := world.handleInventory(client, lootTakeRequest()); err != nil {
+ t.Fatal(err)
+ }
+ cold := reloadMissionEntranceWorld(t)
+ if len(npc.corpse.items) != 0 || len(cold.characters[1].inventory.Items) != 3 || cold.characters[1].inventory.Items[2].ID != item ||
+ cold.characters[1].experience != 100 || cold.characters[1].inventory.Credits != 5 || cold.characters[2].experience != 0 ||
+ len(cold.characters[2].inventory.Items) != 1 || len(outputs[1].packets) != 0 {
+ t.Fatalf("same-world pickup: corpse=%v inventory=%v xp=%d cash=%d foreignXP=%d foreignItems=%v foreignPackets=%x", npc.corpse.items, cold.characters[1].inventory.Items, cold.characters[1].experience, cold.characters[1].inventory.Credits, cold.characters[2].experience, cold.characters[2].inventory.Items, outputs[1].packets)
+ }
+}
+
+func TestMissionBoundariesInterestMovementAndObjectivePickupIncludeOnlyGuests(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ first, second := world.characters[1].missions[0], world.characters[2].missions[0]
+ objective := first.objective
+ for _, id := range []uint32{1, 2, 3} {
+ local, foreign := uint32(2000001), uint32(2000006)
+ if id == 2 {
+ local, foreign = foreign, local
+ }
+ if !world.clients[id].npcs[local] || world.clients[id].npcs[foreign] {
+ t.Fatal("initial interest merged identical-coordinate populations", id, world.clients[id].npcs)
+ }
+ }
+
+ if err := world.handleMovement(world.clients[1], playerMovementRequest(world.characters[1], 9)); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleInventory(world.clients[2], worldPickupRequest(2, objective)); err != nil {
+ t.Fatal(err)
+ }
+
+ if len(outputs[2].packets) != 1 || binary.BigEndian.Uint32(outputs[2].packets[0][24:28]) != 1 ||
+ len(outputs[1].packets) != 1 || binary.BigEndian.Uint32(outputs[1].packets[0][29:33]) != 146 ||
+ world.worldItems[objective].mission != first.id || len(world.characters[2].inventory.Items) != 1 {
+ t.Fatal("movement or objective ownership crossed the world boundary")
+ }
+ for _, output := range outputs {
+ output.packets = nil
+ }
+ world.characters[3].position = world.worldItems[objective].position
+ if err := world.handleInventory(world.clients[3], worldPickupRequest(3, objective)); err != nil {
+ t.Fatal(err)
+ }
+ cold := reloadMissionEntranceWorld(t)
+ if len(outputs[0].packets) != 1 || binary.BigEndian.Uint32(outputs[0].packets[0][24:28]) != objective || len(outputs[1].packets) != 0 ||
+ len(outputs[2].packets) != 1 || len(cold.characters[3].inventory.Items) != 2 || cold.characters[3].inventory.Items[1].ID != objective ||
+ cold.worldItems[second.objective].mission != second.id || len(cold.worldItems) != 1 {
+ t.Fatal("guest pickup lost the exact objective or removed another world's item")
+ }
+}
+
+func TestMissionBoundariesGuestTradeTransfersTheSameInstanceOnce(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ playerTradeRequest(t, world, 1, 0, [2]uint32{50000, 3}, [2]uint32{})
+ playerTradeRequest(t, world, 1, 4, [2]uint32{50000, 1}, [2]uint32{104, 64})
+
+ playerTradeRequest(t, world, 1, 1, [2]uint32{}, [2]uint32{})
+ playerTradeRequest(t, world, 3, 1, [2]uint32{}, [2]uint32{})
+ playerTradeRequest(t, world, 3, 1, [2]uint32{}, [2]uint32{})
+ cold := reloadMissionEntranceWorld(t)
+
+ if world.clients[1].trade != nil || world.clients[3].trade != nil || len(outputs[1].packets) != 0 || len(cold.characters[1].inventory.Items) != 1 ||
+ cold.characters[1].inventory.Items[0].ID != 2 || len(cold.characters[3].inventory.Items) != 2 || cold.characters[3].inventory.Items[0].ID != 1 ||
+ cold.characters[3].inventory.Items[0].Slot != 65 || cold.characters[1].inventory.Credits != 4 || cold.characters[3].inventory.Credits != 5 {
+ t.Fatal("same-world guest trade lost an instance or repeated settlement", cold.characters[1].inventory, cold.characters[3].inventory)
+ }
+}
+
+func TestMissionBoundariesRetirementEvacuatesGuestsAndPreservesTheOtherWorld(t *testing.T) {
+ world, outputs := newMissionBoundaryWorld(t)
+ first, second := world.characters[1].missions[0], world.characters[2].missions[0]
+ otherItems := world.characters[2].inventory.Items
+
+ if err := world.handleMissionRemoval(world.clients[1], missionRemovalPacket(1, first.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ cold := reloadMissionEntranceWorld(t)
+
+ if cold.characters[1].playfield != 3000 || cold.characters[3].playfield != 3000 || cold.characters[2].playfield != 65537 ||
+ len(cold.characters[1].missions) != 0 || len(cold.characters[3].inventory.Items) != 0 || len(cold.characters[2].missions) != 1 ||
+ !reflect.DeepEqual(cold.characters[2].inventory.Items, otherItems) || cold.characters[2].inventory.Credits != 4 || len(outputs[1].packets) != 0 ||
+ len(cold.missionExpiry) != 1 || cold.missionExpiry[0].id != second.id || cold.missionExpiry[0].doors[0].id != 2 ||
+ len(cold.worldItems) != 1 || cold.worldItems[second.objective].mission != second.id ||
+ world.geometry.mission(65536) != nil || world.geometry.mission(65537) == nil {
+ t.Fatal("retirement revoked another assignment or a checkpoint restored the retired world")
+ }
+ for id := uint32(2000000); id < 2000010; id++ {
+ if id < 2000005 {
+ if world.characters[id] != nil || cold.characters[id] != nil {
+ t.Fatal("retired mission actor survived a checkpoint", id)
+ }
+ } else if cold.characters[id] == nil || cold.characters[id].health != 100 || cold.characters[id].playfield != 65537 {
+ t.Fatal("another world's original population changed", id)
+ }
+ }
+}