Skip to content

Commit 47ab346

Browse files
committed
Apply visibility bounds check fix to all chapters
It didn't occur to me that the bounds check problem occurred in nearly every chapter after 5; this commit propagates that fix to every chapter. Unfortunately, I have not read any further than chapter 5 yet, so I don't know for certain that this issue even exists in later chapters. I apologize in advance if this fix is inappropriate for the rest of the book.
1 parent 6c3c0ba commit 47ab346

63 files changed

Lines changed: 63 additions & 63 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chapter-06-monsters/src/visibility_system.rs

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

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

chapter-07-damage/src/visibility_system.rs

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

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

chapter-08-ui/src/visibility_system.rs

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

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

chapter-09-items/src/visibility_system.rs

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

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

chapter-10-ranged/src/visibility_system.rs

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

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

chapter-11-loadsave/src/visibility_system.rs

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

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

chapter-12-delvingdeeper/src/visibility_system.rs

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

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

chapter-13-difficulty/src/visibility_system.rs

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

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

chapter-14-gear/src/visibility_system.rs

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

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

chapter-16-nicewalls/src/visibility_system.rs

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

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

0 commit comments

Comments
 (0)