add bounds check for bpos
This commit is contained in:
parent
74b430a498
commit
fdbc4ad83d
|
@ -213,6 +213,10 @@ impl State {
|
||||||
Cell::Box | Cell::Goal(true) => {
|
Cell::Box | Cell::Goal(true) => {
|
||||||
let bpos = dpos + pos;
|
let bpos = dpos + pos;
|
||||||
|
|
||||||
|
if ((bpos.1 * self.lvl.size.0) + bpos.0) as usize >= self.lvl.map.len() {
|
||||||
|
return Err(Error::BadMove(bpos));
|
||||||
|
}
|
||||||
|
|
||||||
match self.lvl[bpos] {
|
match self.lvl[bpos] {
|
||||||
Cell::None => {
|
Cell::None => {
|
||||||
self.toggle_box(dpos);
|
self.toggle_box(dpos);
|
||||||
|
|
Loading…
Reference in New Issue