ref: 4845f3e913a02417fe7a8d84c6407d40807ec0ec
parent: 952ef8ca565d803da1134466358bd85683a489a3
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Jan 8 05:05:12 EST 2023
Correct RANGECHECK macro in Black Box Lasers are numbered from 0 to nlasers-1 inclusive, so the upper limit should be "<", not "<=".
--- a/blackbox.c
+++ b/blackbox.c
@@ -305,7 +305,7 @@
#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 };