bug fix game_has_error

This commit is contained in:
Nathan Nunes committed 2021-12-02 11:19:56 +01:00
1 parent 73b327e41a
commit e5a330f56a
2 files changed
+7 -6

No files matched your search

+5 -4
View File
@@ -91,14 +91,15 @@ square game_get_state(cgame g, uint i, uint j) {
} }
square game_get_flags(cgame g, uint i, uint j) { square game_get_flags(cgame g, uint i, uint j) {
if (g->tab_cell[i][j] >= F_ERROR) { square temp = g->tab_cell[i][j];
g->tab_cell[i][j] -= F_ERROR; if (temp >= F_ERROR) {
if (g->tab_cell[i][j] >= F_LIGHTED) { temp -= F_ERROR;
if (temp >= F_LIGHTED) {
return (F_ERROR | F_LIGHTED); return (F_ERROR | F_LIGHTED);
} }
return (F_ERROR); return (F_ERROR);
} }
if (g->tab_cell[i][j] >= F_LIGHTED) { if (temp >= F_LIGHTED) {
return (F_LIGHTED); return (F_LIGHTED);
} }
return (S_BLANK); return (S_BLANK);
+2 -2
View File
@@ -344,12 +344,12 @@ bool test_game_is_lighted(void) {
/* ************** game_has_error ************** */ /* ************** game_has_error ************** */
bool test_game_has_error(void) { bool test_game_has_error(void) {
game g = game_new_empty(); 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)) { if ((game_get_flags(g, 0, 0) == F_ERROR) && game_has_error(g, 0, 0)) {
game_delete(g); game_delete(g);
return true; 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)) && if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) &&
game_has_error(g, 0, 0)) { game_has_error(g, 0, 0)) {
game_delete(g); game_delete(g);