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:
+8
-2
@@ -45,7 +45,7 @@ import db_connector/db_sqlite
|
||||
import mummy, mummy/routers
|
||||
import config, db, eventlog, crypto, auth, conns, instancelock, protocol, world, jsonbound
|
||||
import characters, geometry, markers, props, text, tiles, tokens, vision, views, explored, worldmap, faults, moverules
|
||||
import sessions
|
||||
import importer, sessions
|
||||
|
||||
const
|
||||
CookieName* = "fff_session"
|
||||
@@ -2019,7 +2019,7 @@ proc dispatch(conn: Conn, env: Envelope) {.gcsafe.} =
|
||||
of "scene.set":
|
||||
# DESIGN 6.1, slice 10 / #25: a hello-equivalent reset of every connection (the client resets on
|
||||
# `hello`, 6.1) after a GM edit of the settable scene fields. `w`, `h`, `tile_size`, `cell` and
|
||||
# `art_version` are not patch fields (import is the M6 CLI) and are ignored as unknown fields
|
||||
# `art_version` are not patch fields (import is the offline CLI, 11.1) and are ignored as unknown fields
|
||||
# (6.2); a patch carrying only those has no field and is `invalid`.
|
||||
if not sceneOk(conn, env): return
|
||||
var patchOpt = parseScenePatch(env.node)
|
||||
@@ -2366,6 +2366,7 @@ proc cliUsage(): string =
|
||||
|
||||
Usage: fff-vtt [options]
|
||||
fff-vtt gm-key [--new] [options]
|
||||
fff-vtt import --image=<path> [--scene=<id>] [--tile-size=<px>] [options]
|
||||
|
||||
Options:
|
||||
--public-origin=<url> Browser origin the site is served from (default: http://localhost:8080).
|
||||
@@ -2378,6 +2379,9 @@ Commands:
|
||||
gm-key Create the single GM if needed and print the GM key (same key on re-run).
|
||||
gm-key --new Rotate the GM key and revoke all GM sessions. Refused while the server
|
||||
holds the state-dir lock (stop the server first).
|
||||
import Slice a PNG/WebP map into the scene's tile tree and update the scene row.
|
||||
Stop the server first (it reads the scene at startup); restart it after.
|
||||
Run `fff-vtt import --help` for the import arguments.
|
||||
|
||||
The bind address is fixed at 127.0.0.1 and is not a key: put nginx (or another TLS proxy) in front.
|
||||
"""
|
||||
@@ -2533,6 +2537,8 @@ proc main() =
|
||||
let args = commandLineParams()
|
||||
if args.len > 0 and args[0] == "gm-key":
|
||||
quit runGmKey(if args.len > 1: args[1 .. ^1] else: @[])
|
||||
if args.len > 0 and args[0] == "import":
|
||||
quit runImport(if args.len > 1: args[1 .. ^1] else: @[])
|
||||
|
||||
var cfg: Config
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user