Skip to content

Commit 8830b9d

Browse files
committed
Apply visibility bounds check fix to all missed locations
My initial application of sed was to too narrow a glob; now I think all instances are replaced
1 parent 47ab346 commit 8830b9d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

book/src/chapter_22.md

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

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

book/src/chapter_5.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'a> System<'a> for VisibilitySystem {
247247
for (viewshed,pos) in (&mut viewshed, &pos).join() {
248248
viewshed.visible_tiles.clear();
249249
viewshed.visible_tiles = field_of_view(Point::new(pos.x, pos.y), viewshed.range, &*map);
250-
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width-1 && p.y >= 0 && p.y < map.height-1 );
250+
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width && p.y >= 0 && p.y < map.height );
251251
}
252252
}
253253
}
@@ -386,7 +386,7 @@ impl<'a> System<'a> for VisibilitySystem {
386386
for (ent,viewshed,pos) in (&entities, &mut viewshed, &pos).join() {
387387
viewshed.visible_tiles.clear();
388388
viewshed.visible_tiles = field_of_view(Point::new(pos.x, pos.y), viewshed.range, &*map);
389-
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width-1 && p.y >= 0 && p.y < map.height-1 );
389+
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width && p.y >= 0 && p.y < map.height );
390390

391391
// If this is the player, reveal what they can see
392392
let p : Option<&Player> = player.get(ent);
@@ -468,7 +468,7 @@ if viewshed.dirty {
468468
viewshed.dirty = false;
469469
viewshed.visible_tiles.clear();
470470
viewshed.visible_tiles = field_of_view(Point::new(pos.x, pos.y), viewshed.range, &*map);
471-
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width-1 && p.y >= 0 && p.y < map.height-1 );
471+
viewshed.visible_tiles.retain(|p| p.x >= 0 && p.x < map.width && p.y >= 0 && p.y < map.height );
472472

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

chapter-73-systems/src/systems/visibility_system.rs

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

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

chapter-74-darkcity/src/systems/visibility_system.rs

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

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

0 commit comments

Comments
 (0)