havoc-remaster/docs/LEVEL_NOTES.md
pyr0ball 763509e4bc feat: set up Linux Ghidra pipeline, find and patch FPS-coupling and pause-hang bugs
Ghidra decompilation environment stood up on Linux (headless, no sudo): JDK 21 +
Ghidra 12.1.2 in ~/tools, reusing the existing analyzed project at
tools/ghidra_project/ from the prior Windows session instead of starting fresh.

FPS-coupling investigation: traced the main game loop's per-frame path and found
the real root cause - compute_frame_delta_ticks_60hz_min1_clamp (0x4092D0) computes
correct delta-time from timeGetTime(), but clamps the minimum return value to 1 tick
even when zero ticks truly elapsed, causing simulation speed to scale with framerate
above 60fps. First patch attempt (NOP the clamp) crashed on level load because the
shared delta value has 203 read sites across 40+ functions and only 2 were checked
for zero-safety; reverted and archived as a documented lesson. The corrected fix
(busy-wait instead of lying) is designed but not yet built.

Pause-loop hang fixed: the pause command handler blocks the Windows message queue
in a tight GetAsyncKeyState polling loop (found while locating the cheat code
handler), which trips modern Windows' "Not Responding" hang detection if left
paused too long, permanently disconnecting input. Patched (HAVOC_NOCD_PAUSEFIX_v1.EXE)
to pump one message per loop iteration via the game's own existing message-drain
function; confirmed fixed by play-testing, including the related "alt-tab while
paused resets to menu" symptom. A separate "alt-tab while not paused" reset symptom
remains open.

New tracking docs: docs/FUNCTIONS.md (function-by-function RE progress),
docs/PATCH_VERSIONS.md (binary patch version log), docs/LEVEL_NOTES.md (level/AI
design quirks for the Remaster variant). Extended docs/PATCHES.md and
docs/METHODOLOGY.md with full discovery narratives including dead ends.
2026-07-03 22:32:28 -07:00

2 KiB

Level / AI Design Notes

Running list of level-specific design quirks and idiosyncrasies noticed during play-testing, separate from docs/PATCHES.md (binary bugs/fixes) and docs/FUNCTIONS.md (RE progress). These are candidates for the Remaster variant's "bug fixes" bucket (see docs/HANDOFF.md section 1) while staying intact in the Faithful 1:1 variant. Nothing here has been reverse-engineered yet -- these are gameplay observations to revisit once the AI/level-loader code (MAP/STUF/LAND, enemy AI) gets decompiled.

World 1 (Badlands), first level

Unreachable stranded drop from a flying enemy. One of the final flying enemies in this level has a patrol/movement pattern that can carry it over a tall piece of terrain. If it isn't killed early -- before most other enemies in that area -- it can end up dying while positioned over that tall terrain, and its item drop can land somewhere physically unreachable (stuck on/above terrain the player can't get to).

  • Not a crash or technical bug -- a level/AI design issue remembered from the original game, confirmed again during a 2026-07-03 playthrough.
  • Workaround (as originally learned): kill this specific enemy early, before it can drift into the problem area.
  • Remaster candidate: once STUF<lvl>.DAT (entity placement) and the AI/pathing code are decompiled, this could be fixed by adjusting the enemy's patrol bounds, or by making drops from airborne kills fall to the nearest reachable ground instead of wherever the enemy died.
  • Not yet reverse-engineered -- no addresses, no code path identified. Revisit once AI/level loading is a priority (see docs/HANDOFF.md section 7, items 4-5).

Template for new entries

## World <N> (<name>), level <N>

**Short description.**  Longer explanation of the quirk, when it happens, how to reproduce
or avoid it.

- Bug or design quirk?
- Reproduction notes / workaround if known.
- Remaster candidate? What would the fix look like.
- RE status: not yet investigated / found at VA 0x... / etc.