~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Black Box: fix "reveal" button location, explain what's meant by the
[sgt/puzzles]
/
mines.c
diff --git
a/mines.c
b/mines.c
index
f3e216c
..
f962dd6
100644
(file)
--- a/
mines.c
+++ b/
mines.c
@@
-2334,16
+2334,18
@@
static char *game_text_format(game_state *state)
struct game_ui {
int hx, hy, hradius; /* for mouse-down highlights */
struct game_ui {
int hx, hy, hradius; /* for mouse-down highlights */
+ int validradius;
int flash_is_death;
int flash_is_death;
- int deaths;
+ int deaths
, completed
;
};
static game_ui *new_ui(game_state *state)
{
game_ui *ui = snew(game_ui);
ui->hx = ui->hy = -1;
};
static game_ui *new_ui(game_state *state)
{
game_ui *ui = snew(game_ui);
ui->hx = ui->hy = -1;
- ui->hradius = 0;
+ ui->hradius =
ui->validradius =
0;
ui->deaths = 0;
ui->deaths = 0;
+ ui->completed = FALSE;
ui->flash_is_death = FALSE; /* *shrug* */
return ui;
}
ui->flash_is_death = FALSE; /* *shrug* */
return ui;
}
@@
-2357,20
+2359,28
@@
static char *encode_ui(game_ui *ui)
{
char buf[80];
/*
{
char buf[80];
/*
- * The deaths counter needs preserving across a serialisation.
+ * The deaths counter and completion status need preserving
+ * across a serialisation.
*/
sprintf(buf, "D%d", ui->deaths);
*/
sprintf(buf, "D%d", ui->deaths);
+ if (ui->completed)
+ strcat(buf, "C");
return dupstr(buf);
}
static void decode_ui(game_ui *ui, char *encoding)
{
return dupstr(buf);
}
static void decode_ui(game_ui *ui, char *encoding)
{
- sscanf(encoding, "D%d", &ui->deaths);
+ int p;
+ sscanf(encoding, "D%d%n", &ui->deaths, &p);
+ if (encoding[p] == 'C')
+ ui->completed = TRUE;
}
static void game_changed_state(game_ui *ui, game_state *oldstate,
game_state *newstate)
{
}
static void game_changed_state(game_ui *ui, game_state *oldstate,
game_state *newstate)
{
+ if (newstate->won)
+ ui->completed = TRUE;
}
struct game_drawstate {
}
struct game_drawstate {
@@
-2416,6
+2426,10
@@
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
ui->hx = cx;
ui->hy = cy;
ui->hradius = (from->grid[cy*from->w+cx] >= 0 ? 1 : 0);
ui->hx = cx;
ui->hy = cy;
ui->hradius = (from->grid[cy*from->w+cx] >= 0 ? 1 : 0);
+ if (button == LEFT_BUTTON)
+ ui->validradius = ui->hradius;
+ else if (button == MIDDLE_BUTTON)
+ ui->validradius = 1;
return "";
}
return "";
}
@@
-2456,7
+2470,8
@@
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
*/
if (button == LEFT_RELEASE &&
(from->grid[cy * from->w + cx] == -2 ||
*/
if (button == LEFT_RELEASE &&
(from->grid[cy * from->w + cx] == -2 ||
- from->grid[cy * from->w + cx] == -3)) {
+ from->grid[cy * from->w + cx] == -3) &&
+ ui->validradius == 0) {
/* Check if you've killed yourself. */
if (from->layout->mines && from->layout->mines[cy * from->w + cx])
ui->deaths++;
/* Check if you've killed yourself. */
if (from->layout->mines && from->layout->mines[cy * from->w + cx])
ui->deaths++;
@@
-2471,7
+2486,7
@@
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
* surrounding the tile is equal to its mine count, and if
* so then we open all other surrounding squares.
*/
* surrounding the tile is equal to its mine count, and if
* so then we open all other surrounding squares.
*/
- if (from->grid[cy * from->w + cx] > 0) {
+ if (from->grid[cy * from->w + cx] > 0
&& ui->validradius == 1
) {
int dy, dx, n;
/* Count mine markers. */
int dy, dx, n;
/* Count mine markers. */
@@
-3009,9
+3024,9
@@
static int game_wants_statusbar(void)
return TRUE;
}
return TRUE;
}
-static int game_timing_state(game_state *state)
+static int game_timing_state(game_state *state
, game_ui *ui
)
{
{
- if (state->dead || state->won || !state->layout->mines)
+ if (state->dead || state->won ||
ui->completed ||
!state->layout->mines)
return FALSE;
return TRUE;
}
return FALSE;
return TRUE;
}