From a9d3e9a13d17c9036e88b4e4a0df40f210cf06d6 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 16 Apr 2021 09:45:03 -0400 Subject: The Matrix plugin -- Bugfix Off by one errorS in the matrix plugin might even say its the matrix plugin re-loaded Change-Id: I2bc7487615a9e28fcd1d170961fb0b5ee6da6af7 --- apps/plugins/matrix.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/plugins/matrix.c b/apps/plugins/matrix.c index 087a501474..1b2f6d465a 100644 --- a/apps/plugins/matrix.c +++ b/apps/plugins/matrix.c @@ -166,7 +166,7 @@ static void matrix_loop(void) */ /* A little more random now for spaces */ if (rb->rand() % randomness == 1){ - while (i <= ROWS && (matrix[i][j].val == 129 || + while (i < ROWS && (matrix[i][j].val == 129 || matrix[i][j].val == -1)){ i++; randomness--; @@ -179,19 +179,19 @@ static void matrix_loop(void) } - if (i > ROWS) + if (i >= ROWS) break; /* Go to the head of this collumn */ z = i; y = 0; - while (i <= ROWS && (matrix[i][j].val != 129 && + while (i < ROWS && (matrix[i][j].val != 129 && matrix[i][j].val != -1)) { i++; y++; } - if (i > ROWS) { + if (i >= ROWS) { matrix[z][j].val = 129; matrix[ROWS - 1][j].bold = 1; matrix_blit_char(z - 1, j, matrix[z][j].val); @@ -200,7 +200,7 @@ static void matrix_loop(void) matrix[i][j].val = rb->rand() % (MAXCHARS-1) + 1; - if (matrix[i - 1][j].bold == 2) { + if (i > 0 && matrix[i - 1][j].bold == 2) { matrix[i - 1][j].bold = 1; matrix[i][j].bold = 2; } -- cgit v1.2.3