feat(server): map import CLI, pulled forward to M4 (#79)
Slice a PNG/WebP map into the gate's <x>_<y>.png tree under <state>/tiles/<scene>/v<art_version>/ and update the one scene row (w, h, tile_size, art_version); a re-import grows art_version so clients never serve stale tiles. The state-dir lock keeps a running server out (it loads the scene at startup), so stop/import/restart. Decoding is ImageMagick from the root devbox with a disk-backed pixel cache (-limit memory/map), keeping a 16384 px source memory-sane; no Nim/npm image dependency and the FIXED stack is unchanged. The black-box harness covers the tile geometry, scene row, restart pickup through the gate, re-import bump and every refused-import case. Records the M6 -> M4 move in DESIGN 3.3/11.1/13 and DESIGN-history, and documents the CLI plus the 16384 px/50-token recipe in README.
This commit is contained in:
@@ -48,6 +48,43 @@ Re-running prints the same key. `gm-key --new` rotates it and revokes every GM s
|
||||
in-browser way to become GM and no first-visitor claim: without the key you only ever see the
|
||||
sign-in page.
|
||||
|
||||
### Import the map
|
||||
|
||||
The map is a source image plus a tiled copy the server gates per player. One offline command slices
|
||||
the image and updates the scene; the server must be **stopped** for it (it reads the scene once at
|
||||
startup) and restarted afterwards. ImageMagick comes from the root devbox.
|
||||
|
||||
```sh
|
||||
# stop the server first, then:
|
||||
devbox run -- ./run/fff-vtt import --state-dir=run --image=/path/to/map.png --tile-size=64
|
||||
# restart the server with the usual command
|
||||
```
|
||||
|
||||
| argument | meaning |
|
||||
|---|---|
|
||||
| `--image=<path>` | source PNG or WebP (required); tiles are always PNG |
|
||||
| `--tile-size=<px>` | tile edge, default the scene's current tile size; must be a positive multiple of the 32 px explored cell (so 32 or the 64 px fallback) |
|
||||
| `--scene=<id>` | target scene; v1 has exactly one, id 1 |
|
||||
| `--state-dir=<path>` | the same state dir as the server (default `run`) |
|
||||
|
||||
Tiles land in `<state-dir>/tiles/1/v<art_version>/<x>_<y>.png`, origin at the world origin, which is
|
||||
exactly what the gate parses and nginx's internal `/_tiles/` alias serves. The command sets the
|
||||
scene's width, height and tile size from the image. Importing again grows `art_version` and writes a
|
||||
new `v` directory, so browsers never keep a stale tile; old versions stay on disk until the M6
|
||||
cleanup. Any problem exits non-zero and writes nothing: a missing/unreadable source or state dir, an
|
||||
unsupported or multi-frame image, a scene other than 1, a tile size that is not a multiple of the
|
||||
cell, or a server still holding the state-dir lock (exit 3).
|
||||
|
||||
**A 16384 px scene with 50 tokens (the phone-playtest target).**
|
||||
|
||||
1. Prepare a 16384×16384 PNG or WebP. `--tile-size=64` is the designed fallback and gives 256×256 =
|
||||
65,536 tiles (32 px would give 262,144 files); ImageMagick keeps the source in a disk-backed
|
||||
pixel cache, so allow temp space and a few minutes rather than gigabytes of RAM.
|
||||
2. Stop the server, run the import above, restart it.
|
||||
3. Create the 50 tokens with the GM token panel (or the `token.create` intent); tokens, walls and
|
||||
explored state are untouched by the import.
|
||||
4. Point nginx's `/_tiles/` alias at `<state-dir>/tiles` as shown below.
|
||||
|
||||
### Start the server
|
||||
|
||||
```sh
|
||||
@@ -116,11 +153,11 @@ backup timer) exists in the repo yet; that is M6.
|
||||
count toward the cap.
|
||||
3. **Map.** Only one scene exists. It is seeded at 4096×4096 px with 32 px tiles and cells, a 400 px
|
||||
default vision radius, a 20 px default token radius and no grid (the grid toggle exists, but the
|
||||
seeded grid size is 0 and only `scene.set` can change it). There is **no map upload and no
|
||||
import command yet**: browser upload is post-v1 and the map import CLI is M6. Today you put the
|
||||
tile images in `<state-dir>/tiles/1/v1/<x>_<y>.png` yourself (32 px PNGs, `x` left to right and
|
||||
`y` top to bottom from the world origin, no leading zeros). A player is served a tile only after
|
||||
they have explored a cell that overlaps it; the GM
|
||||
seeded grid size is 0 and only `scene.set` can change it). Replace the map with the offline
|
||||
import CLI described under *Import the map* (`fff-vtt import`, server stopped first, restarted
|
||||
after): it writes the tile tree under `<state-dir>/tiles/1/v<art_version>/` and sets the width,
|
||||
height and tile size. There is still **no browser upload** (post-v1). A player is served a tile
|
||||
only after they have explored a cell that overlaps it; the GM
|
||||
always gets every tile. Because one 32 px cell is the unit of disclosure, do not paint secret
|
||||
doors, traps or notes into map art near places players can reach — keep secrets as GM-only tokens.
|
||||
4. **Tokens.** *Create token* takes a kind, a descriptive name, an actual name, a position, a radius
|
||||
@@ -153,7 +190,7 @@ you write to the wire yourself:
|
||||
|
||||
Still missing entirely:
|
||||
|
||||
- map upload or an import command (browser upload is post-v1, the import CLI is M6);
|
||||
- browser map upload (post-v1; the offline `fff-vtt import` CLI exists);
|
||||
- wall thickness, height, see-over and wall placement (built after the phone playtest, ADR-0012);
|
||||
- the graded who-sees-it fraction (needs wall heights);
|
||||
- the NixOS module, systemd unit and backup timer (M6);
|
||||
|
||||
Reference in New Issue
Block a user