This change does not have any functional impact. Instead, it separates
dungeon-dependent data from the vision algorithm, making the
`DoVision()` function suitable to be called from the test case, which
comes next.
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
This commit fixes a very subtle case where players could see through
diagonally adjacent tiles. The bug was introduced in the recent
commit: 88d0cb749f ("lighting: fix long-standing issue with
invisible objects (#7901)").
The following 2D grid illustrates the bug:
```
. . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . .
# # # # # # #
# . . . . . . . #
# . . . . . . . #
# . . . . . . . #
# . . . x . . . #
# . . . . . . . #
# . . . . . . . #
# . . . . . . . #
# # # # # # #
. . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . .
```
Where 'x' represents the player, surrounded by walls with diagonally
adjacent corners, and '.' represents visible tiles reached by vision
rays cast from the player's position. The figure clearly shows that
rays "leak" through corners.
The fix is quite simple: stop traversing the ray if "light" can't pass
through the adjacent tiles or if the ray hits a tile that doesn't
allow "light" to pass through. Previously, the ray continued to be
traversed even when the "light" couldn't pass through the adjacent
tiles, which is incorrect and leads to the described issue.
Here is the Python script which simulates the bug and the fix:
https://gist.github.com/rouming/8a24789fd5d18c36c40e2b4925915d16
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>