Correct RANGECHECK macro in Black Box

Lasers are numbered from 0 to nlasers-1 inclusive, so the upper limit
should be "<", not "<=".
This commit is contained in:
Ben Harris
2023-01-08 10:05:12 +00:00
parent 952ef8ca56
commit 4845f3e913

View File

@ -305,7 +305,7 @@ struct game_state {
#define GRID(s,x,y) ((s)->grid[(y)*((s)->w+2) + (x)]) #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. */ /* specify numbers because they must match array indexes. */
enum { DIR_UP = 0, DIR_RIGHT = 1, DIR_DOWN = 2, DIR_LEFT = 3 }; enum { DIR_UP = 0, DIR_RIGHT = 1, DIR_DOWN = 2, DIR_LEFT = 3 };