commit 368ae06b2d28c11be90cf2a36b4a585ba705e2d5
parent be15fec65c089600d02ac609cabed90fc596c736
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 03:51:27 +0000
Use external server assets by default with opt-in embedding
Diffstat:
15 files changed, 270 insertions(+), 96 deletions(-)
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
@@ -8,17 +8,25 @@ See [README.md](README.md) for the quick start and repository overview.
Game definitions and their provenance are embedded YAML in `server/gamedata`.
NPC behavior is Go code in that directory, linked to YAML group IDs through
`NPCScripts`; see [the conversation API and source evidence](docs/npc-scripts.md).
-Static resources live in `server/assets` and are embedded in the server. Build with Go 1.26 or
-newer from the repository root:
+Static resources live in `server/assets`. Default builds read `./assets/` from
+their launch directory. Build with Go 1.26 or newer from the repository root:
```sh
go build -o ao-server ./server
-./ao-server
+cd server
+../ao-server
```
-Distribute `ao-server` by itself (or the corresponding Windows binary). It can
-run from an empty directory; static resources are served directly from the
-binary. Mutable world state is stored in `data/world.sqlite` and certificates in
+For a standalone release, build from the repository root with
+`go build -tags embedassets -o ao-server ./server`. Distribute that binary by
+itself (or the corresponding Windows binary); it can run from an empty directory.
+An external-assets installation instead needs `assets/` containing
+`anarchy-assets-14.9.1/`, `client/`, `maps/`, `favicon.ico`, `terrain.bin` and
+`zone_links.yaml`, with the layout from `server/assets/`. Both providers use the
+same resource readers and HTTP handlers. Game-definition YAML and the small
+admin map script remain compiled into both builds.
+
+Mutable world state is stored in `data/world.sqlite` and certificates in
`data/https/`. Server logs go to `logs/server.log` and profiles to `logs/profiles/`.
By default, the terminal and log file contain startup/shutdown, player connections
with peer IP and port, and errors. Browser connections retain the HTTP peer address;
@@ -52,10 +60,20 @@ replacement.
The matching browser build is checked in under `server/assets/client/`:
`index.html`, `game.js`, `game.wasm.br`, `profile-worker.js`, `audio-worklet.js`,
-and `build.json`. A fresh clone can run `go run ./server` immediately.
+and `build.json`. A fresh clone can run `(cd server && go run .)` immediately.
No Emscripten, Python, Make, C compiler, or original Windows client is needed
-on the server build machine. Rebuild the Go binary after updating resources.
+on the server build machine. Restart after updating external resources; rebuild
+tagged binaries to include changed resources. Keep the same launch directory
+when restarting an existing installation so it retains its `data/` and `logs/`.
+To retain a repository-root installation, put an `assets` symlink to
+`server/assets` there before launching the default binary.
+
+Run `go test ./server` from the repository root normally. Go starts package tests
+in `server/`; the external provider captures the absolute asset root before
+fixtures change directory. Run manually compiled test binaries from `server/`
+as well. `go test -tags embedassets ./server` checks the standalone provider;
+its resource parity test compares bytes and HTTP responses against disk assets.
Requires Go 1.26 or newer. The server listens on all network interfaces. Default
ports are login 7500, world 7501, chat 7502, HTTP 8080 and HTTPS 8443. Chat uses
@@ -73,7 +91,8 @@ can be moved to `logs/profiles/`. Server messages are appended to
`logs/server.log` and also printed to the terminal.
```sh
-go run ./server
+cd server
+go run .
```
### Reverse proxy deployment
@@ -247,7 +266,8 @@ make wasm -j8
```
This downloads/builds the audio dependencies, compiles the game, and writes the
-six files above to tracked `server/assets/client/`, which Go embeds when building. The first build is
+six files above to tracked `server/assets/client/`, which the default server reads
+from disk and `embedassets` builds include in the executable. The first build is
heavy; allow several gigabytes of build space and substantial compilation time.
ThinLTO optimizes calls across source files with eight linker workers. Keep
`client/build/wasm/lto-cache/` to reuse that work on subsequent builds.
@@ -291,7 +311,8 @@ writes extraction candidates to `local/reports/` for review, leaving maintained
YAML intact. `make assets` copies game resources from the top-level
`anarchy-assets-14.9.1/` directory and derived data from `data/` into
`server/assets/`. `make wasm` runs this step before building and publishing
-the browser client. Go embeds the ordinary files directly; there are no
+the browser client. The default provider reads ordinary files directly;
+`embedassets` embeds them without changing their paths. There are no
resource archives, split files or startup extraction. Asset checksums are
prepared during copying so browser cache validation does not scan large files
at server startup. Extraction tools write reproducible JSON candidates into
@@ -349,7 +370,7 @@ Install the same build dependencies and fonts inside WSL. Run the server there
as well so the client can reach it on localhost:
```powershell
-wsl --cd /path/to/ao --exec go run ./server
+wsl --cd /path/to/ao/server --exec go run .
```
In another terminal:
@@ -412,8 +433,8 @@ The server may need network access on its first build to download Go modules.
| `client/tests/` | Native contract and regression tests. |
| `server/` | Go server and server-side game logic. |
| `server/gamedata/` | Embedded YAML definitions, provenance and Go schemas. |
-| `server/assets/` | Embedded static resources and their Go loader. |
-| `server/assets/client/` | Checked-in browser build, embedded when building the server. |
+| `server/assets/` | External static resources and the optional `embedassets` provider. |
+| `server/assets/client/` | Checked-in browser build, bundled by `embedassets` releases. |
| `anarchy-vanilla-14.9.1/` | Local original game for Windows reference comparisons. |
| `anarchy-runtime-14.9.1/` | Windows runtime assets and native vendor DLLs. |
| `anarchy-assets-14.9.1/` | Portable game assets and configuration; no Windows executables or plug-ins. |
diff --git a/Makefile b/Makefile
@@ -8,6 +8,6 @@ wasm:
+$(MAKE) -C client -f Makefile.wasm
python3 tools/client/publish_wasm.py
-# Copy static game data for direct embedding in the Go server.
+# Copy static game data for the external and embedded server providers.
assets:
python3 tools/client/package_runtime.py
diff --git a/README.md b/README.md
@@ -49,29 +49,32 @@ Install Go 1.26 or newer, then clone and run:
```sh
git clone https://<game-host>/share/demo/code/ao.git
-cd ao
-go run ./server
+cd ao/server
+go run .
```
Edit Go code in `server/` and game definitions (NPC spawns and scripts) in
`server/gamedata/`, then restart the server to apply your changes. The compiled
browser client is included, so you do not need a WASM toolchain for server-side work.
+Default builds read `./assets/` from the launch directory. To build a standalone
+release from the repository root, use `go build -tags embedassets -o ao-server ./server`.
## 4. Modify and compile the client
Clone the repository as above. Client sources and browser controls live in
`client/`. Follow the [browser toolchain setup](DEVELOPERS.md#build-the-browser-client-on-debian),
-then build and publish the WASM client:
+then build and publish the WASM client from the repository root:
```sh
python3 tools/client/build_wasm_dependencies.py
make -C client -f Makefile.wasm -j8
python3 tools/client/publish_wasm.py
-go run ./server
+(cd server && go run .)
```
-Publishing updates the browser files embedded in the Go server. Restart the
-server after rebuilding and reload the game. The first client build takes
+Publishing updates the browser files in `server/assets/client/`. Restart the
+server and reload the game; rebuild standalone `embedassets` binaries to include
+the new files. The first client build takes
substantial time and several gigabytes of build space.
You can optionally build a native Linux or Windows client with `make` using the
diff --git a/TODO.md b/TODO.md
@@ -306,7 +306,7 @@ rewriting this document does not close them.
been made. Completion: smooth cursor motion at low FPS, correct cursor shapes
and click alignment, and no regressions in camera controls, item dragging or
touch input.
-- [ ] **Use external assets by default; make single-executable bundling opt-in.**
+- [x] **Use external assets by default; make single-executable bundling opt-in.**
The assets directory currently occupies about 1.2 GB and is unconditionally
embedded into the server/test build. Default development builds should read
`./assets/` through the existing `fs.FS` boundary. Select the embedded provider
@@ -318,6 +318,12 @@ rewriting this document does not close them.
asset tree; the tagged executable runs without external assets; representative
resource reads and HTTP responses agree in both modes. Update build/release
instructions and resource tests to cover both providers.
+ November 5: default builds capture `./assets/` at launch; `embedassets` selects
+ the standalone provider. Both resource/HTTP selections and direct provider
+ parity pass. The tagged server runs from an empty directory; the default
+ provider passes native browser startup and resizing. Server size is 169 MB
+ externally versus 1.34 GB embedded; tests are 194 MB versus 1.37 GB. See
+ [provider verification and launch instructions](docs/repository-packaging.md#asset-provider-verification).
- [x] **Repair the NPC fixture's missing interior resources.**
The fixture opens the packaged database for required interior geometry while
retaining its fake population, terrain and zone links. Synthetic outdoor
diff --git a/docs/portable-assets.md b/docs/portable-assets.md
@@ -2,8 +2,9 @@
`anarchy-assets-14.9.1/` is the portable client's working directory. It contains
data and configuration, not the Windows installation. Its unpacked form is
-ignored by Git. The required files are now included in the compressed `runtime/`
-bundle and unpacked automatically by `go run ./server` on a fresh checkout.
+ignored by Git. The required server files are checked in under `server/assets/`.
+Default builds read that directory externally; standalone `embedassets` builds
+include it without unpacking files at startup.
See [repository packaging](repository-packaging.md) for the current handoff.
`tools/client/prepare_portable_assets.py` creates it from an explicit allowlist
diff --git a/docs/repository-packaging.md b/docs/repository-packaging.md
@@ -35,12 +35,15 @@ with a fresh clone; do not merge the old history back into the repository.
Clone the repository normally; the complete matching `server/assets/client/`
bundle is checked in. No WASM toolchain is needed for server work. Build with
-`go build -o ao-server ./server` using Go 1.26 or newer. Distribute the resulting
-binary by itself; it can run from an empty directory. Open
+`go build -o ao-server ./server` using Go 1.26 or newer, then launch it from
+`server/` with `../ao-server` so it reads `./assets/`. For a standalone release,
+use `go build -tags embedassets -o ao-server ./server` and distribute that binary
+by itself; the tagged binary can run from an empty directory. Open
`http://127.0.0.1:8080/`. The server listens on all interfaces; use its HTTPS
port from other machines.
-Static resources are ordinary files embedded directly from `server/assets`.
+Static resources are ordinary files read from `./assets/` by default and
+embedded directly from `server/assets` with the `embedassets` build tag.
`server/gamedata` contains embedded YAML for NPCs, playfields, monsters,
items, map coordinates and their extraction provenance, plus Go schemas and loading code. The
resources include portable 14.9.1 playfields, audio, textures, fonts/configuration,
@@ -55,13 +58,53 @@ unpacking them. Mutable world state goes to `data/world.sqlite`; certificates
stay in `data/https/`. Server logs go to `logs/server.log`; the
terminal shows startup, connections and errors. Browser profiles go to `logs/profiles/`.
Old unpacked assets and `.runtime-bundle` markers are no longer read by the
-server. Rebuild the Go binary after updating any static inputs or NPC code.
-
-`go test ./server` uses embedded inputs and temporary state directories, away
-from saved characters. Authored NPC population expectations are checked in
+server. Restart after changing external resources or rebuild tagged binaries;
+NPC code and embedded game-definition changes always need a rebuild.
+
+`go test ./server` captures the external asset directory before fixtures change
+to temporary state directories, away from saved characters. Manually compiled
+test binaries must start in `server/`. Use `go test -tags embedassets ./server`
+to check the standalone provider, including parity with disk resources.
+Authored NPC population expectations are checked in
under `server/testdata/`; Python extraction tools are not required for Go tests.
-The static resources and binary are each approximately 1.3 GB. Build caches also
-contain embedded resources; allow several GB for the checkout and Go builds.
+Static resources occupy about 1.2 GB; default executables do not contain that
+tree. Tagged executables and their build caches include it. Both providers keep
+the small admin map script and `server/gamedata` catalogs compiled in.
+
+## Asset provider verification
+
+The November 5 checks build both providers from the same checkout:
+
+| Build | External default | `embedassets` |
+| --- | ---: | ---: |
+| Server executable | 169,465,992 bytes | 1,341,335,264 bytes |
+| Test executable | 193,785,048 bytes | 1,365,673,176 bytes |
+
+`go list` reports only the small `map.js` application script as an embedded
+input in the default assets package. The resource tree appears only with the
+tag. Game-definition catalogs remain embedded in their own package; this
+change makes no claim about full-suite runtime or catalog initialization cost.
+
+The focused packaged-resource, browser-file/range/cache, resource-index and
+HTTP-mount tests pass under both builds. Tagged parity checks compare terrain,
+zone-link and database-index prefixes plus complete browser JS/WASM, page,
+manifest, version and database-range HTTP bodies against the external files.
+Only ETag and Last-Modified differ by design: disk uses modification metadata,
+while embedded files use content hashes. Their respective cache checks pass.
+
+The actual tagged server starts in an empty temporary directory, serves the
+browser page and exact database byte range, creates its private database and
+certificates, and exits cleanly on SIGTERM without any external `assets/`.
+The default provider also passes `TestBrowserOptionsResize` in 11.91 seconds:
+native world loading and mouse interaction at all seven sizes, after test
+fixtures have changed working directories. No browser errors were recorded.
+`go vet ./server` and syntax checks for the adjusted sweep launchers pass.
+
+Evidence is retained under `local/external-assets/`: `default.log`,
+`embedded.log`, `standalone.json`, `standalone.log`, `browser-external.log` and
+`vet.log`. All test processes are closed. The browser sweep explicitly opts
+into embedding its build-overlay pages; the native sweep shares external
+assets through a link in its isolated working directory.
## Handoff verification
@@ -89,7 +132,8 @@ stopped afterward.
`make wasm -j8` builds dependencies and the client, then publishes the six
matching files to tracked `server/assets/client/`. Commit them together after
-validation and rebuild the server. `build.json` records the source revision, source digest,
+validation and restart the server (rebuild `embedassets` binaries).
+`build.json` records the source revision, source digest,
compiler identity and output hashes. Edit `client/runtime/` or `client/browser/`
and republish instead of editing generated JavaScript.
diff --git a/server/assets/files_embedded.go b/server/assets/files_embedded.go
@@ -0,0 +1,10 @@
+//go:build embedassets
+
+package assets
+
+import "embed"
+
+// Files contains the read-only resources bundled into a standalone server.
+//
+//go:embed anarchy-assets-14.9.1 client favicon.ico maps terrain.bin zone_links.yaml
+var Files embed.FS
diff --git a/server/assets/files_external.go b/server/assets/files_external.go
@@ -0,0 +1,18 @@
+//go:build !embedassets
+
+package assets
+
+import (
+ "io/fs"
+ "os"
+ "path/filepath"
+)
+
+// Capture the launch directory before test fixtures change the working directory.
+var Files fs.FS = func() fs.FS {
+ root, err := filepath.Abs("assets")
+ if err != nil {
+ panic(err)
+ }
+ return os.DirFS(root)
+}()
diff --git a/server/assets/resources.go b/server/assets/resources.go
@@ -1,11 +1,6 @@
package assets
-import "embed"
-
-// Files contains the read-only resources shipped with the server.
-//
-//go:embed anarchy-assets-14.9.1 client favicon.ico maps terrain.bin zone_links.yaml
-var Files embed.FS
+import _ "embed"
//go:embed map.js
var ControlMapScript string
diff --git a/server/embedded_resources_test.go b/server/embedded_resources_test.go
@@ -1,71 +1,74 @@
+//go:build embedassets
+
package main
import (
"ao/server/assets"
- "encoding/hex"
- "encoding/json"
+ "bytes"
+ "io"
"io/fs"
"net/http"
"net/http/httptest"
- "strings"
+ "os"
+ "path/filepath"
+ "reflect"
+ "runtime"
"testing"
)
-func TestEmbeddedResourcesServeWithoutExternalFiles(t *testing.T) {
+func TestEmbeddedResourceProviderMatchesExternal(t *testing.T) {
+ _, source, _, _ := runtime.Caller(0)
+ disk := os.DirFS(filepath.Join(filepath.Dir(source), "assets"))
t.Chdir(t.TempDir())
- useResources(t, assets.Files)
- maps, err := fs.Sub(resources, "maps")
- if err != nil {
- t.Fatal(err)
+ for _, name := range []string{"terrain.bin", "zone_links.yaml", "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.idx"} {
+ var prefixes [][]byte
+ for _, provider := range []fs.FS{disk, assets.Files} {
+ file, err := provider.Open(name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ prefix := make([]byte, 64)
+ _, err = io.ReadFull(file, prefix)
+ file.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+ prefixes = append(prefixes, prefix)
+ }
+ if !bytes.Equal(prefixes[0], prefixes[1]) {
+ t.Fatalf("resource prefix differs: %s", name)
+ }
}
+
+ // Both providers use the same HTTP handlers, including large-file ranges.
mux := http.NewServeMux()
mux.HandleFunc("GET /browser-assets/{path...}", browserAsset)
mux.HandleFunc("GET /browser-manifest", browserManifest)
- mux.HandleFunc("GET /browser-resource-index", browserResourceIndex)
mux.HandleFunc("GET /wasm/", (&server{baseURL: "/"}).browserClient)
mux.HandleFunc("GET /{$}", (&server{baseURL: "/"}).browserClient)
- mux.Handle("GET /admin/map-assets/", http.StripPrefix("/admin/map-assets/", http.FileServerFS(maps)))
-
- for _, path := range []string{"/", "/wasm/game.js", "/wasm/build.json", "/browser-manifest", "/browser-resource-index", "/admin/map-assets/manifest.json", "/browser-assets/version.id", "/browser-assets/cd_image/text/help/What%20%27s-This%20General%20Help.txt"} {
- response := httptest.NewRecorder()
- mux.ServeHTTP(response, httptest.NewRequest("GET", path, nil))
-
- if response.Code != http.StatusOK || response.Body.Len() == 0 {
- t.Fatalf("embedded %s: HTTP %d", path, response.Code)
- }
- }
-}
-
-func TestEmbeddedAssetRangesAndManifestVersions(t *testing.T) {
- t.Chdir(t.TempDir())
- useResources(t, assets.Files)
- mux := http.NewServeMux()
- mux.HandleFunc("GET /browser-assets/{path...}", browserAsset)
- manifestRequest := httptest.NewRequest("GET", "/browser-manifest", nil)
- manifestRequest.Header.Set("Accept", "application/json")
- manifest := httptest.NewRecorder()
- request := httptest.NewRequest("GET", "/browser-assets/CD_IMAGE/DATA/DB/resourcedatabase.DAT", nil)
- request.Header.Set("Range", "bytes=27748086-27748101")
- response := httptest.NewRecorder()
-
- browserManifest(manifest, manifestRequest)
- mux.ServeHTTP(response, request)
- var metadata map[string]struct{ Version string }
- if err := json.Unmarshal(manifest.Body.Bytes(), &metadata); err != nil {
- t.Fatal(err)
- }
- cachedRequest := httptest.NewRequest("GET", "/browser-assets/cd_image/data/db/ResourceDatabase.dat", nil)
- cachedRequest.Header.Set("If-None-Match", response.Header().Get("ETag"))
- cached := httptest.NewRecorder()
- mux.ServeHTTP(cached, cachedRequest)
-
- if response.Code != http.StatusPartialContent || hex.EncodeToString(response.Body.Bytes()) != "00010000000c00000001030000000400" || !strings.HasPrefix(response.Header().Get("Content-Range"), "bytes 27748086-27748101/") {
- t.Fatalf("embedded range: HTTP %d, %v, %x", response.Code, response.Header(), response.Body.Bytes())
- }
- if metadata["cd_image/text/help/What 's-This General Help.txt"].Version == "" || metadata["cd_image/text/help/What _s-This General Help.txt"].Version != "" {
- t.Fatal("manifest did not preserve the original help filename")
- }
- if metadata["cd_image/data/db/ResourceDatabase.dat"].Version != response.Header().Get("ETag") || cached.Code != http.StatusNotModified {
- t.Fatalf("embedded asset versions disagree: manifest %s, response %v, cached HTTP %d", manifest.Body.String(), response.Header(), cached.Code)
+ for _, path := range []string{"/", "/wasm/game.js", "/wasm/game.wasm", "/browser-manifest", "/browser-assets/version.id", "/browser-assets/cd_image/data/db/ResourceDatabase.dat"} {
+ t.Run(path, func(t *testing.T) {
+ var responses []*httptest.ResponseRecorder
+ for _, provider := range []fs.FS{disk, assets.Files} {
+ useResources(t, provider)
+ request := httptest.NewRequest("GET", path, nil)
+ if path == "/browser-assets/cd_image/data/db/ResourceDatabase.dat" {
+ request.Header.Set("Range", "bytes=27748086-27748101")
+ }
+ response := httptest.NewRecorder()
+ mux.ServeHTTP(response, request)
+ if response.Code != http.StatusOK && response.Code != http.StatusPartialContent {
+ t.Fatal("resource request failed", response.Code)
+ }
+ // Disk modification times and embedded content hashes have distinct validators.
+ response.Header().Del("ETag")
+ response.Header().Del("Last-Modified")
+ responses = append(responses, response)
+ }
+ if responses[0].Code != responses[1].Code || !bytes.Equal(responses[0].Body.Bytes(), responses[1].Body.Bytes()) ||
+ !reflect.DeepEqual(responses[0].Header(), responses[1].Header()) {
+ t.Fatal("external and embedded HTTP responses differ")
+ }
+ })
}
}
diff --git a/server/packaged_resources_test.go b/server/packaged_resources_test.go
@@ -0,0 +1,71 @@
+package main
+
+import (
+ "ao/server/assets"
+ "encoding/hex"
+ "encoding/json"
+ "io/fs"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestPackagedResourcesServeAfterWorkingDirectoryChanges(t *testing.T) {
+ t.Chdir(t.TempDir())
+ useResources(t, assets.Files)
+ maps, err := fs.Sub(resources, "maps")
+ if err != nil {
+ t.Fatal(err)
+ }
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /browser-assets/{path...}", browserAsset)
+ mux.HandleFunc("GET /browser-manifest", browserManifest)
+ mux.HandleFunc("GET /browser-resource-index", browserResourceIndex)
+ mux.HandleFunc("GET /wasm/", (&server{baseURL: "/"}).browserClient)
+ mux.HandleFunc("GET /{$}", (&server{baseURL: "/"}).browserClient)
+ mux.Handle("GET /admin/map-assets/", http.StripPrefix("/admin/map-assets/", http.FileServerFS(maps)))
+
+ for _, path := range []string{"/", "/wasm/game.js", "/wasm/build.json", "/browser-manifest", "/browser-resource-index", "/admin/map-assets/manifest.json", "/browser-assets/version.id", "/browser-assets/cd_image/text/help/What%20%27s-This%20General%20Help.txt"} {
+ response := httptest.NewRecorder()
+ mux.ServeHTTP(response, httptest.NewRequest("GET", path, nil))
+
+ if response.Code != http.StatusOK || response.Body.Len() == 0 {
+ t.Fatalf("packaged %s: HTTP %d", path, response.Code)
+ }
+ }
+}
+
+func TestPackagedAssetRangesAndManifestVersions(t *testing.T) {
+ t.Chdir(t.TempDir())
+ useResources(t, assets.Files)
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /browser-assets/{path...}", browserAsset)
+ manifestRequest := httptest.NewRequest("GET", "/browser-manifest", nil)
+ manifestRequest.Header.Set("Accept", "application/json")
+ manifest := httptest.NewRecorder()
+ request := httptest.NewRequest("GET", "/browser-assets/CD_IMAGE/DATA/DB/resourcedatabase.DAT", nil)
+ request.Header.Set("Range", "bytes=27748086-27748101")
+ response := httptest.NewRecorder()
+
+ browserManifest(manifest, manifestRequest)
+ mux.ServeHTTP(response, request)
+ var metadata map[string]struct{ Version string }
+ if err := json.Unmarshal(manifest.Body.Bytes(), &metadata); err != nil {
+ t.Fatal(err)
+ }
+ cachedRequest := httptest.NewRequest("GET", "/browser-assets/cd_image/data/db/ResourceDatabase.dat", nil)
+ cachedRequest.Header.Set("If-None-Match", response.Header().Get("ETag"))
+ cached := httptest.NewRecorder()
+ mux.ServeHTTP(cached, cachedRequest)
+
+ if response.Code != http.StatusPartialContent || hex.EncodeToString(response.Body.Bytes()) != "00010000000c00000001030000000400" || !strings.HasPrefix(response.Header().Get("Content-Range"), "bytes 27748086-27748101/") {
+ t.Fatalf("packaged range: HTTP %d, %v, %x", response.Code, response.Header(), response.Body.Bytes())
+ }
+ if metadata["cd_image/text/help/What 's-This General Help.txt"].Version == "" || metadata["cd_image/text/help/What _s-This General Help.txt"].Version != "" {
+ t.Fatal("manifest did not preserve the original help filename")
+ }
+ if metadata["cd_image/data/db/ResourceDatabase.dat"].Version != response.Header().Get("ETag") || cached.Code != http.StatusNotModified {
+ t.Fatalf("packaged asset versions disagree: manifest %s, response %v, cached HTTP %d", manifest.Body.String(), response.Header(), cached.Code)
+ }
+}
diff --git a/tools/README.md b/tools/README.md
@@ -31,7 +31,7 @@ and the C toolchain; normal server builds need Go.
- `client/package_runtime.py`: copies the required portable assets from
`anarchy-assets-14.9.1/` and derived server data into `server/assets/`, and
prepares HTTP checksums. `make assets` runs it; `make wasm` includes this step.
- Go embeds the ordinary files directly.
+ Default builds read those files externally; `-tags embedassets` embeds them.
- `client/audit_linux_imports.gdb.py`: queries the compiled resolver to refresh
`docs/linux-import-coverage.json`. An adapter being present does not imply
every possible argument is implemented.
@@ -69,7 +69,7 @@ The existing isolated Windows server is
`local/client/fonts/server-14.9.1/server.exe`, run from its containing directory.
The WSL wrapper starts `local/client/linux-server-probe/server` itself. Both
use separate fixture data and ports 7510/7511/8081. They are preserved diagnostic
-server builds; the normal server is always `go run ./server` on the default ports.
+server builds; the normal server is `(cd server && go run .)` on the default ports.
Do not point these tests at the user's normal `data/players/` directory.
With the isolated Windows server running:
diff --git a/tools/client/package_runtime.py b/tools/client/package_runtime.py
@@ -1,4 +1,4 @@
-"""Copy static game resources into the Go server's embedded asset directory."""
+"""Copy static game resources into the Go server's asset directory."""
import hashlib
import json
import pathlib
diff --git a/tools/client/sweep_browser.py b/tools/client/sweep_browser.py
@@ -38,7 +38,7 @@ overlay.write_text(json.dumps({'Replace': {
('sweep-client.html', root / 'tools/client/sweep_browser_client.html'),
]
}}))
-subprocess.run(['go', 'build', '-overlay', str(overlay), '-o', str(work / 'server'), './server'], cwd=root, check=True)
+subprocess.run(['go', 'build', '-tags', 'embedassets', '-overlay', str(overlay), '-o', str(work / 'server'), './server'], cwd=root, check=True)
# The browser copies preferences into private WASM memory; HTTP assets are read-only.
fixture = output / 'server'
diff --git a/tools/client/sweep_playfields.py b/tools/client/sweep_playfields.py
@@ -48,6 +48,8 @@ if not resuming:
active.mkdir()
(fixture / 'data').mkdir(parents=True)
tools.client.server_fixture.create_player(fixture, 'Playfield Sweep', [0, 0, 0, 1])
+if not (fixture / 'assets').exists():
+ (fixture / 'assets').symlink_to(root / 'server/assets', target_is_directory=True)
for port in [7520, 7521, 8082]:
with socket.socket() as connection:
assert connection.connect_ex(('127.0.0.1', port)) != 0, port