From b89fe78e631aca50e83333f7d2e6aa3a7c93ddc6 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 3 Mar 2019 17:21:43 -0500 Subject: fix crash when no rotation is possible --- cetris.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cetris.c b/cetris.c index e2c6cfb..65c32d0 100644 --- a/cetris.c +++ b/cetris.c @@ -210,7 +210,7 @@ void rotate_matrix(struct cetris_game* g, int clockwise) { } int set_current = 0; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 5; i++) { vec2 kick = (vec2){0, 0}; if (i > 0) { if (g->current.t == I) kick = srs_wall_kicks_i[wall_kick][i - 1]; @@ -370,21 +370,17 @@ void set_constants(struct cetris_game* g) { } } -void reset_slot(slot* s) { - s->occupied = 0; - s->constant = 0; - s->remove_tick = 0; -} - void wipe_board(struct cetris_game* g) { int lines_cleared = 0; for (int y = 0; y < BOARD_Y; y++) { int clear_line = 1; for (int x = 0; x < BOARD_X; x++) { - if (!g->board[x][y].constant) reset_slot(&g->board[x][y]); + if (!g->board[x][y].constant) { + memset(&g->board[x][y], 0, sizeof(slot)); + } if (g->board[x][y].remove_tick && g->board[x][y].remove_tick <= g->tick) { - reset_slot(&g->board[x][y]); + memset(&g->board[x][y], 0, sizeof(slot)); for (int s = y - 1; s >= 0; s--) { g->board[x][s + 1] = g->board[x][s]; } -- cgit v1.2.3-101-g0448