commit 69598c002ee87557a6edd7a341f3a26852dc0d63
parent a8ffb139b3026b044c4ee7d3f9022605754aed90
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 02:29:54 +0000
Preserve live mission key names through bank snapshots
Diffstat:
6 files changed, 132 insertions(+), 8 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -2473,8 +2473,10 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md).
progression. Tools placement follows the later wiki; original per-terminal
stock remains unrecovered. The original generic SimpleItem custom-name route
now displays two distinct controlled live-key names in native tooltips/info;
- its missing carried-slot translation is fixed. Production destination labels
- and their bank/trade/reclaim/reconnect behavior remain unimplemented.
+ its missing carried-slot translation is fixed. A controlled named key now
+ retains its live name through bank reopening and withdrawal, with ordinary
+ uninstantiated keys still usable. Production destination labels and their
+ trade/reclaim/reconnect behavior remain unimplemented.
See [mission keys](docs/mission-keys.md).
Cover held, banked, traded, deleted and reclaimed keys; possession
of an unrelated template28577 must never admit a player to another mission.
diff --git a/docs/mission-keys.md b/docs/mission-keys.md
@@ -109,7 +109,34 @@ test labels are not recovered historical destination wording or mission bindings
Captures and protocol verification are in `local/mission-key-name/`.
Production keys and copies still display the base name. Destination publication,
-historical label wording and live-item bank/trade/reclaim/reconnect behavior
-remain open. The original activation ignores already-existing dynels, so fresh
-creation alone cannot prove those lifetime paths. Historical key retention after
+historical label wording and live-item trade/reclaim/reconnect behavior remain
+open. The original activation ignores already-existing dynels, so fresh creation
+alone cannot prove those lifetime paths. Historical key retention after
completion/abandonment remains separately unresolved.
+
+### Bank identity rows
+
+Reopening the native bank rebuilt a named Mission Key as a template proxy:
+`Destination A` disappeared both in the bank and after withdrawal. The bank
+snapshot now uses flag2 for the exact type51053/template28577 key, retaining
+its physical identity and live name. Other ordinary rows keep flag3.
+
+Original name resolver `0x1005e3c0` selects the live object's name virtual when
+the row permits it and that object exists. It otherwise falls back to the
+template dummy. Thus a key without an instantiated name remains usable with
+its normal template name. This is retained evidence
+`ev_419217e366aa4db03b3b2a17ae953a8ebd65fd7f01f54fd4aff8955f5f6e11c7`
+in `local/mission-key-metadata/kkr-evidence.json`.
+
+The expanded `TestBrowserMissionKeyNameRoute` first deposits, reopens and
+withdraws an uninstantiated ordinary key. It then applies the two controlled
+labels and repeats that same key's bank round trip without another FullUpdate.
+The bank and withdrawn information windows retain `Destination A`, while the
+second instance keeps its own label. Exact IDs, slots and zero cash survive
+cold loading. The separate public bank-Use regression protects both row flags,
+unchanged ownership/allocation and zero writes on opening.
+
+The before/after captures are `local/mission-key-name/20261103-182253/` and
+`20261103-182555/`; the corrected check takes17 seconds. The bank fixture position
+and labels are controlled. This does not establish historical destination
+wording or name publication on cold reconnect.
diff --git a/server/bank.go b/server/bank.go
@@ -42,7 +42,7 @@ func bankInventoryPacket(player *character) []byte {
body = binary.BigEndian.AppendUint32(body, uint32(len(player.inventory.Bank)+1)*1009)
for _, item := range player.inventory.Bank {
flags := uint32(3)
- if item.isPortableContainer() {
+ if item.isPortableContainer() || item.Type == 51053 && item.Template == 28577 {
flags = 2
}
low, high := item.templateIDs()
diff --git a/server/bank_mission_key_test.go b/server/bank_mission_key_test.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "slices"
+ "testing"
+)
+
+func TestBankMissionKeySnapshotUsesLiveIdentityWithoutWrites(t *testing.T) {
+ world, conn := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.playfield, player.position = 705, [3]float32{985, 20.2001, 580}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := player.inventory
+ inventory.LastID = 3
+ inventory.Bank = []ownedItem{{ID: 2, Type: 51053, Template: 28577, Quality: 1, Slot: 0, Count: 1},
+ {ID: 3, Type: 51005, Template: 42640, Quality: 1, Slot: 1, Count: 1}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ auditCheckpointWrites(t, world)
+ conn.packets = nil
+
+ if err := world.handleTerminalUse(client, bankUseRequest(1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ after, err := readTestItemStore(world)
+ cold := newTestInventoryServer(t)
+
+ if err != nil || !bytes.Equal(before, after) || len(checkpointWrites(t, world)) != 0 ||
+ !slices.Equal(player.inventory.Bank, inventory.Bank) || !slices.Equal(cold.characters[1].inventory.Bank, inventory.Bank) ||
+ world.nextItem != 3 || cold.nextItem != 3 || len(conn.packets) != 2 {
+ t.Fatal("opening bank changed key ownership, allocation or unrelated rows", err)
+ }
+ packet := conn.packets[1]
+ if binary.BigEndian.Uint32(packet[16:20]) != 0x343c287f ||
+ binary.BigEndian.Uint32(packet[49:53]) != 0x00020001 || binary.BigEndian.Uint32(packet[57:61]) != 2 ||
+ binary.BigEndian.Uint32(packet[81:85]) != 0x00030001 || binary.BigEndian.Uint32(packet[89:93]) != 3 {
+ t.Fatalf("bank snapshot lost key identity routing or changed the ordinary row: %x", packet)
+ }
+}
diff --git a/server/browser_mission_key_name_test.go b/server/browser_mission_key_name_test.go
@@ -1,9 +1,11 @@
package main
import (
+ "cmp"
"context"
"crypto/sha256"
"encoding/binary"
+ "encoding/json"
"fmt"
"net/http"
"net/http/httptest"
@@ -25,6 +27,9 @@ func TestBrowserMissionKeyNameRoute(t *testing.T) {
output := filepath.Join(root, "local/mission-key-name", time.Now().Format("20060102-150405"))
world := newTestServer(t)
player := world.newCharacter()
+ // Controlled bank position isolates live-item transfer from earned travel.
+ player.playfield, player.position = 1183, [3]float32{193.79826, 5.01, 136.83983}
+ player.rotation = [4]float32{0, .70710677, 0, .70710677}
player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("mission-key-name")))
if err := world.saveUser_locked(player); err != nil {
t.Fatal(err)
@@ -36,6 +41,11 @@ func TestBrowserMissionKeyNameRoute(t *testing.T) {
}
mux := http.NewServeMux()
mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ json.NewEncoder(w).Encode(player.inventory)
+ })
mux.HandleFunc("POST /test-name", func(w http.ResponseWriter, r *http.Request) {
world.updateMutex.Lock()
defer world.updateMutex.Unlock()
@@ -75,9 +85,11 @@ func TestBrowserMissionKeyNameRoute(t *testing.T) {
t.Fatal(err)
}
cold := newTestInventoryServer(t)
+ items := slices.Clone(player.inventory.Items)
+ slices.SortFunc(items, func(a, b ownedItem) int { return cmp.Compare(a.ID, b.ID) })
expected := []ownedItem{{ID: 1, Type: 51053, Template: 28577, Quality: 1, Slot: 64, Count: 1},
{ID: 2, Type: 51053, Template: 28577, Quality: 1, Slot: 65, Count: 1}}
- if !slices.Equal(player.inventory.Items, expected) || !slices.Equal(cold.characters[1].inventory.Items, expected) ||
+ if !slices.Equal(items, expected) || !slices.Equal(cold.characters[1].inventory.Items, expected) ||
world.nextItem != 2 || cold.nextItem != 2 || player.inventory.Credits != 0 || cold.characters[1].inventory.Credits != 0 {
t.Fatal("native name updates changed durable ownership or allocation")
}
diff --git a/tools/client/test_mission_key_name.mjs b/tools/client/test_mission_key_name.mjs
@@ -13,12 +13,44 @@ try {
await context.addCookies([{name: 'ao_client', value: 'mission-key-name', url}]);
const page = await context.newPage();
game = await GameTest.attach(page);
+ const openBank = async () => {
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.click(...await game.pick(51005, 3221357727), 'right');
+ await game.wait('bank opens', state => state.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ };
+ const roundTrip = async phase => {
+ await openBank();
+ await game.click(681, 45);
+ await game.click(30, 45);
+ await game.wait('exact key banked', state => !game.local(state).inventory.some(item => item.id === 1));
+ assert.deepEqual((await (await page.request.get(url + '/test-state')).json()).Bank.map(item => [item.ID, item.Slot]), [[1, 0]]);
+ await game.click(170, 8);
+ await game.wait('bank closes', state => !state.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ await openBank();
+ await page.keyboard.down('Shift');
+ try { await game.click(30, 45); }
+ finally { await page.keyboard.up('Shift'); }
+ await game.save(output + '/bank-info-' + phase);
+ await game.click(30, 45);
+ await game.wait('same key withdrawn', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === 48));
+ await page.keyboard.down('Shift');
+ try { await game.click(681, 45); }
+ finally { await page.keyboard.up('Shift'); }
+ await game.save(output + '/withdrawn-info-' + phase);
+ await game.click(170, 8);
+ await game.wait('bank closes after withdrawal', state => !state.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ };
await page.goto(url);
await game.ready();
await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
await game.snapshot();
await game.key('KeyI');
await game.save(output + '/before');
+ // Flag2 must also permit ordinary keys without an instantiated custom name.
+ await roundTrip('unnamed');
assert((await page.request.post(url + '/test-name')).ok());
await game.wait('both named keys attached to real instances', state =>
game.events.filter(event => event.direction === 'framereceived' && event.opcode === '3b11256f').length === 2 &&
@@ -37,8 +69,11 @@ try {
await game.save(output + '/info-' + slot);
await game.key('Escape');
}
+
+ // Reopening must retain the live name without another FullUpdate.
+ await roundTrip('named');
assert.deepEqual(game.errors, []);
- console.log('PASS: generic SimpleItem updates attach both named key identities; inspect native info screenshots');
+ console.log('PASS: distinct native key names, unnamed/named bank round trips and exact cold ownership');
} finally {
try { if (game) await game.save(output + '/final'); }
finally { await browser.close(); }