fix: walls r1 review — server (ref #52)

This commit is contained in:
2026-11-20 08:42:50 +01:00
parent f9f26a4a01
commit e1a5b297e4
11 changed files with 198 additions and 167 deletions
+11 -8
View File
@@ -632,9 +632,10 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
DEFAULT 0 CHECK (secret IN (0,1)), locked INTEGER NOT NULL DEFAULT 0 CHECK (locked IN (0,1)),
height REAL NULL CHECK (height IS NULL OR (height > 0 AND height <= 100)), label TEXT NULL CHECK
(label IS NULL OR (length(label) >= 1 AND length(label) <= 64)), flags TEXT NOT NULL DEFAULT
'{}', PRIMARY KEY (scene_id, id), CHECK (open = 0 OR door = 1), CHECK (secret = 0 OR (door = 1
AND open = 0 AND blocks_sight = 1 AND blocks_movement = 1 AND sight_dir = 'both')), CHECK
(locked = 0 OR door = 1), CHECK (sight_dir = 'both' OR blocks_sight = 1))`
'{}', PRIMARY KEY (scene_id, id), CHECK (open = 0 OR door = 1), CHECK (open = 0 OR locked = 0),
CHECK (secret = 0 OR (door = 1 AND open = 0 AND blocks_sight = 1 AND blocks_movement = 1 AND
sight_dir = 'both')), CHECK (locked = 0 OR door = 1), CHECK (sight_dir = 'both' OR blocks_sight
= 1))`
3. `INSERT INTO wall (...) SELECT ..., 0, 'center', 1, 1, 'both', 0, CASE kind WHEN 'door' THEN 1
ELSE 0 END, CASE kind WHEN 'door' THEN open ELSE 0 END, 0, 0, NULL, NULL, flags FROM wall_v1` —
every existing wall becomes today's behaviour: `thickness 0`, `position center`,
@@ -659,8 +660,8 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
answer (5.7).
- **`label` and `height` NULL binding:** db_connector quotes every bound argument as text and
cannot bind NULL, so both columns are written as SQL literals (`NULL` when absent) by one helper
in `server/world.nim` (`world.sqlLitText` doubles `'`; a real is formatted with a fixed
locale-free form). The `''`-for-NULL trick used by `encountered.actual_name` does not apply:
in `server/db.nim` (`db.sqlLitText` doubles `'` and refuses NUL or other control characters; a
real is formatted with a fixed locale-free form). The `''`-for-NULL trick used by `encountered.actual_name` does not apply:
`''` is not a legal label (`1..64`) and `0` is not a legal height (`> 0`), so a sentinel would
make the load path lie about the domain.
- **Startup and write timing:** `marker_seen` rows are loaded per player with the explored chunks
@@ -1394,7 +1395,9 @@ switch a boolean and `sight_dir` one of `both|left|right`, with a non-`both` `si
`blocks_sight:true` (#47); `open`/`secret`/`locked` only with `door`; a secret door closed, two-way
and opaque (`blocks_sight` and `blocks_movement` both true); `open:true` with `secret` or `locked`
is `invalid` (#46, 5.8); `label` an optional 6.5 text string of 1..64 code points, or `null`;
`preset` is `wall|door|window|one_way` and never with a raw switch in the same payload (5.8, #48).
`preset` is `wall|door|window|one_way` and never with any raw switch or setting in the same
payload — including `open:false`: the payload is preset XOR raw, and any raw field beside a preset
is `invalid` (5.8, #48).
**One expand-and-validate path [FIXED (owner-delegated), 2026-11-17, #49]:** `wall.add`,
`wall.update` and the M6 UVTT importer build the same candidate (geometry + expanded switches +
label) and run the same validation function; a preset is expanded before validation and sets only
@@ -1433,8 +1436,8 @@ switches, never `thickness`, `position` or `height` (#50).
`label`), and a `preset` replaces the whole switch set, so `preset:"door"` on a window turns it
into a closed opaque door, and `preset:"window"` sets `player_marker:true` as part of the
expansion. `open` is not a patch field: it belongs to `door.set`, and an `open` field in
`wall.update` is an unknown field (ignored, 6.2; a `preset` carrying `open:true` is `invalid` as
above). Fields are checked before the target lookup (6.5 steps 7 then 8), so a fieldless
`wall.update` is an unknown field (ignored, 6.2) when it stands alone; beside a `preset`, any raw
switch or setting is `invalid`, `open:false` included (preset XOR raw, above). Fields are checked before the target lookup (6.5 steps 7 then 8), so a fieldless
`wall.update` is `invalid` whatever the id.
- `id` is an integer; lookup failures are `not-found` (a GM's missing target, 6.5 step 8).
`door.set` on a row whose `door` is false is `invalid`, and so is `open:true` on a secret door