From 32d18c1f78488054c5f570746b9b1b00b168cc30 Mon Sep 17 00:00:00 2001 From: girst Date: Thu, 7 Sep 2017 18:15:19 +0200 Subject: [PATCH] add questionmark key allows to place question marks by hitting `?'. `-q' still sets what flags can be set with `i'. --- mines_2017.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mines_2017.c b/mines_2017.c index 3d00d97..f032f61 100644 --- a/mines_2017.c +++ b/mines_2017.c @@ -72,6 +72,7 @@ void show_minefield (int); int get_neighbours (int, int, int); int uncover_square (int, int); void flag_square (int, int); +void quesm_square (int, int); int choord_square (int, int); struct minecell** alloc_array (int, int); void free_field (); @@ -289,6 +290,7 @@ newgame: f.p[0] < 0 || f.p[1] >= f.h) break; /*out of bound*/ /* fallthrough */ case 'i': flag_square (f.p[0], f.p[1]); break; + case '?':quesm_square (f.p[0], f.p[1]); break; #define BM BIG_MOVE case 'h': set_cursor_pos (f.p[0], f.p[1]-1 ); break; case 'j': set_cursor_pos (f.p[0]+1, f.p[1] ); break; @@ -425,6 +427,7 @@ int choord_square (int line, int col) { int uncover_square (int l, int c) { f.c[l][c].o = OPENED; + f.c[l][c].f = NOFLAG; /* must not be QUESM, otherwise rendering issues */ partial_show_minefield (l, c, NORMAL); if (f.c[l][c].m) { @@ -463,6 +466,15 @@ void flag_square (int l, int c) { printf ("[%03d]", f.f); } +void quesm_square (int l, int c) { + /* toggle question mark / none. won't turn flags into question marks. + unlike flag_square, this function doesn't respect `-q'. */ + if (f.c[l][c].o != CLOSED) return; + else if (f.c[l][c].f == NOFLAG) f.c[l][c].f = QUESM; + else if (f.c[l][c].f == QUESM) f.c[l][c].f = NOFLAG; + partial_show_minefield (l, c, NORMAL); +} + void fill_minefield (int l, int c) { srand (time(0)); int mines_set = f.m; -- 2.39.3