Skip to content

Commit 6c3c0ba

Browse files
authored
Fix FOV bottom-right bounds checking
Fixes issue #131. The old bounds checking code used the inequalities `p.x < map.width - 1` and `p.y < map.height - 1`. This means that when p.x is 79, or p.y is 49, visibility is never checked, even though there actually are tiles in those locations. Removing the `- 1` part from each inequality allows these tiles to be checked.
1 parent 48fe3d5 commit 6c3c0ba

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

chapter-05-fov/src/visibility_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<'a> System<'a> for VisibilitySystem {
1919
viewshed.dirty = false;
2020
viewshed.visible_tiles.clear();
2121
viewshed.visible_tiles = field_of_view(Point::new(pos.x, pos.y), viewshed.range, &*map);
22-
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width-1 && p.y >= 0 && p.y < map.height-1 );
22+
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width && p.y >= 0 && p.y < map.height );
2323

2424
// If this is the player, reveal what they can see
2525
let _p : Option<&Player> = player.get(ent);

0 commit comments

Comments
 (0)