commit 22011eb232f6c59f9832e90684d19ec0bdd6a3f8
parent b730deb368981b2a58154f3ff2112f0f883de19c
Author: anon <anon@example.com>
Date: Thu, 5 Nov 2026 21:46:41 +0000
Explain unsupported shop purchases while preserving loot sales
Diffstat:
7 files changed, 290 insertions(+), 17 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -99,7 +99,7 @@ research separately. More screenshots and test cases do not count as new gamepla
- [ ] **A5: Useful, nonempty early shop stock.** Inventory every terminal in the
selected starter and basic shops for all three factions. Supported purchases
- exist, but unknown categories currently open without catalog rows. Supply
+ exist; unstocked categories now explain their purchase limitation on opening. Supply
a coherent early subset: usable weapons/armor, ammunition, health/nano recovery
and the profession essentials needed by offered starts. A clearly identified
unsupported specialty terminal is a scope limitation; a blank apparently
@@ -119,12 +119,12 @@ research separately. More screenshots and test cases do not count as new gamepla
Thirty-six crystal terminals now carry 19 original early nanos with complete
supported contracts; all 36 pass native buy/sell, cancel, upload/cast and
reconnect/cold recovery, with every row covered by server regressions.
- 123 placements remain empty. Meta-Physicist combat nanos and pet attacks,
+ 123 placements remain empty and visibly identify unsupported purchases while
+ retaining loot sales. Meta-Physicist combat nanos and pet attacks,
Engineer robots and other unfinished profession essentials remain open,
- alongside visible specialty-terminal limitations and ordinary-reward
- affordability. Funded fixtures do not establish affordability; the stock
- ledger also records unfinished weapon specials rather than claiming complete
- combat support from a successful ordinary attack.
+ alongside ordinary-reward affordability. Funded fixtures do not establish
+ affordability; the stock ledger also records unfinished weapon specials
+ rather than claiming complete combat support from a successful ordinary attack.
## P0: playable and releasable
diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md
@@ -33,8 +33,7 @@ and terminal price modifiers are preserved. Prices below precede skill discounts
One of each costs 655 credits at the Omni terminal and 686 at the Clan/Neutral
terminals. Controlled funded fixtures do not establish normal-play affordability;
-that acceptance check remains open, along with basic upgrades, profession
-essentials and visible identification of deferred specialty categories.
+that acceptance check remains open, along with profession essentials.
### Verification, November 5
@@ -169,8 +168,8 @@ subdirectories `c005049f`, `c026049c` and `c01204a2`. The three-shop run took
299.48 seconds. Logs are `local/alpha-rifle-smg/browser-final.log` and
`regressions.log`. `go vet ./server`, JavaScript syntax and diff checks also pass
(`vet.log`). Test servers and Chromium processes were closed. The remaining
-A5 work is profession essentials, visible unsupported-terminal limitations and
-ordinary-reward affordability; Aimed Shot/Burst are still explicit combat gaps.
+A5 work is profession essentials and ordinary-reward affordability;
+Aimed Shot/Burst are still explicit combat gaps.
## Basic nano crystals
@@ -252,8 +251,40 @@ Symbol Helper (29192 -> 29113) was considered for Meta-Physicist stock but rejec
its Psychological Modification/Sensory Improvement requirements exceed the
unbuffed level-ten checkpoint. It is crafting utility in any case, so stocking it
would not resolve the missing combat essentials. The three Meta-Physicist
-terminals remain empty pending useful supported content; their visible limitation
-labels are still part of A5's outstanding specialty/unsupported UI work.
+terminals remain empty pending useful supported content. The notice below
+identifies that limitation without closing the missing profession essentials.
+
+## Empty terminal feedback
+
+An admitted Use of an unstocked terminal now displays its original name followed
+by "Purchases are not yet supported in this alpha. You can still sell items here."
+This uses the native text-feedback channel. The shop remains available for loot
+sales at its original modifier. Normal access and range checks run before the
+notice; repeated sequence numbers do not repeat it. Supported catalogs have no
+limitation notice. Empty ShopUpdate packets remain omitted to avoid the native
+GM warning.
+
+`TestEarlyShopCatalogAvailabilityFeedback` covers all 190 scoped placements:
+123 empty terminals emit exactly one named notice, 67 stocked terminals emit
+their catalog without that notice, and replayed Use leaves both unchanged.
+The initial regression reproduced all 123 missing notices. Existing admission,
+sale cancellation, purchase and rejected-write/retry checks also pass.
+
+`TestBrowserShopAvailability` and `tools/client/test_shop_availability.mjs` visit
+the three empty Meta-Physicist terminals with real right-click/E input. Each
+shows the notice, cancels an offered item, sells it on retry, reconnects and
+reopens with the notice again. Exact cash and ownership survive cold recovery.
+Screenshots confirm the native notice is visible. This is UI and sale evidence,
+not support for missing Meta-Physicist purchases or combat.
+
+Passing browser artifacts are under `local/alpha-shop-availability/`:
+`20261105-134424/c013049f` (Omni), `20261105-134424/c014049c` (Clan), and
+`20261105-134541/c00904a2` (Neutral). The first Neutral reconnect reset the
+camera to third person and prevented the fixture from picking the terminal;
+restoring first person before opening passed. Logs are `browser.log`,
+`browser-neutral.log`, `regressions.log` and `vet.log`. Test processes were closed.
+No historical research or new stock is claimed; A5 remains open for profession
+essentials and ordinary-reward affordability.
## Placement census
diff --git a/server/browser_shop_availability_test.go b/server/browser_shop_availability_test.go
@@ -0,0 +1,82 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "math"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserShopAvailability(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for empty terminal feedback")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-shop-availability", time.Now().Format("20060102-150405"))
+ for _, id := range []uint32{0xc013049f, 0xc014049c, 0xc00904a2} {
+ t.Run(fmt.Sprintf("%x", id), func(t *testing.T) {
+ world := newTestServer(t)
+ machine := gamedata.ShopMachines[id]
+ player := world.newCharacter()
+ player.playfield, player.position = machine.Playfield, machine.Position
+ player.appearance = map[uint32]uint16{1183: 0x515, 1180: 0x315, 1186: 0x115}[machine.Playfield]
+ forward, _ := bodyAxes(machine.Rotation)
+ player.position[0] += 3 * forward[0]
+ player.position[2] += 3 * forward[2]
+ player.position[1] += .5
+ yaw := math.Atan2(float64(machine.Position[0]-player.position[0]), float64(machine.Position[2]-player.position[2]))
+ player.rotation = [4]float32{0, float32(math.Sin(yaw / 2)), 0, float32(math.Cos(yaw / 2))}
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("shop-availability")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, playerInventory{Credits: 100, LastID: 1, Items: []ownedItem{
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ }}); err != nil {
+ t.Fatal(err)
+ }
+ creditsAfterSale := uint32(584)
+ if machine.Playfield == 1183 {
+ creditsAfterSale = 705
+ }
+ 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()
+ open, sales := false, 0
+ if client := world.clients[1]; client != nil && client.shop != nil {
+ open, sales = true, len(client.shop.items)
+ }
+ json.NewEncoder(w).Encode(map[string]any{"machine": id, "name": gamedata.ItemTemplates[machine.Template].Name,
+ "creditsAfterSale": creditsAfterSale, "open": open, "sales": sales, "inventory": player.inventory})
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_shop_availability.mjs"), host.URL, filepath.Join(output, fmt.Sprintf("%x", id)))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ if err := command.Run(); err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("Browser artifacts: %s", filepath.Join(output, fmt.Sprintf("%x", id)))
+ cold := newTestInventoryServer(t).characters[1].inventory
+ if cold.Credits != creditsAfterSale || cold.LastID != 1 || len(cold.Items) != 0 {
+ t.Fatal("empty terminal sale changed during cold recovery", cold)
+ }
+ })
+ }
+}
diff --git a/server/shop_availability_test.go b/server/shop_availability_test.go
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "maps"
+ "reflect"
+ "slices"
+ "testing"
+)
+
+func TestEarlyShopCatalogAvailabilityFeedback(t *testing.T) {
+ world, conn := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ before := player.inventory
+ visited, empty := 0, 0
+ for _, id := range slices.Sorted(maps.Keys(gamedata.ShopMachines)) {
+ machine := gamedata.ShopMachines[id]
+ appearance, selected := map[uint32]uint16{950: 0x515, 952: 0x315, 954: 0x115, 1180: 0x315, 1183: 0x515, 1186: 0x115}[machine.Playfield]
+ if !selected {
+ continue
+ }
+ visited++
+ t.Run(fmt.Sprintf("%x", id), func(t *testing.T) {
+ player.playfield, player.position, player.appearance = machine.Playfield, machine.Position, appearance
+ request := shopUseRequest(uint32(visited))
+ binary.BigEndian.PutUint32(request[44:48], id)
+ conn.packets = nil
+
+ if err := world.handleShopUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if client.shop == nil || client.shop.machine != id || !reflect.DeepEqual(player.inventory, before) {
+ t.Fatal("browsing failed or changed ownership/cash")
+ }
+ messages, catalogs := 0, 0
+ for _, packet := range conn.packets {
+ switch binary.BigEndian.Uint32(packet[16:20]) {
+ case 0x5f4b442a:
+ messages++
+ text := gamedata.ItemTemplates[machine.Template].Name + ": Purchases are not yet supported in this alpha. You can still sell items here."
+ if binary.BigEndian.Uint32(packet[29:33]) != uint32(len(text)) || !bytes.Equal(packet[33:35+len(text)], append([]byte(text), 0, 0)) {
+ t.Fatalf("wrong terminal limitation: %x", packet)
+ }
+ case 0x58362220:
+ catalogs++
+ }
+ }
+ if len(gamedata.ShopStock[machine.Template]) == 0 {
+ empty++
+ if messages != 1 || catalogs != 0 {
+ t.Fatal("empty terminal lacks one explicit limitation or publishes an empty catalog")
+ }
+ } else if messages != 0 || catalogs != 1 {
+ t.Fatal("supported catalog is missing or incorrectly labelled unsupported")
+ }
+
+ // Replayed Use must not repeat the notice or reopen the transaction.
+ conn.packets = nil
+ if err := world.handleShopUse(client, request); err != nil || len(conn.packets) != 0 {
+ t.Fatal("replayed Use repeated feedback", err)
+ }
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 2, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ })
+ }
+ if visited != 190 || empty != 123 {
+ t.Fatalf("finite terminal inventory changed: visited %d, empty %d", visited, empty)
+ }
+}
diff --git a/server/shop_machines_test.go b/server/shop_machines_test.go
@@ -58,12 +58,8 @@ func TestShopUseEvaluatesAuthoredAccessContracts(t *testing.T) {
t.Fatalf("shop admission = %v, want %v", client.shop != nil, scenario.accepted)
}
if scenario.accepted {
- packets := 4
- if scenario.machine == 3221685407 || scenario.machine == 3221226655 {
- packets = 5
- }
start := conn.packets[len(conn.packets)-1]
- if len(conn.packets) != packets || client.shop.machine != scenario.machine || binary.BigEndian.Uint32(start[41:45]) != scenario.machine ||
+ if len(conn.packets) != 5 || client.shop.machine != scenario.machine || binary.BigEndian.Uint32(start[41:45]) != scenario.machine ||
binary.BigEndian.Uint32(start[45:49]) != 111 || binary.BigEndian.Uint32(start[49:53]) != 0 {
t.Fatal("opened the wrong shop contract")
}
diff --git a/server/shops.go b/server/shops.go
@@ -116,6 +116,16 @@ func (server *server) startShop_locked(client *worldClient, machineID uint32, ma
}
}
client.shop = &shopTrade{machine: machineID, items: make(map[uint32]ownedItem), stock: gamedata.ShopStock[machine.Template], purchases: make(map[uint32]uint16)}
+ // Explain missing purchase stock while keeping the terminal available for sales.
+ if len(client.shop.stock) == 0 {
+ text := gamedata.ItemTemplates[machine.Template].Name + ": Purchases are not yet supported in this alpha. You can still sell items here."
+ feedback := binary.BigEndian.AppendUint32(nil, uint32(len(text)))
+ feedback = append(feedback, text...)
+ feedback = append(feedback, 0, 0)
+ if err := client.send(n3Packet(0x5f4b442a, 50000, client.id, feedback)); err != nil {
+ return err
+ }
+ }
if err := client.send(shopMachinePacket(machineID, machine)); err != nil {
return err
}
diff --git a/tools/client/test_shop_availability.mjs b/tools/client/test_shop_availability.mjs
@@ -0,0 +1,80 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'shop-availability', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const waitServer = (label, predicate) => game.waitFor(label, async () => predicate(await server()));
+ const shopVisible = state => state.regions.some(([left, top, right, bottom]) =>
+ left === 832 && top === 0 && right === 1024 && bottom === 494);
+ await page.goto(url);
+ await game.ready();
+ await game.key('KeyI');
+ const initial = evidence.initial = await server();
+ const open = async keyboard => {
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ const sequence = game.sequence;
+ await game.click(...await game.pick(51035, initial.machine), keyboard ? 'left' : 'right');
+ if (keyboard) await game.key('KeyE');
+ await game.wait('empty shop opens with an explicit purchase limitation', state => shopVisible(state) &&
+ game.events.some(event => event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '5f4b442a'));
+ const messages = game.events.filter(event => event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '5f4b442a');
+ assert.equal(messages.length, 1);
+ const packet = Buffer.from(messages[0].hex, 'hex');
+ assert.equal(packet.subarray(33, 33 + packet.readUInt32BE(29)).toString(),
+ initial.name + ': Purchases are not yet supported in this alpha. You can still sell items here.');
+ assert(!game.state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 111 && !cell.dummy)));
+ await waitServer('server retains the sale transaction', state => state.open);
+ };
+ const offer = async () => {
+ const cell = game.state.grids.flatMap(grid => grid.cells).find(cell => cell.identity[0] === 104 && cell.identity[1] === 48);
+ assert(cell, 'owned sale item is present');
+ await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2);
+ await game.wait('sale item picked', state => state.dragged[0] === 104);
+ await game.click(860, 412);
+ await waitServer('sale item offered', state => state.sales === 1);
+ };
+ await open(false);
+ await game.save(output + '/limitation');
+ await offer();
+ await game.click(945, 475);
+ await waitServer('cancel restores ownership', state => !state.open);
+ await game.wait('cancel closes native shop', state => !shopVisible(state));
+ assert.deepEqual((await server()).inventory, initial.inventory);
+ await open(true);
+ await offer();
+ await game.click(873, 475);
+ await waitServer('sale committed once', state => !state.open && state.inventory.Items.length === 0);
+ evidence.sold = await server();
+ assert.equal(evidence.sold.inventory.Credits, initial.creditsAfterSale);
+ await game.wait('native cash agrees with sale', state => game.local(state).stats[61] === initial.creditsAfterSale);
+ await page.reload();
+ await game.ready();
+ evidence.reconnected = await server();
+ assert.deepEqual(evidence.reconnected.inventory, evidence.sold.inventory);
+ assert.equal(game.local().stats[61], initial.creditsAfterSale);
+ await open(false);
+ await game.save(output + '/reconnected-limitation');
+ await game.click(945, 475);
+ await waitServer('final cancellation completed', state => !state.open);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS:', initial.machine, 'visible purchase limitation, sell/cancel/retry and reconnect');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}