From e5a330f56a39fce6605e9e9d2e2b0194621ed58a Mon Sep 17 00:00:00 2001 From: Nathan Nunes Date: Thu, 2 Dec 2021 11:19:56 +0100 Subject: [PATCH] bug fix game_has_error --- game.c | 9 +++++---- game_test_nnunes.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/game.c b/game.c index 54fb9c4..672e13e 100644 --- a/game.c +++ b/game.c @@ -91,14 +91,15 @@ square game_get_state(cgame g, uint i, uint j) { } square game_get_flags(cgame g, uint i, uint j) { - if (g->tab_cell[i][j] >= F_ERROR) { - g->tab_cell[i][j] -= F_ERROR; - if (g->tab_cell[i][j] >= F_LIGHTED) { + square temp = g->tab_cell[i][j]; + if (temp >= F_ERROR) { + temp -= F_ERROR; + if (temp >= F_LIGHTED) { return (F_ERROR | F_LIGHTED); } return (F_ERROR); } - if (g->tab_cell[i][j] >= F_LIGHTED) { + if (temp >= F_LIGHTED) { return (F_LIGHTED); } return (S_BLANK); diff --git a/game_test_nnunes.c b/game_test_nnunes.c index 935aba8..24f823f 100644 --- a/game_test_nnunes.c +++ b/game_test_nnunes.c @@ -344,12 +344,12 @@ bool test_game_is_lighted(void) { /* ************** game_has_error ************** */ bool test_game_has_error(void) { game g = game_new_empty(); - game_set_square(g, 0, 0, S_BLANK | F_ERROR); + game_set_square(g, 0, 0, S_LIGHTBULB | F_ERROR); if ((game_get_flags(g, 0, 0) == F_ERROR) && game_has_error(g, 0, 0)) { game_delete(g); return true; } - game_set_square(g, 0, 0, S_BLANK | F_LIGHTED | F_ERROR); + game_set_square(g, 0, 0, S_LIGHTBULB | F_LIGHTED | F_ERROR); if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) && game_has_error(g, 0, 0)) { game_delete(g);