Skip to content

Commit

Permalink
Fix out-of-bounds vector access in recompute_autotile
Browse files Browse the repository at this point in the history
  • Loading branch information
white-axe committed Sep 15, 2023
1 parent e49e45d commit 8872d28
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/tabs/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,21 @@ impl Tab {
|| (x == 1 && position.0 + 1 == map.data.xsize()))
|| ((y == -1 && position.1 == 0) || (y == 1 && position.1 + 1 == map.data.ysize()));
// Otherwise, we only consider neighbors that are autotiles of the same type
let is_same_autotile = map.data[(
if x == -1 {
position.0 - 1
} else {
position.0 + x as usize
},
if y == -1 {
position.1 - 1
} else {
position.1 + y as usize
},
position.2,
)] / 48
== autotile;
let is_same_autotile = !is_out_of_bounds
&& map.data[(
if x == -1 {
position.0 - 1
} else {
position.0 + x as usize
},
if y == -1 {
position.1 - 1
} else {
position.1 + y as usize
},
position.2,
)] / 48
== autotile;

if is_out_of_bounds || is_same_autotile {
bitfield |= 1
Expand Down

0 comments on commit 8872d28

Please sign in to comment.