feat(walls): marker retraction, re-earn and marker fault classes (#60)
Retract a player marker when the GM removes the wall, clears player_marker, makes the wall stop deriving window, or moves its geometry (a/b, thickness, position). Retraction emits del only and never the new anchor; a re-earned marker gets a fresh id. The marker_seen deletes ride the same derived-memory NORMAL transaction as the explored chunks, after the wall row commits and before the ack. Replace the leak checker's aggregate MARKER class with MARKER_EARLY, MARKER_EXTRA and MARKER_OFF, add their leakfault hooks and exact-class fault tests, and extend the leak scenario with an unseen marked window and a marked solid wall as the negative controls. WS black-box tests cover all four causes, fresh re-earns, no untouched re-send, no set/del for one id in a frame, no explored write from a retraction, and delete/cascade durability across a restart.
This commit is contained in:
+11
-5
@@ -235,7 +235,8 @@ proc recordEncounters() =
|
||||
# M3 slice 6 / #21, #59). Both live in memory and reach the DB only here. One rule: a mutation writes
|
||||
# exactly the explored chunks its refresh dirtied and the markers it minted, never the whole state,
|
||||
# and the write rides in the mutation's transaction so an ack cannot precede what it reports. NORMAL
|
||||
# durability (Q12): both are derived and monotone (a marker only grows in r1), not GM-authored.
|
||||
# durability (Q12): both are derived (explored only grows; a marker is minted and retracted by the
|
||||
# GM's causes), never GM-authored.
|
||||
|
||||
proc dirtyExplored(pids: openArray[int]): seq[explored.Chunk] =
|
||||
## The chunks the last refresh dirtied, for the named players. Caller holds the lock and has
|
||||
@@ -252,16 +253,21 @@ proc dirtyExplored(pids: openArray[int]): seq[explored.Chunk] =
|
||||
proc persistMarkers(pids: openArray[int]) =
|
||||
## The marker half alone, for a connect where the explored grid must stay exactly as it was (a
|
||||
## schema-4/7 database rebuilds its grid on connect and stores nothing until a mutation): a marker
|
||||
## minted at the resync is still durable before it is sent (5.8, 4.2 step 6).
|
||||
## minted at the resync is still durable before it is sent (5.8, 4.2 step 6). The deletes run
|
||||
## before the inserts: a moved wall's old marker must be gone before its fresh one is stored, and
|
||||
## both are the same derived-memory transaction.
|
||||
for pid in pids:
|
||||
if pid == GmControlled: continue
|
||||
discard markers.writeDead(app.db, pid,
|
||||
app.visions.mgetOrPut(pid, PlayerVision()).markerDead)
|
||||
discard markers.writeNew(app.db, app.scene.id, pid,
|
||||
app.visions.mgetOrPut(pid, PlayerVision()).markerFresh)
|
||||
|
||||
proc persistDerived(pids: openArray[int]) =
|
||||
## Writes the dirtied explored chunks and the markers the same refresh minted (5.8: a marker insert
|
||||
## is in the same derived-memory transaction as the explored chunks, after the wall row commits).
|
||||
## No transaction of its own: the caller wraps it together with the mutation's row writes.
|
||||
## Writes the dirtied explored chunks and the markers the same refresh minted or retracted (5.8:
|
||||
## marker inserts and deletes are in the same derived-memory transaction as the explored chunks,
|
||||
## after the wall row commits). No transaction of its own: the caller wraps it together with the
|
||||
## mutation's row writes.
|
||||
let chunks = dirtyExplored(pids)
|
||||
if chunks.len > 0: discard explored.writeChunks(app.db, app.scene.id, chunks)
|
||||
persistMarkers(pids)
|
||||
|
||||
Reference in New Issue
Block a user