aorecomp

Anarchy Online classic in the browser

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


commit 2968704262876d0ab7e9324eeabd83a9a9b7ae51
parent fe77707285357ba37c3164117dc3d5132bcb2b76
Author: anon <anon@example.com>
Date:   Sun,  8 Nov 2026 02:12:29 +0000

Render admin page properties as key-value tables

Diffstat:
Mserver/admin_player_password_test.go | 4++--
Mserver/control.go | 2+-
Mserver/control_inventory_test.go | 2+-
Mserver/item_admin_snapshot_test.go | 2+-
Mserver/item_catalog.go | 9++++++---
Mserver/item_catalog_test.go | 6+++---
Mserver/item_pages.go | 18++++++++++++------
Mserver/item_source_pages.go | 11+++++------
8 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/server/admin_player_password_test.go b/server/admin_player_password_test.go @@ -36,7 +36,7 @@ func TestAdminChangesPlayerPasswordWithoutDisconnecting(t *testing.T) { if unauthorized.Code != http.StatusUnauthorized || changed.Code != http.StatusSeeOther || changed.Header().Get("Location") != "/admin/players/1?password=saved" { t.Fatal(unauthorized.Code, changed.Code, changed.Body) } - if profile.Code != 200 || !strings.Contains(profile.Body.String(), "<p>Player ID: 1</p><p>Connected: Yes</p><p>Account: Adopted</p>") || + if profile.Code != 200 || !strings.Contains(profile.Body.String(), "<th scope='row'>Player ID</th><td>1</td></tr><tr><th scope='row'>Connected</th><td>Yes</td></tr><tr><th scope='row'>Account</th><td>Adopted</td>") || !strings.Contains(profile.Body.String(), "<p><a href='admin/players/1/teleport'>Teleport</a></p><p><a href='admin/players/1/password'>Change password</a></p>") { t.Fatal("adopted profile did not separate its details and actions", profile.Code, profile.Body) } @@ -68,7 +68,7 @@ func TestAdminCannotSetVisitorPassword(t *testing.T) { changed := adminRequest(handler, "POST", "/admin/players/1/password", "password=secret", cookie) blank := adminRequest(handler, "POST", "/admin/players/1/password", "password=", cookie) - if profile.Code != 200 || !strings.Contains(profile.Body.String(), "<p>Player ID: 1</p><p>Connected: No</p><p>Account: Unadopted visitor</p>") || + if profile.Code != 200 || !strings.Contains(profile.Body.String(), "<th scope='row'>Player ID</th><td>1</td></tr><tr><th scope='row'>Connected</th><td>No</td></tr><tr><th scope='row'>Account</th><td>Unadopted visitor</td>") || strings.Contains(profile.Body.String(), "Change password") { t.Fatal("visitor profile offered account changes or hid its status", profile.Code, profile.Body) } diff --git a/server/control.go b/server/control.go @@ -56,7 +56,7 @@ func (server *server) userPage(w http.ResponseWriter, r *http.Request) { if connected { connection = "Yes" } - fmt.Fprintf(w, "<h1>%s</h1><p>Player ID: %d</p><p>Connected: %s</p><p>Account: %s</p>", html.EscapeString(data.Name), data.ID, connection, account) + fmt.Fprintf(w, "<h1>%s</h1><table><tr><th scope='row'>Player ID</th><td>%d</td></tr><tr><th scope='row'>Connected</th><td>%s</td></tr><tr><th scope='row'>Account</th><td>%s</td></tr></table>", html.EscapeString(data.Name), data.ID, connection, account) fmt.Fprintf(w, "<p><a href='admin/players/%d/teleport'>Teleport</a></p>", data.ID) if adopted { fmt.Fprintf(w, "<p><a href='admin/players/%d/password'>Change password</a></p>", data.ID) diff --git a/server/control_inventory_test.go b/server/control_inventory_test.go @@ -120,7 +120,7 @@ func TestControlEquipmentClearUnassignsWithoutLosingItems(t *testing.T) { } page := httptest.NewRecorder() adminTestHandler(restarted).ServeHTTP(page, httptest.NewRequest("GET", "/admin/items/2", nil)) - if !strings.Contains(page.Body.String(), "<p>Unassigned.") || len(restarted.characters[1].inventory.Containers[3]) != 1 { + if !strings.Contains(page.Body.String(), "<th scope='row'>Owner</th><td>Unassigned</td>") || len(restarted.characters[1].inventory.Containers[3]) != 1 { t.Fatal("cleared armor remained assigned or backpack contents changed") } } diff --git a/server/item_admin_snapshot_test.go b/server/item_admin_snapshot_test.go @@ -92,7 +92,7 @@ func TestRoutedAdminItemCreationRollsBackWithoutPublishingAnInstance(t *testing. t.Fatal("retry did not reserve a fresh identity", created.Code, created.Header(), created.Body.String()) } page := adminRequest(handler, "GET", "/admin/items/3?owner=1", "", nil) - if page.Code != http.StatusOK || !strings.Contains(page.Body.String(), "<p>Unassigned.") || !strings.Contains(page.Body.String(), "Small Backpack") || !strings.Contains(page.Body.String(), "slot_21") { + if page.Code != http.StatusOK || !strings.Contains(page.Body.String(), "<th scope='row'>Owner</th><td>Unassigned</td>") || !strings.Contains(page.Body.String(), "Small Backpack") || !strings.Contains(page.Body.String(), "slot_21") { t.Fatal("committed unassigned item was not readable", page.Code, page.Body.String()) } var template, placements uint32 diff --git a/server/item_catalog.go b/server/item_catalog.go @@ -10,17 +10,20 @@ import ( func itemCatalogProperties(w io.Writer, item ownedItem, definition *gamedata.Item) { fmt.Fprint(w, "<h2>Catalog properties</h2>") - fmt.Fprintf(w, "<p>Template %d (QL %d). Native object type: %d. Resource type: %d.</p>", definition.ID, *definition.Quality, definition.HeaderWords[0], definition.RecordType) - fmt.Fprint(w, "<p>Attributes below use the instance's quality. Price is the base value before vendor and Computer Literacy modifiers; it does not establish shop stock or monster drops.</p>") + fmt.Fprintf(w, "<table><tr><th scope='row'>Template</th><td>%d</td></tr><tr><th scope='row'>Template QL</th><td>%d</td></tr><tr><th scope='row'>Attribute QL</th><td>%d</td></tr><tr><th scope='row'>Native object type</th><td>%d</td></tr><tr><th scope='row'>Resource type</th><td>%d</td></tr>", definition.ID, *definition.Quality, item.Quality, definition.HeaderWords[0], definition.RecordType) if item.templateStat(0)&0x04000000 != 0 { - fmt.Fprint(w, "<p>This item is NoDrop and cannot be sold to a shop.</p>") + fmt.Fprint(w, "<tr><th scope='row'>Shop sale</th><td>Not allowed (NoDrop)</td></tr>") } + fmt.Fprint(w, "</table>") fmt.Fprintf(w, "<table><tr><th>Field</th><th>ID</th><th>Value at QL %d</th><th>Meaning</th></tr>", item.Quality) for _, stat := range definition.Stats { name := gamedata.ItemStatNames[stat[0]] if name == "" { name = "Unknown attribute" } + if stat[0] == 74 { + name = "Base price (unmodified)" + } value := item.templateStat(stat[0]) fmt.Fprintf(w, "<tr><td>%s</td><td>%d</td><td>%d</td><td>%s</td></tr>", html.EscapeString(name), stat[0], value, html.EscapeString(itemCatalogStatMeaning(item, stat[0], value))) } diff --git a/server/item_catalog_test.go b/server/item_catalog_test.go @@ -28,12 +28,12 @@ func TestControlItemCatalogDecodesBrontoMeat(t *testing.T) { t.Fatal(response.Code, response.Body.String()) } for _, expected := range []string{ - "<td>price</td><td>74</td><td>200</td>", + "<td>Base price (unmodified)</td><td>74</td><td>200</td>", "<td>volume_mass</td><td>2</td><td>200</td>", "<td>flags</td><td>0</td><td>2214593057</td>", "Visible, HasMultiplecount, TellCollision, NoDrop, DisableStatelCollision", "<td>can</td><td>30</td><td>1</td><td>Carry</td>", - "This item is NoDrop and cannot be sold to a shop.", + "<th scope='row'>Shop sale</th><td>Not allowed (NoDrop)</td>", "<summary>Source catalog record</summary>", "- [price, 200]", } { @@ -61,7 +61,7 @@ func TestControlItemCatalogUsesInstanceQuality(t *testing.T) { if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), "<th>Value at QL 5</th>") || - !strings.Contains(response.Body.String(), "<td>price</td><td>74</td><td>346</td>") || + !strings.Contains(response.Body.String(), "<td>Base price (unmodified)</td><td>74</td><td>346</td>") || !strings.Contains(response.Body.String(), "<td>level</td><td>54</td><td>5</td>") || !strings.Contains(response.Body.String(), "<td>placement</td><td>298</td><td>256</td><td>clothes_hands</td>") || !strings.Contains(response.Body.String(), "<td>default_pos</td><td>88</td><td>8</td><td>clothes_hands</td>") { diff --git a/server/item_pages.go b/server/item_pages.go @@ -169,7 +169,7 @@ func (server *server) itemCatalogPage(w http.ResponseWriter, r *http.Request) { } fmt.Fprintf(w, "<option value='%s'%s>%s</option>", option.value, selected, option.label) } - fmt.Fprint(w, "</select></label> <button>Filter</button> <a href='admin/items/catalog'>Clear filter</a></form><p>Sources cover the item's quality-level family. Open an item to see available qualities and locations. No known source means no mapped acquisition path in the current server data.</p>") + fmt.Fprint(w, "</select></label> <button>Filter</button> <a href='admin/items/catalog'>Clear filter</a></form>") start, end := itemPagination(w, r, len(matches)) fmt.Fprint(w, "<form method='post' action='admin/items'><table><tr><th>Name</th><th>Template</th><th>QL</th><th>Sources (family)</th><th></th></tr>") for _, definition := range matches[start:end] { @@ -255,19 +255,25 @@ func (server *server) itemPage(w http.ResponseWriter, r *http.Request) { server.adminPageStart(w, fmt.Sprintf("Item %d", id), "Items") fmt.Fprintf(w, "<h1>Item %d</h1>", id) if definition != nil { - fmt.Fprintf(w, "<h2>%s</h2><p><strong>Description:</strong> %s</p>", itemIcon(definition)+html.EscapeString(definition.Name), html.EscapeString(definition.Description)) + fmt.Fprintf(w, "<h2>%s</h2>", itemIcon(definition)+html.EscapeString(definition.Name)) } + fmt.Fprint(w, "<table>") + if definition != nil { + fmt.Fprintf(w, "<tr><th scope='row'>Description</th><td>%s</td></tr>", html.EscapeString(definition.Description)) + } + fmt.Fprint(w, "<tr><th scope='row'>Owner</th><td>") if location.owner != 0 { - fmt.Fprintf(w, "<p>Owner: <a href='admin/players/%d'>%s (%d)</a>. ", location.owner, html.EscapeString(ownerName), location.owner) + fmt.Fprintf(w, "<a href='admin/players/%d'>%s (%d)</a>", location.owner, html.EscapeString(ownerName), location.owner) } else { - fmt.Fprint(w, "<p>Unassigned. ") + fmt.Fprint(w, "Unassigned") } + fmt.Fprint(w, "</td></tr><tr><th scope='row'>Location</th><td>") if location.container != 0 { fmt.Fprintf(w, "<a href='admin/items/%d'>%s</a>", location.container, html.EscapeString(location.label)) } else { fmt.Fprint(w, html.EscapeString(location.label)) } - fmt.Fprintf(w, "</p><p><a href='admin/items/catalog/%d'>View catalog and acquisition sources</a></p>", record.Template) + fmt.Fprintf(w, "</td></tr><tr><th scope='row'>Catalog</th><td><a href='admin/items/catalog/%d'>Catalog and acquisition sources</a></td></tr></table>", record.Template) if location.label == "" { fmt.Fprintf(w, "<h2>Assign item</h2><form method='get' action='admin/items/%d'><label>Player <select name='owner' required>", id) for _, id := range slices.Sorted(maps.Keys(snapshot.names)) { @@ -300,7 +306,7 @@ func (server *server) itemPage(w http.ResponseWriter, r *http.Request) { } item := ownedItem{Type: record.Type, Template: record.Template, Quality: record.Quality} itemCatalogProperties(w, item, definition) - fmt.Fprintf(w, "<details><summary>Source catalog record</summary><p>Header words contain the native object type, inferred block count and attribute block tags. Text header contains the text block tags. Hash and file offset identify the original payload. Sections retain their original encoding.</p><textarea rows='25' cols='80' readonly>%s</textarea></details>", html.EscapeString(string(catalog))) + fmt.Fprintf(w, "<details><summary>Source catalog record</summary><textarea rows='25' cols='80' readonly>%s</textarea></details>", html.EscapeString(string(catalog))) } fmt.Fprint(w, "</main></body></html>") } diff --git a/server/item_source_pages.go b/server/item_source_pages.go @@ -37,7 +37,7 @@ func sourceMap(w http.ResponseWriter, sources []itemSource) { if err != nil { panic(err) } - fmt.Fprint(w, "<section><h2>Acquisition locations</h2><p>Green markers show possible sources. NPC markers use their spawn positions. Interior locations appear in their own playfield view.</p><label>Source location <select data-map-source>") + fmt.Fprint(w, "<section><h2>Acquisition locations</h2><label>Source location <select data-map-source>") for index, location := range locations { fmt.Fprintf(w, "<option value='%d'>%s - %s (%d), X %.1f Z %.1f</option>", index, html.EscapeString(location.Name), html.EscapeString(gamedata.Playfields[location.Playfield].Name), location.Playfield, location.Position[0], location.Position[2]) } @@ -55,10 +55,9 @@ func (server *server) itemTemplatePage(w http.ResponseWriter, r *http.Request) { } sources := itemSources()[itemFamily(definition.ID)] server.adminPageStart(w, definition.Name, "Items") - fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s%s</h1><p><strong>Description:</strong> %s</p><p>Template %d, QL %d. %s.</p>", itemIcon(definition), html.EscapeString(definition.Name), html.EscapeString(definition.Description), definition.ID, *definition.Quality, html.EscapeString(itemSourceSummary(sources))) - fmt.Fprint(w, "<p>Sources below cover this item's quality-level family; only the listed QLs are offered. Shop rows describe possible stock, not guaranteed current availability. No known source is a gap in the current server mappings, not proof that the item is impossible to obtain.</p>") + fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s%s</h1><table><tr><th scope='row'>Description</th><td>%s</td></tr><tr><th scope='row'>Mapped sources (QL family)</th><td>%s</td></tr></table>", itemIcon(definition), html.EscapeString(definition.Name), html.EscapeString(definition.Description), html.EscapeString(itemSourceSummary(sources))) sourceMap(w, sources) - fmt.Fprint(w, "<h2>Sources</h2><table><tr><th>Type</th><th>Source</th><th>QL</th><th>Details</th></tr>") + fmt.Fprint(w, "<h2>Possible sources (QL family)</h2><table><tr><th>Type</th><th>Source</th><th>Offered QL</th><th>Details</th></tr>") for _, source := range sources { name := html.EscapeString(source.name) if source.shop != 0 { @@ -148,8 +147,8 @@ func (server *server) shopCatalogPage(w http.ResponseWriter, r *http.Request) { } definition := gamedata.ItemTemplates[uint32(template)] server.adminPageStart(w, definition.Name, "Items") - fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s</h1><p>Shop template %d. %s.</p>", itemIcon(definition)+html.EscapeString(definition.Name), template, html.EscapeString(shopAccess(definition))) - fmt.Fprint(w, "<p>This is the possible stock pool from embedded YAML. Supplies and QL 1-10 equipment stay available. Higher-QL weapon and armor families rotate every 30 minutes, with a 75% inclusion chance per row and QL varying by up to 10% within the supported range. Open trades keep their original stock and prices. Editing stock requires changing the YAML and recompiling.</p>") + fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s</h1><table><tr><th scope='row'>Shop template</th><td>%d</td></tr><tr><th scope='row'>Access</th><td>%s</td></tr>", itemIcon(definition)+html.EscapeString(definition.Name), template, html.EscapeString(shopAccess(definition))) + fmt.Fprint(w, "<tr><th scope='row'>Stock pool</th><td>Possible stock</td></tr><tr><th scope='row'>Always stocked</th><td>Supplies and QL 1-10 equipment</td></tr><tr><th scope='row'>Rotating stock</th><td>Higher-QL weapons and armor</td></tr><tr><th scope='row'>Rotation interval</th><td>30 minutes</td></tr><tr><th scope='row'>Inclusion chance per rotating row</th><td>75%</td></tr><tr><th scope='row'>QL variation</th><td>Up to 10% within supported range</td></tr><tr><th scope='row'>Open-trade stock and prices</th><td>Fixed</td></tr></table>") // Each catalog repeats its placements per item; one source supplies the map. sources := itemSources() for _, family := range slices.Sorted(maps.Keys(sources)) {