return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
/*
* Lower limit on grid size: each dimension must be at least 3.
* _have_ to have a gap somewhere which you can't determine the
* position of.
*/
- if (params->w <= 2 || params->h <= 2)
+ if (full && params->unique && (params->w <= 2 || params->h <= 2))
return "Width and height must both be greater than two";
if (params->n > params->w * params->h - 9)
return "Too many mines for grid size";
struct game_ui {
int hx, hy, hradius; /* for mouse-down highlights */
+ int validradius;
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;
- ui->hradius = 0;
+ ui->hradius = ui->validradius = 0;
ui->deaths = 0;
+ ui->completed = FALSE;
ui->flash_is_death = FALSE; /* *shrug* */
return ui;
}
{
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);
+ if (ui->completed)
+ strcat(buf, "C");
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)
{
+ if (newstate->won)
+ ui->completed = TRUE;
}
struct game_drawstate {
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 "";
}
*/
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++;
* 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. */
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;
}
* $ ./mineobfusc 9x9:4,4,004000007c00010022080
* 9x9:4,4,mb071b49fbd1cb6a0d5868
*
- * gcc -DSTANDALONE_OBFUSCATOR -o mineobfusc mines.c malloc.c random.c tree234.c
+ * gcc -DSTANDALONE_OBFUSCATOR -o mineobfusc mines.c malloc.c random.c tree234.c misc.c
*/
#include <stdarg.h>
void start_draw(frontend *fe) {}
void draw_update(frontend *fe, int x, int y, int w, int h) {}
void end_draw(frontend *fe) {}
-void midend_supersede_game_desc(midend_data *me, char *desc) {}
+void midend_supersede_game_desc(midend_data *me, char *desc, char *privdesc) {}
void status_bar(frontend *fe, char *text) {}
void fatal(char *fmt, ...)
{
game_params *p;
game_state *s;
- int recurse = TRUE;
char *id = NULL, *desc, *err;
int y, x;
- int grade = FALSE;
while (--argc > 0) {
char *p = *++argv;
if (*p == '-') {
- fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0]);
+ fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
return 1;
} else {
id = p;