#define ENCODE(upper,title,lower) #lower
#define CONFIG(upper,title,lower) ":" #title
enum { DIFFLIST(ENUM) DIFFCOUNT };
-static char const *const loopy_diffnames[] = { DIFFLIST(TITLE) };
+/* static char const *const loopy_diffnames[] = { DIFFLIST(TITLE) }; */
static char const loopy_diffchars[] = DIFFLIST(ENCODE);
#define DIFFCONFIG DIFFLIST(CONFIG)
#endif
}
-static char *new_fullyclued_board(game_params *params, random_state *rs)
+static void add_full_clues(game_state *state, game_params *params,
+ random_state *rs)
{
char *clues;
char *board;
int i, j, a, b, c;
- game_state s;
- game_state *state = &s;
int board_area = SQUARE_COUNT(params);
int t;
#define SCORE_DISTANCE 1
board = snewn(board_area, char);
- clues = snewn(board_area, char);
-
- state->h = params->h;
- state->w = params->w;
- state->clues = clues;
+ clues = state->clues;
/* Make a board */
memset(board, SQUARE_UNLIT, board_area);
}
sfree(board);
- return clues;
}
static solver_state *solve_game_rec(const solver_state *sstate, int diff);
state->h = params->h;
state->w = params->w;
+ state->clues = snewn(SQUARE_COUNT(params), char);
state->hl = snewn(HL_COUNT(params), char);
state->vl = snewn(VL_COUNT(params), char);
* preventing games smaller than 4x4 seems to stop this happening */
do {
- state->clues = new_fullyclued_board(params, rs);
+ add_full_clues(state, params, rs);
} while (!game_has_unique_soln(state, params->diff));
state_new = remove_clues(state, rs, params->diff);
}
}
- /* No point in doing sums like that if they're going to be wrong */
- assert(strlen(ret) == (size_t)len);
+ /*
+ * Ensure we haven't overrun the buffer we allocated (which we
+ * really shouldn't have, since we computed its maximum size).
+ * Note that this assert is <= rather than ==, because the
+ * solver is permitted to produce an incomplete solution in
+ * which case the buffer will be only partially used.
+ */
+ assert(strlen(ret) <= (size_t)len);
return ret;
}
break;
case DLINE_DL:
case DLINE_DR:
- if (j <= (state)->h && BELOW_DOT(state, i, j) == line_old) {
+ if (j < (state)->h && BELOW_DOT(state, i, j) == line_old) {
LV_BELOW_DOT(state, i, j) = line_new;
retval = TRUE;
}
case DLINE_UR:
case DLINE_DR:
case DLINE_HORIZ:
- if (i <= (state)->w && RIGHTOF_DOT(state, i, j) == line_old) {
+ if (i < (state)->w && RIGHTOF_DOT(state, i, j) == line_old) {
LV_RIGHTOF_DOT(state, i, j) = line_new;
retval = TRUE;
}
break;
case DLINE_VERT:
- if (j <= (state)->h && BELOW_DOT(state, i, j) == line_old) {
+ if (j < (state)->h && BELOW_DOT(state, i, j) == line_old) {
LV_BELOW_DOT(state, i, j) = line_new;
retval = TRUE;
}
ds->linewidth = max(1,tilesize/16);
}
-static float *game_colours(frontend *fe, game_state *state, int *ncolours)
+static float *game_colours(frontend *fe, int *ncolours)
{
float *ret = snewn(4 * NCOLOURS, float);
return 0.0F;
}
-static int game_wants_statusbar(void)
-{
- return FALSE;
-}
-
static int game_timing_state(game_state *state, game_ui *ui)
{
return TRUE;
game_anim_length,
game_flash_length,
TRUE, FALSE, game_print_size, game_print,
- game_wants_statusbar,
+ FALSE, /* wants_statusbar */
FALSE, game_timing_state,
- 0, /* mouse_priorities */
+ 0, /* flags */
};