From 4845f3e913a02417fe7a8d84c6407d40807ec0ec Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 8 Jan 2023 10:05:12 +0000 Subject: [PATCH] Correct RANGECHECK macro in Black Box Lasers are numbered from 0 to nlasers-1 inclusive, so the upper limit should be "<", not "<=". --- blackbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blackbox.c b/blackbox.c index f8d6b27..7918c53 100644 --- a/blackbox.c +++ b/blackbox.c @@ -305,7 +305,7 @@ struct game_state { #define GRID(s,x,y) ((s)->grid[(y)*((s)->w+2) + (x)]) -#define RANGECHECK(s,x) ((x) >= 0 && (x) <= (s)->nlasers) +#define RANGECHECK(s,x) ((x) >= 0 && (x) < (s)->nlasers) /* specify numbers because they must match array indexes. */ enum { DIR_UP = 0, DIR_RIGHT = 1, DIR_DOWN = 2, DIR_LEFT = 3 };