~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Stop failing assertions when we encounter an insoluble puzzle.
[sgt/puzzles]
/
filling.c
diff --git
a/filling.c
b/filling.c
index
6f6c6c3
..
b05ab49
100644
(file)
--- a/
filling.c
+++ b/
filling.c
@@
-299,7
+299,7
@@
static game_state *new_game(midend *, game_params *, char *);
static void free_game(game_state *);
/* generate a random valid board; uses validate_board. */
static void free_game(game_state *);
/* generate a random valid board; uses validate_board. */
-void make_board(int *board, int w, int h, random_state *rs) {
+
static
void make_board(int *board, int w, int h, random_state *rs) {
int *dsf;
const unsigned int sz = w * h;
int *dsf;
const unsigned int sz = w * h;
@@
-907,7
+907,7
@@
static void game_changed_state(game_ui *ui, game_state *oldstate,
#define PREFERRED_TILE_SIZE 32
#define TILE_SIZE (ds->tilesize)
#define BORDER (TILE_SIZE / 2)
#define PREFERRED_TILE_SIZE 32
#define TILE_SIZE (ds->tilesize)
#define BORDER (TILE_SIZE / 2)
-#define BORDER_WIDTH (
TILE_SIZE / 32
)
+#define BORDER_WIDTH (
max(TILE_SIZE / 32, 1)
)
struct game_drawstate {
struct game_params params;
struct game_drawstate {
struct game_params params;
@@
-974,9
+974,9
@@
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
static game_state *execute_move(game_state *state, char *move)
{
game_state *new_state;
static game_state *execute_move(game_state *state, char *move)
{
game_state *new_state;
+ const int sz = state->shared->params.w * state->shared->params.h;
if (*move == 's') {
if (*move == 's') {
- const int sz = state->shared->params.w * state->shared->params.h;
int i = 0;
new_state = dup_game(state);
for (++move; i < sz; ++i) new_state->board[i] = move[i] - '0';
int i = 0;
new_state = dup_game(state);
for (++move; i < sz; ++i) new_state->board[i] = move[i] - '0';
@@
-991,6
+991,7
@@
static game_state *execute_move(game_state *state, char *move)
value = strtol(move, &endptr, 0);
if (endptr == move) return NULL;
if (*endptr != '\0') return NULL;
value = strtol(move, &endptr, 0);
if (endptr == move) return NULL;
if (*endptr != '\0') return NULL;
+ if (i < 0 || i >= sz || value < 0 || value > 9) return NULL;
new_state = dup_game(state);
new_state->board[i] = value;
}
new_state = dup_game(state);
new_state->board[i] = value;
}
@@
-1388,7
+1389,8
@@
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
* should start by drawing a big background-colour rectangle
* covering the whole window.
*/
* should start by drawing a big background-colour rectangle
* covering the whole window.
*/
- draw_rect(dr, 0, 0, 10*ds->tilesize, 10*ds->tilesize, COL_BACKGROUND);
+ draw_rect(dr, 0, 0, w*TILE_SIZE + 2*BORDER, h*TILE_SIZE + 2*BORDER,
+ COL_BACKGROUND);
/*
* Smaller black rectangle which is the main grid.
/*
* Smaller black rectangle which is the main grid.
@@
-1398,6
+1400,8
@@
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
h*TILE_SIZE + 2*BORDER_WIDTH + 1,
COL_GRID);
h*TILE_SIZE + 2*BORDER_WIDTH + 1,
COL_GRID);
+ draw_update(dr, 0, 0, w*TILE_SIZE + 2*BORDER, h*TILE_SIZE + 2*BORDER);
+
ds->started = TRUE;
}
ds->started = TRUE;
}
@@
-1524,7
+1528,7
@@
const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
-
0,
/* flags */
+
REQUIRE_NUMPAD,
/* flags */
};
#ifdef STANDALONE_SOLVER /* solver? hah! */
};
#ifdef STANDALONE_SOLVER /* solver? hah! */