Dedent unblock_cells()'s unreachable early-out #105

Merged
liamjd merged 1 commit from 99-unblock-cells-early-out into main 2026-09-17 07:59:25 +01:00
Owner

Fixes #99.

unblock_cells()'s if changed_cells.is_empty(): return was nested inside the loop and inside the is_walkable() branch, so it could never fire — the loop only runs when changed_cells is non-empty. Dedented it to sit between the loop and the refresh, mirroring block_cells().

Effect: unblocking cells that were never blocked no longer runs _refresh_connections_around([]) plus a full _find_largest_region() flood fill. That path is hit by building_removed, so a demolition UI calling it repeatedly gets the saving.

Verification

  • test_terrain_navigation — 23/23 pass, including test_unblocking_a_cell_that_was_never_blocked_is_inert (the AC test).
  • Full suite headless — 451 tests, 450 passing, 1 pre-existing pending (test_what_a_cancelled_child_should_do_to_its_parent_is_undecided, tracked as #85).

No visual check needed; this is navigation-graph logic only.

🤖 Generated with Claude Code

Fixes #99. `unblock_cells()`'s `if changed_cells.is_empty(): return` was nested inside the loop *and* inside the `is_walkable()` branch, so it could never fire — the loop only runs when `changed_cells` is non-empty. Dedented it to sit between the loop and the refresh, mirroring `block_cells()`. Effect: unblocking cells that were never blocked no longer runs `_refresh_connections_around([])` plus a full `_find_largest_region()` flood fill. That path is hit by `building_removed`, so a demolition UI calling it repeatedly gets the saving. ## Verification - `test_terrain_navigation` — 23/23 pass, including `test_unblocking_a_cell_that_was_never_blocked_is_inert` (the AC test). - Full suite headless — 451 tests, 450 passing, 1 pre-existing pending (`test_what_a_cancelled_child_should_do_to_its_parent_is_undecided`, tracked as #85). No visual check needed; this is navigation-graph logic only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The `if changed_cells.is_empty(): return` sat inside the loop and inside
the is_walkable() branch, making it unreachable: the loop only runs when
changed_cells is non-empty. So unblock_cells() ran _refresh_connections_around([])
and a full _find_largest_region() flood fill even when nothing changed.

Moved between the loop and the refresh, mirroring block_cells().

Closes #99

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
liamjd merged commit fb4d092eec into main 2026-09-17 07:59:25 +01:00
liamjd deleted branch 99-unblock-cells-early-out 2026-09-17 07:59:32 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder!105
No description provided.