WP-098: The arena pile check’s flake (Gen 1)

Status: ✅ Done (2026-11-28). Fork PR barefootbetters/scummvm#21 merged on 2026-11-28 (merge commit b24b8b25b3). Phase: 5 (self-test hygiene) Depends on: WP-069 ✅ (the second arena and its pile check) Companion EC: none (inline checklist under Exit criteria) Pre-flight: pre-flight-WP-098-2026-11-28. Required: the packet modifies engines/terraglyph/**. Targets generation(s): Gen 1, Phantom of the Knight only. Estimated effort: An hour


Goal

Make the arena pile check’s level-0 line deterministic. On unchanged code it printed to - in some runs and to ROOM_Brad_SPOOKY in others. WP-094 and WP-095 noted it as a known flake.

The cause (log, then probe)

The check enters the second arena at each level and waits for the room’s own click on the pile to finish. It then seeds the random source with 1, clicks the pile and waits for the room change.

The log of a failing run (WP-094’s second self-test) shows exactly this:

  1. The entry click at tick 0.
  2. Brad.Armor.2 during it.
  3. The pile at rest at tick 36.
  4. One click at tick 37, its event ignored.
  5. No room change in the 2000 ticks after.

The game is right. A rattle swallowing a click made while it plays is the original’s behaviour (WP-069). Only the check needed fixing. The earlier guess, in WP-094, that the flake came from waiting on a clip’s playback was wrong.

Scope

In scope: fork arena_check.cpp, the pile check’s wait; this packet, its pre-flight, a pointer in WP-094 and the index row.

Out of scope: the room (arena_rooms.cpp), which matches the original.

Exit criteria

  1. Reproduced and fixed. A probe seeds the random source before entry. Seeds that make the old wait lose the click reach Brad’s game with the new wait.
  2. Self-test. The pile line reads ROOM_Brad_SPOOKY at level 0, and the rest matches the WP-097 run except for the per-run random keys. No new warnings.
  3. Process. The fork PR against scooby-engine is open (merged later the same day).

Result

Evidence labels: log (a self-test’s debug log), self-test, probe (a temporary check this session ran and didn’t commit).

Deliverables