From 470d00bbe10ceb033d3ebffc72aa3b7e35888224 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Tue, 21 Nov 2023 21:27:26 +0100 Subject: [PATCH] git fix underflow bug --- src/level.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/level.rs b/src/level.rs index 6c62ddb..1a2b097 100644 --- a/src/level.rs +++ b/src/level.rs @@ -80,15 +80,15 @@ impl Level { break; } } - for x_r in (max(x - 2, 0)..x).rev() { - self.discovered[x_r][y] = true; - if self.structure[x_r][y] == LevelElement::Wall { + for x_r in (max(x, 2)..x + 2).rev() { + self.discovered[x_r - 2][y] = true; + if self.structure[x_r - 2][y] == LevelElement::Wall { break; } } - for y_r in (max(y - 2, 0)..y).rev() { - self.discovered[x][y_r] = true; - if self.structure[x][y_r] == LevelElement::Wall { + for y_r in (max(y, 2)..y + 2).rev() { + self.discovered[x][y_r - 2] = true; + if self.structure[x][y_r - 2] == LevelElement::Wall { break; } }