WP-107: Hotspot Magnet TerraGlyph provider — targets, points and the per-room check (Gen 1)

Status: ✅ Done (2026-12-04). The provider is in the fork (#62, dcf2630b21), and so are the character targets of Jeff’s H25 (#66, 37b75bf77e). Every check passes. Jeff accepted the covered targets and empty rooms as listed (§Result). Phase: 5 (polish and accessibility). Depends on:

Unblocks:

Companion EC: EC-017. Pre-flight: required. The packet changes engines/terraglyph/**. The pre-flight is written at the start of execution, as docs/reference/pre-flight-WP-107-<date>.md. Targets generation(s): Gen 1 (Showdown, Phantom). Estimated effort: two to three days. The checks cover 122 rooms, and the click audit covers 32 overrides.


Goal

Write packet 5 of the plan’s sequence: component A, TerraGlyph’s hotspot provider. For the room the player is in, it lists the eligible targets:

It also decides what current is for a press or an OK (plan §5.5: the hover and cursor-at-point rules).

Two self-test checks come with it:

Nothing in play moves or clicks yet; packet 6 does that. With or without Hotspot Assist, a player sees no change.

Background

Scope

In scope

  1. The pre-flight. It covers:
    • the fork pin, and a fork worktree (tools/New-ForkWorktree.ps1);
    • the file names, and the override recount;
    • how the checks enter rooms, wait out openings and open the toolbar (see “For the pre-flight” below);
    • the risks.
  2. Room::getHitBox(sprite). The current step’s polygon box, offset by the sprite’s position, or the union of the current frame’s cels (E37).
  3. The point search and cache (§4.5). Centre first, then 4 px rings: the first on-screen point that hit-tests to the sprite. Cached per sprite and step, and re-checked at every rebuild.
  4. The filter (§4.6), exactly as written, with H7’s kinds and the click gate.
  5. The three target hooks on RoomClass: addNavTargets(), isNavTargetValid() and navTargetAt(). ButtonRoom and Wizard’s Rule implement them, as does any room the audit names.
  6. The click audit. Read every override at the pin, and give each one of these verdicts:
    • Eligible kinds only: nothing to add.
    • Hook added: the class now adds the sprites it acts on.
    • A §6.8 cursor-mode room, recorded: its objects aren’t sprites to select, for example Sign In’s rows, the jigsaw’s places and Maria’s pans. Each is recorded as a §6.8 row.
    • Jeff decides: neither rule settles it. The packet raises it rather than choosing.

    The override list and its verdicts go in the WP’s §Result.

  7. One target per interaction (H22), with its three rules and the collision rule as defined above.
  8. The provider’s entry points:
    • From Appendix B: listTargets(targets, ids), and the getHotspotPositions() and hotspotDirty() overrides.
    • Additions, recorded in Appendix B: targetAt(point) (the hover lookup), and the current decision of §5.5 as one function: the selection’s identity, the cursor and the last warp point give the index, or −1.
  9. The listing hook (§12.7). A self-test check enters every room of both titles through showRoom(), after its opening, and logs every target with its identity, label and point.
    • It fails if:
      • a sprite target’s point doesn’t hit-test to its sprite;
      • a class target’s navTargetAt(point) isn’t its index;
      • a point is off screen;
      • two targets share a point;
      • the open toolbar gives more than one target per click index.
    • It also lists:
      • every eligible sprite that got no point;
      • every room whose list is empty at its start state, with the reason (a busy class, input held, or a redirect).
    • Its asserts, room by room:
      • getHotspotPositions() equals listTargets();
      • hotspotDirty() is false on a second read with no change, and true after showRoom(), a step change, or a hide or show.
  10. The current decision’s cases. In the self-test:
    • a selection with the cursor at its point, and within 2 px;
    • the cursor moved more than 2 px away;
    • hover over a sprite target, and over a class target;
    • hover over nothing.
  11. The per-room reachability check (§5.8), on the listing hook’s output, with everything §5.8 lists:
    • States: each room as it starts, and with the toolbar open where isToolbarHidden() doesn’t hide it, waiting until it’s open.
    • The graph: the press graph from navigate(), and strong connectivity by a forward and a backward search. A failure fails the self-test.
    • The geometric graph: isGeometricConnected(), with each room that needs the fallback named, with its stranded targets.
    • Order: the graph from the reversed list matches edge for edge, by identity.
    • No selection: the smoke grid, edges included.
    • The report: on a pass, one line per room and state, with the target count and whether the fallback ran. On a failure:
      • the room and the state;
      • every target with its identity, label and point;
      • the unreached target and the presses tried.
  12. The self-test passes on both titles, with no new warnings.
    • The baseline: a self-test run at the pin before any change.
    • The comparison: every existing check’s result matches it.
  13. The fork PR against scooby-engine, merged by hand after CI passes. It’s reviewed by tools/Check-ScummvmStyle.ps1 once that tool is on main (open PR #209).
  14. Records:
    • the plan: §11 packet 5 marked done; §5.8 with the list of rooms that need the fallback; §6.8 with any new rows from the audit; Appendix B with the two additions and any other departure; a revision-history row;
    • this WP’s §Result, with the audit and the room results;
    • EC-017;
    • the WORK_INDEX row;
    • the dashboard.json note.

Out of scope

For the pre-flight

Points the pre-flight must settle, from the cold review of this draft:

Exit criteria

  1. Pre-flight. It exists and settles every point above.
  2. getHitBox(), the point search and cache, and the filter implement §4.5 and §4.6 as written.
  3. The hooks. The three target hooks are on RoomClass, and ButtonRoom and Wizard’s Rule implement them. The listing shows the menu rooms’ buttons and Wizard’s Rule’s six bottles as targets.
  4. The click audit is complete. Every override at the pin is listed with its verdict, every “hook added” has its hook, and every “Jeff decides” is decided.
  5. One target per interaction. In every room, the listing hook finds no shared point, no failed hit test, no point off screen, and at most one target per toolbar click index.
  6. Unpointed sprites and empty lists. None, or each is listed with its reason and Jeff’s decision on it.
  7. The current decision’s cases pass, and the getHotspotPositions() and hotspotDirty() asserts pass.
  8. The per-room check passes in every room of both titles, as started and with the toolbar open where it can open. The log names each room that needs the reading-order fallback, and no failing or empty room is accepted silently (H20, §7.6).
  9. The self-test passes on both titles with no new warnings, and every existing check matches the pre-change baseline.
  10. No change in play. No cursor moves, nothing new draws, and no input path changes.
  11. The fork PR is merged against scooby-engine, and the merge commit is recorded.
  12. The records are updated, including §5.8’s fallback rooms and any §6.8 rows. The strict wiki build passes.

Deliverables

Notes

Result

Pre-flight: pre-flight-WP-107-2026-12-01, at fork 837ca576da. Run sheet: EC-017.

Jeff’s decisions are at the end of this section. He decided the first on 2026-12-02: the 15 classes that answer a click on a character add those characters as targets (H25), done in a second fork PR. He decided the second on 2026-12-04: the covered targets and the empty rooms (exit criterion 6) stand as listed.

In the fork (barefootbetters/scummvm#62, two commits, a8badf89d9 and fbcbe7aedd, merged as dcf2630b21), all in engines/terraglyph/:

The character targets (barefootbetters/scummvm#66, one commit, e6154a9f8b, merged as 37b75bf77e), from Jeff’s H25:

The self-test, on both titles, debug build, --debuglevel=11, at 37b75bf77e (logs kept local):

Showdown:
magnet room check current: 2520 checks, 0 failed, 60 on class targets
magnet room check dirty: 57 rooms, 0 failed
magnet room check fallback in 0:
magnet room check: 69 rooms, 3 story passes, 100 states (23 with the toolbar open,
  5 with an item held), 0 failures, 11 unpointed, the slowest list 4 ms
  (ROOM_P06_Stage_Trapdoor), 3428 ms in all
Phantom:
magnet room check current: 2985 checks, 0 failed, 75 on class targets
magnet room check dirty: 55 rooms, 0 failed
magnet room check fallback in 0:
magnet room check: 53 rooms, 4 story passes, 88 states (29 with the toolbar open,
  2 with an item held), 0 failures, 7 unpointed, the slowest list 2 ms
  (ROOM_P10_Throne_Room), 2684 ms in all

At dcf2630b21, before the character targets, the check had 147 listed states, 5,090 current cases and 15 unpointed targets, all passing.

The 15 unpointed targets. An unpointed target is eligible, with a box on screen, but every point of its box hits something else:

Room Target What a click there hits
Sheriff’s office OBJ_P02_TO_P07 the closed door, OBJ_P02_DOOR
Bank OBJ_P13_TO_P16 the closed door, OBJ_P13_DOOR
Bank vault OBJ_P16_TO_P19 the closed door, OBJ_P16_DOOR
Hotel hall OBJ_P17_TO_P20 the closed door, OBJ_P17_HOTEL_HALL_DOOR
Jail OBJ_P07_JAIL_HOTSPOT2 Scooby, standing in front
Throne room (Phantom) OBJ_P10_TO_P19 the throne
Kitchen storage (Phantom) OBJ_P17_TO_P13 the closed door
Secret passage 2 (Phantom) OBJ_P19_TO_P16 Scooby, standing in front

Each is listed in both states where it has one, which makes 15 at dcf2630b21. With the character targets the count is 18:

§3.5’s rule leaves them out: a fully covered sprite isn’t a target. A mouse click there hits the same door, character or blocker. The doors are targets themselves.

The rooms with an empty list as they start (§5.8 has the summary):

Why Rooms
Cursor-mode room (§6.8) Pie Noon
Input held, and the room leaves by itself The chases B1, B4 and C1–C4; the strong boxes SB1–5; Artie’s close-up
Input held to the cap (400 ticks), a set piece Chases C5 and C6
Input held, and a skip leaves The title, Big Head, the credits, the ghost spot (both titles)
Nothing eligible The open safe (a cut scene: it takes every click with the cursor hidden); the cheat room

Arena 2 with the toolbar open isn’t checked: the room leaves for Brad’s game while the van drives in. It passes as started.

The click audit (exit criterion 4). At the pin, bool click(int sprite) override appears 32 times in 28 headers. Each has one of item 6’s verdicts:

The kinds come from the class’s claim (kSprite builds a plain sprite) or from the default path, which makes the names in kCharacters characters (room.cpp:84-90).

# Override Room(s) Acts on Kind Verdict
1 Arena2Room (arena_rooms.h:65) Arena 2 Brad, with the shield character B (H25; progress)
2 BelowBalconyRoom (below_balcony_rooms.h:59) Below the balcony The vines, with the shears requires A
3 BelowBalconyDoorRoom (below_balcony_rooms.h:114) Below the balcony’s door The Jester character B (H25; lines only)
4 BradGameRoom (brad_rooms.h:68) Brad’s three games The armour, pressed and dragged plain C (row exists)
5 CloseupRoom (chase_rooms.h:106) Chase B2’s close-up ICDouble character B (H25; progress)
6 ArtifactRoom (chase_rooms.h:152) The nine jigsaws Any click; pieces follow the pointer plain C (row exists)
7 DiningRoomRoom (dining_rooms.h:44) Dining room Maria character B (H25; progress)
8 RoomOfDoorsRoom (doors_rooms.h:88) Room of doors The Jester (the meeting) character B (H25; progress)
9 DrawbridgeRoom (drawbridge_rooms.h:42) Drawbridge The four flags plain B, hook added
10 EwanRoom (ewan_rooms.h:49) Ewan The four answers requires A
11 RoyalGalleryRoom (gallery_rooms.h:48) Royal gallery The Jester character B (H25; lines only)
12 GardenPlaqueRoom (garden_rooms.h:84) Garden plaque The four buttons requires A
13 KitchenRoom (kitchen_rooms.h:45) Kitchen Ewan character B (H25; progress)
14 MariaGameRoom (maria_rooms.h:64) Maria’s game Items carried and thrown engine C (row exists)
15 WellInMazeRoom (maze_interior_rooms.h:176) Well in the maze The Jester character B (H25; lines only)
16 HedgeMazeRoom (maze_rooms.h:57) Hedge maze The four direction buttons exit A (listed: they have destinations)
17 MazeMapRoom (maze_rooms.h:134) Maze map The four markers clickable A
18 OptionsRoom (options_rooms.h:43) Options The knobs, dragged engine C (row exists)
19 TreasuryRoom (passage_rooms.h:107) Treasury The Princess (the final clue) character B (H25; progress)
20 PostOfficeRoom (post_rooms.h:45) Post office The hole, with the lantern exit A
21 ButtonRoom (room_class.h:108) Main menu, level select, quit, the clue book, Sign In The buttons engine or plain B, hook added (H13)
22 SaloonRoom (saloon_rooms.h:48) Saloon Artie; Shaggy, with the nickel character B (H25; progress)
23 SheriffRoom (sheriff_rooms.h:48) Sheriff The four answers requires A
24 SignInRoom (signin_room.h:44) Sign In Its buttons; the rows by the pointer buttons; rows drawn B (through 21); rows C, see below
25 StageRoom (stage_rooms.h:43) Stage Jenny character B (H25; lines only)
26 RailroadStationRoom (station_rooms.h:45) Railroad station Gummy (arrow, dentures); the donkey character B (H25; progress)
27 Street1Room (story_rooms.h:81) Street 1 The Sheriff (arrow, the sign) character B (H25; progress)
28 ThroneRoomRoom (throne_rooms.h:42) Throne room Jane, with the duster character B (H25; progress)
29 OpenSafeRoom (vault_rooms.h:87) The open safe Every click, taken — A (a cut scene; nothing listed)
30 VaultClockRoom (vault_rooms.h:158) The vault’s clock The hands, dragged plain C (row exists)
31 WizardsRuleRoom (wfr_rooms.h:63) Wizard’s Rule The six bottles plain B, hook added (E45)
32 WizardsBedroomRoom (wizards_bedroom_rooms.h:56) Wizard’s bedroom The wizard (to Wizard’s Rule) character B (H25; progress)

Totals: A 8, B 18 (3 at first and 15 from H25; Sign In’s buttons ride on row 21), C 6 (Sign In’s rows among them), D 0.

Sign In’s rows. They’re drawn sprites the class reads by the pointer, so they aren’t targets. But the up and down buttons move the selection a row at a time, and Play plays the selected player (signin_room.cpp:433-450, :489-490). So with the buttons as targets, Sign In plays in Magnet mode. §6.8’s row now says so.

The D rows, now B (H25). H7 leaves characters out until their click behavior is verified. These 15 overrides are classes that give a character click a meaning. In 11 of them that meaning is progress:

Without those clicks, neither title can be finished in Magnet mode. The other four (the Jester’s lines, three times, and Jenny’s) are flavour.

§4.6 rule 2 says “a class that catches clicks on sprites of other kinds must add them”, which reads as “add them”. H7 says characters come later. The packet raised that conflict, and Jeff settled it with H25: all 15 classes add their characters.

# Exit criterion Met Evidence
1 Pre-flight ✅ The pre-flight above, verdict READY, with each “For the pre-flight” point settled
2 Geometry and the filter ✅ getHitBox(), the ring search and its cache, and §4.6’s rules 1–5, in magnet_provider.cpp. The listing finds no point that misses its target, and none off screen
3 The hooks ✅ The three hooks on RoomClass, and no other. The listing shows the menus’ buttons and the six bottles; the check fails a menu with nothing listed, and Wizard’s Rule with other than six
4 The click audit ✅ The table above: all 32 overrides, each with a verdict and each “hook added” with its hook. The 15 “Jeff decides” rows became hooks with H25 (#66)
5 One target per interaction ✅ No shared point, failed hit test or off-screen point in any room, and at most one toolbar target per index
6 Unpointed sprites and empty lists ✅ Each is listed above with its reason. Jeff accepted them as listed (2026-12-04)
7 current and the overrides ✅ 5,505 current cases pass (5,090 before the character targets). The show-all list equals listTargets() in every state, the hotspotDirty() cases pass in 112 rooms, and the room-entry case passes on each title
8 The per-room check ✅ 162 listed states pass (147 before the character targets). No room needs the fallback. Every failing or empty room is named
9 Self-test on both titles ✅ For each fork PR, every check line matches the baseline at its pin (837ca576da, then c1f2825762; Showdown 2,220 lines, Phantom 2,004), except lines that differ between any two runs. Those are timings and random draws: Phantom’s clips, positions, and the drawbridge’s, Ewan’s and Maria’s draws; in #66’s run, also one of Showdown’s bank clock times, missing from its 80 draws. All of them are logged before the new check runs. Warnings: none new in the build; logs Showdown 0, Phantom 18, as at the baseline
10 No change in play ✅ Only the check calls the provider. getHotspotPositions() is called by Engine::drawHotspots() alone, which TerraGlyph never calls. showRoom() only resets the point cache and counts entries
11 The fork PR ✅ #62 merged as dcf2630b21, and #66 as 37b75bf77e. tools/Check-ScummvmStyle.ps1 isn’t on main yet (open PR #209), so it wasn’t run
12 Records ✅ Plan §4.5, §5.8, §6.8, §11, §14.3, Appendix B and the revision history; this section; EC-017; WORK_INDEX; dashboard.json. The strict wiki build passes

The review. A cold review read the commit against the plan. The provider held: the filter matches handleMouse()’s gate, the ring search and toolbar merge are right, and nothing in play changes. Fixed in the second commit:

Recorded, not changed:

For the next packets:

Jeff’s decisions:

  1. The character clicks (the audit’s D rows). Decided 2026-12-02: yes, all 15 (H25 in the plan’s §10.4). Each class adds its characters through its hook, as §4.6 rule 2 reads. Characters that no class answers stay out, as H7 has it. Done in #66.
  2. The unpointed targets and the empty rooms above. Decided 2026-12-04: accepted as listed. Each matches what a mouse click there does, since it hits the door, character or blocker in front, or the room holds input or leaves by itself.