Pre-Flight — WP-141 — 2026-12-03
Filled-in copy of docs/reference/pre-flight for WP-141. Verdict at the bottom.
Written by the execution session, from the session prompt
docs/sessions/session-WP-141-2026-12-03.md(PR #373, open at claim time). Checked at claim time: WP-141 is 📝 onmain(9afd92e), noWP-141branch in either repository but the session prompt’s owndocs/wp-141-session-prompt, and no open PR naming WP-141 but #373 (the prompt). Both claim branches were pushed before anything else.
Header
- WP:
WP-141 - Title: The Wizard’s Rule Room bottles don’t take a live player’s clicks (Gen 1)
- Pre-flight date:
2026-12-03 - Targets generation(s): 1
- Targets disc(s): Phantom
Dependency check
| Prereq | Status in WORK_INDEX |
Notes |
|---|---|---|
| WP-083 | ✅ Done | The room, WizardsRuleRoom. |
| WP-094 | ✅ Done (2026-11-27) | The rhythm game: the clock, the window, the table. |
| WP-133 | ✅ Done (2026-12-01) | The bottles clicked through handleEvent(); the play self-test lines. |
Rule check: every prereq is ✅ Done.
Repo + disc state
- Docs repo: branch
docs/wp-141-wfr-bottles-live-clickscut fromorigin/main @ 9afd92e, pushed at once; worktreeC:\claude-worktrees\terraglyph-wp-141-docs. - Fork worktree, the claim:
tools/New-ForkWorktree.ps1 -Branch wp-141-wfr-bottles-live-clicks→C:\claude-worktrees\scummvm-wp-141-wfr-bottles-live-clicks, forked fromorigin/scooby-engine @ b59ea35fd8(the merge of fork PR #68, WP-140), pushed at once. - Build: MSYS2 UCRT64,
../configure --disable-all-engines --enable-engine=terraglyphthenmake, out of tree in the worktree’sbuild-tg/. - Game files:
C:\dev\scooby-engine\tools\exes\phantom(local, gitignored). - Logs and configs:
C:\pcloud\scooby-engine\verification\wp-141-2026-12-03\.
Source read
On b59ea35fd8:
wfr_rooms.cpp:412–560,tick()._clickedis read and cleared at the top of every tick. A click counts only when, in that same tick: the beat is the player’s (beats 8–15 of a phrase), the clock is in the beat’s first 0.49 (kBeatWindow), the beat isn’t a gap, and the sprite clicked is the beat’s own bottle. Every other click is dropped with no light, no sound and no log line.scooby-exe.md§Phantom’s Wizard’s Rule Room, “Played” (WP-133’s trace of0x41C3A0): “A click counts only on the player’s beat, inside its window, with the beat’s bottle under the mouse and the button gone down that tick (input+0x20, bit value 4). A press late in a beat, on the wizard’s beats or on a gap is lost.” The port’s rule is the same, line for line.terraglyph.cpp:226–300, the run loop: events are polled once a frame (60 fps), then the ticks owed at 36 a second run. A click sets_clicked; the next tick reads it. A frame that owes no tick keeps the click for the next frame’s tick.terraglyph.cpp:387–415,handleMouse(): a click is dropped before theclick atline when the room script is busy or the inventory blocks input; a busy room class takes it as a skip.WizardsRuleRoomdoesn’t overrideisBusy()(WP-094 removed the hold).magnet_provider.cpp:171,:282: the only readers of a room class’sisNavTargetValid()andnavTargetAt(). The mouse path (handleMouse(),updateHover()) calls neither.wfr_rooms.cpp:303–305: every bottle’s rollover isANIM_CURSOROPEN, whatever the row (WP-094’s recorded deviation: the original tests row 240).sound.cpp:326–330,getClipMillis(): the mixer’sgetElapsedTime()for the song’s channel, the samples handed to the backend plus the milliseconds since. That runs ahead of what’s heard by the backend’s output buffer.
The diagnostic line
The fork tip’s log can’t meet exit criterion 1: no line says a click counted, and a click dropped late in a beat logs nothing past the input layer’s click at. Before Jeff’s replay the session added one level-2 line to tick() (wfr_rooms.cpp), behaviour unchanged:
wfr: a click on the <COLOUR> bottle at beat <beat.ff> (<ms> ms): <what came of it>
where what came of it is counted, late in the beat, lost, the wizard's beat, lost, a gap, lost, the beat already played, lost or not the beat's bottle (<COLOUR>), lost. It’s logged at each of the tick’s own exits, not from a second copy of the rule. The replay runs on that build.
Scope lock
fork: engines/terraglyph/wfr_rooms.cpp
engines/terraglyph/wfr_rooms.h
engines/terraglyph/wfr_check.cpp
engines/terraglyph/terraglyph.cpp (only if the click path is the cause)
engines/terraglyph/sound.cpp, sound.h (only if the clock is the cause)
docs: docs/reference/pre-flight-WP-141-2026-12-03.md
docs/work-packets/WP-141-wfr-bottles-live-clicks.md
docs/work-packets/WORK_INDEX.md
Staged by name; git diff --cached --name-only checked against this list before each commit. Forbidden: game data, logs or captures in any repo; a change to the phrase table, the beat rate or the window without the decompile behind it; a “your turn” cue or any other departure from the original before Jeff’s call.
Risk review
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Fixing the feel and calling it a bug. | med | high | The source read finds the port’s rule equal to the decompile’s. A wider window or a cue is Jeff’s call; the finding goes to him first. |
| The self-test passing while the live game fails. | high (it did) | high | The play lines set the clock by hand. The verdict rests on Jeff’s replay log, with the diagnostic line. |
| The diagnostic line misreporting. | low | med | It’s logged at the tick’s own exits; the self-test’s play wrong bottle, play late press and play not the player's lines drive each exit and are diffed against the baseline. |
| Audio latency (lead 4). | low | med | The log can’t measure what’s heard. The beat lines and Jeff’s click lines show how far off his clicks land; a consistent offset near the window’s edge points here. |
Diagnosis
From Jeff’s replay, 2026-12-03 06:58:59–06:59:34, C:\pcloud\scooby-engine\verification\wp-141-2026-12-03\replay1.log (fork e5cbe578a3, --debugflags=script,input,graphics --debuglevel=2). Seven clicks on bottles, each logged twice: once by the input layer and once by the room.
- The beat window (timing): the cause. Every lost click was lost to the rule, not the path. Phrase 1 (the wizard: RED GREEN BLUE on beats 0–2, by 1.47 s): no click by the player’s beat 8 (6.03 s), so the glass broke at beat 9 (6.53 s). Jeff’s three clicks came after it: RED at beat 11.12, GREEN at 13.49 and BLUE at 15.10, all
a gap, lost. Phrase 2: PINK at beat 23.86, 0.14 of a beat (about 100 ms) before the player’s beat 24:late in the beat, lost. Beat 24 not done, so the glass broke at beat 25. YELLOW at 25.48 thencounted, too late for the phrase. RED at 27.17:a gap, lost. - The click path: ruled out. Every click logged
click at x,y on <n> OBJ_WFR_BOTTLES, and the room’s line then names the bottle. YELLOW at 25.48, the beat’s own bottle in its window,counted. - The cursor: ruled out.
hover <n> OBJ_WFR_BOTTLES, cursor ANIM_CURSOROPENon every bottle Jeff moved over (sprites 3–7), and the arrow off them. - The clock against the music heard: not the cause. The beat lines run 0.72 s apart on the song’s position, as WP-094 measured. The backend’s buffer is 1024 samples (23 ms at 44.1 kHz, per the run’s own header), so the clock leads what’s heard by tens of milliseconds. That moves the window slightly earlier against the music, the side Jeff’s lost PINK click fell on, so a perfect clock wouldn’t have saved it. The log can’t measure the audible offset itself; it’s small against the 355 ms window either way.
Self-test (self-test). Seeded (random_seed=140) against WP-140’s seeded-wp140.log, which ran this tip’s tree (git diff 0ea2574dab b59ea35fd8 is empty). All 16 wizard's rule room check lines match character for character. The only new lines are the 24 diagnostic ones the checks’ presses produce: counted 18, the wizard's beat, lost 3, not the beat's bottle (RED), lost 1, a gap, lost 1, late in the beat, lost 1. (the beat already played, lost isn’t exercised.) The rest of the diff is the noise floor WP-140 measured: the build stamp, two lip-sync lines and the debug-tools check’s millisecond timing.
Verdict
- READY with a named fix
- FINDING: the port matches the original. The rule is the decompile’s (
0x41C3A0, scooby-exe §”Played”), the clicks reach it, the hand shows, and a click on the beat counts. What Jeff met is the original’s difficulty, with nothing on screen or in the speakers to teach it. The finding and Jeff’s call are in WP-141 §Result.
Prepared by: Claude (WP-141 execution session) Date: 2026-12-03
Lessons learned
- Log the verdict, not only the input. WP-087’s log couldn’t say whether a click reached the room, and the tip’s level-2 log still couldn’t say whether one counted. A one-line diagnostic at the tick’s own exits made a single replay by Jeff settle all four leads. When a live symptom is “it didn’t take my input”, add the line that says what became of each input before asking for the run.
- A machine-gun script hides a rhythm rule. WP-094’s live session clicked the bottles every 60 ms through the player’s beats, so it always hit the window, and WP-133’s checks set the clock by hand. Neither could show what a person at their own pace meets. A live check of a timing game needs a person, or a script that clicks once a beat at a human offset.
- A faithful port can still read as a bug. Every rule here is the original’s. What made it feel broken was the missing feedback: a lost click is silent. Report that as a finding with the evidence and leave the departure to Jeff, as WP-140 did.