bug fix game_has_error
This commit is contained in:
1 parent
73b327e41a
commit
e5a330f56a
2 files changed
+7
-6
No files matched your search
@@ -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
@@ -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);
|
||||||
|
|||||||
Reference in new issue
Block a user