Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tcod/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def compute_fov(
RuntimeWarning,
stacklevel=2,
)
map_buffer: NDArray[np.bool_] = np.empty(
map_buffer: NDArray[np.bool_] = np.zeros(
transparency.shape,
dtype=[("transparent", bool), ("walkable", bool), ("fov", bool)],
)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_tcod.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def test_tcod_bsp() -> None:
str(bsp)


@pytest.mark.parametrize("pov", [(-1, 0), (0, -1), (3, 0), (0, 5)])
def test_compute_fov_out_of_bounds(pov: tuple[int, int], monkeypatch: pytest.MonkeyPatch) -> None:
transparency = np.ones((3, 5), dtype=bool)
# Model an uninitialized allocation containing stale visible cells.
monkeypatch.setattr(np, "empty", np.ones)
with pytest.warns(RuntimeWarning, match="outside the array"):
visible = tcod.map.compute_fov(transparency, pov)
assert visible.shape == transparency.shape
assert not visible.any()


@pytest.mark.filterwarnings("ignore:Use map.+ to check for this")
@pytest.mark.filterwarnings("ignore:This class may perform poorly")
def test_tcod_map_set_bits() -> None:
Expand Down