unblock_cells()'s early-out is nested inside its own loop and can never fire #99
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder#99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Noticed while reviewing #83. Not a live bug — the affected line cannot execute — but the guard it was meant to be is missing, and the code reads as though it is there.
TerrainGrid.unblock_cells()(entities/terrain/terrain_grid.gd:573):The
if changed_cells.is_empty(): returnis nested inside the loop and inside theis_walkable()branch, so it is unreachable by construction: the loop only runs whenchanged_cellsis non-empty, and the body only runs for a cell that is in it.Its sibling
block_cells()(line 556) has the same early-out in the right place — between the loop and the refresh — where it does real work:So
unblock_cells()currently runs_refresh_connections_around([])and a full_find_largest_region()sweep even when nothing changed — i.e. when every cell handed to it was already unblocked._find_largest_region()flood-fills the whole grid, so an inert call is not free, andunblock_cells()is on thebuilding_removedpath where a demolition UI will call it repeatedly.Fix: dedent the check out of the loop, to match
block_cells().AC:
block_cells().test_unblocking_a_cell_that_was_never_blocked_is_inert(test/unit/test_terrain_navigation.gd:308) still passes — it already covers the behaviour, which is why nothing caught the misplacement.