fix: hit a wall lying along a sight ray so it casts its line's shadow (#26)
visibilityPolygon casts one ray per 64-gon vertex and ang, ang+-RayEps per wall
endpoint. A wall radial to the viewer is collinear with the ray that crosses it,
and rayHit rejected the collinear case; its own +-RayEps rays meet the wall's
line at the viewer (t = 0, rejected by t > Eps). So the wall got no ray, no
vertex and no shadow, and a token on the line beyond it stayed inside the
polygon: a player-view fog leak (DESIGN 3.1).
Fix: rayHit returns the nearest point of the overlap when the wall lies on the
ray's line (and Inf only for a parallel wall on another line). {.inline.} keeps
the fan's inner loop at its previous cost (CPU-time cross-check on 20k dense
polygons: 25.8s before, 32.5s without the pragma, 24.9s with it).
Proof: tgeometry visibility tests (horizontal k=0, vertical k=16, both wall
directions, a 32 px grid translation, 10 degrees, plus the non-radial and
0.5 px-off negative controls); the leak world gains a wall on the subject's own
column with a hidden token beyond it, and leakcheck's HIDDEN_TOKEN class now
asserts the token-level over-approximation (token centre + viewer->token
segment, 5.4 tolerance), which the GEOMETRY class structurally cannot see.
This commit is contained in:
+45
-2
@@ -8,7 +8,10 @@
|
||||
##
|
||||
## Every failure carries a class, and tools/fault.test.mjs asserts the EXACT class set of each
|
||||
## injected server fault:
|
||||
## HIDDEN_TOKEN a token the subject may not see reached it
|
||||
## HIDDEN_TOKEN a token the subject may not see reached it, or one its polygons admit only
|
||||
## through a wall (#26: the fan's over-approximation is a token-level leak, so the
|
||||
## class is checked on token centres and the viewer->token segment, never on
|
||||
## sampled polygon points; a crossing within the 5.4 boundary tolerance is fine)
|
||||
## GMONLY_TOKEN the same, for a `gm_only` token inside the subject's LOS
|
||||
## WALLDATA a wall-ish key or frame reached the subject
|
||||
## WITHHELD a token the subject may see was not sent (or was taken away while visible)
|
||||
@@ -25,7 +28,8 @@
|
||||
## CHAR_LIST another player's character record or encountered entry reached the subject
|
||||
## CONTROLLER_CHANGE a token changed controller in a group that asked for no such thing (8)
|
||||
## CHAR_OWNER_PROP a character's owner bucket reached a player who does not own it (8)
|
||||
## GEOMETRY the recomputed polygon disagrees with the clear-segment oracle (sanity)
|
||||
## GEOMETRY the recomputed polygon disagrees with the clear-segment oracle (sanity): it only
|
||||
## tests missing vision, so an over-approximated polygon is HIDDEN_TOKEN's job
|
||||
## ONEWAY the subject's fan ignores `sight_dir` (the two-way fan; TESTING 10.3, #58)
|
||||
## MARKER_EARLY a marker arrived before the subject had seen that wall's extent (the extent
|
||||
## gate was dropped: it reveals a position early; TESTING 10.3, #60)
|
||||
@@ -360,6 +364,38 @@ proc insideAny(polys: seq[(string, seq[Vec])], p: Vec): bool =
|
||||
for (_, pts) in polys:
|
||||
if inside(pts, p): return true
|
||||
|
||||
const BoundaryTol = 0.5
|
||||
## DESIGN 5.4: a point within 0.5 px of a vision boundary is ambiguous; the checker's
|
||||
## clear-segment oracle already uses that neighbourhood (TESTING 5.4).
|
||||
|
||||
proc shrink(a, b: Vec, tol: float): (Vec, Vec) =
|
||||
## `a -> b` with both ends pulled in by `tol`; a segment too short to shrink is kept whole.
|
||||
let dx = b.x - a.x
|
||||
let dy = b.y - a.y
|
||||
let l = hypot(dx, dy)
|
||||
if l <= 2 * tol: return (a, b)
|
||||
((a.x + dx / l * tol, a.y + dy / l * tol), (b.x - dx / l * tol, b.y - dy / l * tol))
|
||||
|
||||
proc insideThroughWall(truth: Truth, polys: seq[(string, seq[Vec])], p: Vec): bool =
|
||||
## #26: a point inside a polygon that only a wall admits. The polygons are the same fan the
|
||||
## server runs, and `inside` alone cannot see this leak (the GEOMETRY class checks the opposite
|
||||
## direction, missing vision), so this is the token-level assertion the class list promises:
|
||||
## for the polygon containing `p`, the segment from that viewer's centre to `p` must not pass
|
||||
## through the interior of a sight-blocking wall. Both segments are shrunk by the 5.4 boundary
|
||||
## tolerance first, so a token grazing a corner (inside the polygon while touching the wall's
|
||||
## endpoint) stays tolerated and only a real crossing is a leak.
|
||||
for (pid, pts) in polys:
|
||||
if not inside(pts, p): continue
|
||||
if pid notin truth.tokens: continue
|
||||
let o = truth.tokens[pid].pos
|
||||
let (o2, p2) = shrink(o, p, BoundaryTol)
|
||||
for w in truth.walls:
|
||||
if checkDir and w.sightDir != wdBoth and not w.blindTo(o): continue
|
||||
if not w.blocksSight: continue
|
||||
let (wa, wb) = shrink(w.a, w.b, BoundaryTol)
|
||||
if segsCross(o2, p2, wa, wb): return true
|
||||
false
|
||||
|
||||
proc extentSeen(polys: seq[(string, seq[Vec])], a, b: Vec): bool =
|
||||
## The checker's OWN visible-extent test (DESIGN 5.8, TESTING 10.3; never `vision.nim`): any point
|
||||
## of the segment inside one of the subject's polygons means an endpoint is inside or the segment
|
||||
@@ -652,6 +688,13 @@ proc main() =
|
||||
fail cls, "token " & id & " sent but not visible (group " & g.label & ")"
|
||||
else:
|
||||
seenAny.incl id
|
||||
# #26: the polygon is an over-approximation by design only up to the 5.4 boundary. A
|
||||
# token that is inside it with a wall crossing the viewer -> token segment (away from
|
||||
# either end) is hidden, and this is the token-level assertion the class list promises.
|
||||
if not wantMine and insideThroughWall(truth, polysChecks, actual.pos):
|
||||
leaked[id] = "HIDDEN_TOKEN"
|
||||
fail "HIDDEN_TOKEN", "token " & id &
|
||||
" is inside the subject's polygon only through a wall (group " & g.label & ")"
|
||||
of "token_gone":
|
||||
let id = m["id"].getStr
|
||||
if id notin view:
|
||||
|
||||
Reference in New Issue
Block a user