X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/060ba13452821aaf23aa9f0f8a6ab82c13b759ee..41184c244487c6f50cd174a0a913b02c5255aab9:/sixteen.c diff --git a/sixteen.c b/sixteen.c index c6664c1..feab05d 100644 --- a/sixteen.c +++ b/sixteen.c @@ -173,7 +173,7 @@ static game_params *custom_params(config_item *cfg) static char *validate_params(game_params *params) { - if (params->w < 2 && params->h < 2) + if (params->w < 2 || params->h < 2) return "Width and height must both be at least two"; return NULL; @@ -505,6 +505,7 @@ static game_state *dup_game(game_state *state) static void free_game(game_state *state) { + sfree(state->tiles); sfree(state); } @@ -577,9 +578,8 @@ static void free_ui(game_ui *ui) { } -static game_state *make_move(game_state *from, game_ui *ui, - int x, int y, int button) -{ +static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds, + int x, int y, int button) { int cx, cy; int dx, dy, tx, ty, n; game_state *ret; @@ -775,7 +775,7 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, bgcolour = COL_BACKGROUND; if (!ds->started) { - int coords[6]; + int coords[10]; draw_rect(fe, 0, 0, TILE_SIZE * state->w + 2 * BORDER, @@ -791,15 +791,19 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, coords[1] = COORD(state->h) + HIGHLIGHT_WIDTH - 1; coords[2] = COORD(state->w) + HIGHLIGHT_WIDTH - 1; coords[3] = COORD(0) - HIGHLIGHT_WIDTH; - coords[4] = COORD(0) - HIGHLIGHT_WIDTH; - coords[5] = COORD(state->h) + HIGHLIGHT_WIDTH - 1; - draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT); - draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT); + coords[4] = coords[2] - TILE_SIZE; + coords[5] = coords[3] + TILE_SIZE; + coords[8] = COORD(0) - HIGHLIGHT_WIDTH; + coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1; + coords[6] = coords[8] + TILE_SIZE; + coords[7] = coords[9] - TILE_SIZE; + draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT); + draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT); coords[1] = COORD(0) - HIGHLIGHT_WIDTH; coords[0] = COORD(0) - HIGHLIGHT_WIDTH; - draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT); - draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT); + draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT); + draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT); /* * Arrows for making moves. @@ -1012,4 +1016,5 @@ const struct game thegame = { game_flash_length, game_wants_statusbar, FALSE, game_timing_state, + 0, /* mouse_priorities */ };