X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/44bf5f6fb23fec37056c36580bb4e02fdf610915..88ceda407be72bd6cae67c480ceaa0a77f0f0b55:/solo.c diff --git a/solo.c b/solo.c index 229a058..a2f40eb 100644 --- a/solo.c +++ b/solo.c @@ -2220,7 +2220,7 @@ static char *new_game_desc(game_params *params, random_state *rs, grid2[coords[2*j+1]*cr+coords[2*j]] = 0; ret = solver(c, r, grid2, maxdiff); - if (ret != DIFF_IMPOSSIBLE && ret != DIFF_AMBIGUOUS) { + if (ret <= maxdiff) { for (j = 0; j < ncoords; j++) grid[coords[2*j+1]*cr+coords[2*j]] = 0; } @@ -2293,6 +2293,9 @@ static char *validate_desc(game_params *params, char *desc) } else if (n == '_') { /* do nothing */; } else if (n > '0' && n <= '9') { + int val = atoi(desc-1); + if (val < 1 || val > params->c * params->r) + return "Out-of-range number in game description"; squares++; while (*desc >= '0' && *desc <= '9') desc++; @@ -2442,7 +2445,7 @@ static char *grid_text_format(int c, int r, digit *grid) for (x = 0; x < cr; x++) { int ch = grid[y * cr + x]; if (ch == 0) - ch = ' '; + ch = '.'; else if (ch <= 9) ch = '0' + ch; else @@ -2709,7 +2712,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds, ds->tilesize = tilesize; } -static float *game_colours(frontend *fe, game_state *state, int *ncolours) +static float *game_colours(frontend *fe, int *ncolours) { float *ret = snewn(3 * NCOLOURS, float); @@ -2977,11 +2980,6 @@ static float game_flash_length(game_state *oldstate, game_state *newstate, return 0.0F; } -static int game_wants_statusbar(void) -{ - return FALSE; -} - static int game_timing_state(game_state *state, game_ui *ui) { return TRUE; @@ -3009,7 +3007,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize) /* Ick: fake up `ds->tilesize' for macro expansion purposes */ game_drawstate ads, *ds = &ads; - ads.tilesize = tilesize; + game_set_size(dr, ds, NULL, tilesize); /* * Border. @@ -3054,7 +3052,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize) #endif const struct game thegame = { - "Solo", "games.solo", + "Solo", "games.solo", "solo", default_params, game_fetch_preset, decode_params, @@ -3085,53 +3083,13 @@ const struct game thegame = { 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 */ }; #ifdef STANDALONE_SOLVER -/* - * gcc -DSTANDALONE_SOLVER -o solosolver solo.c malloc.c - */ - -void frontend_default_colour(frontend *fe, float *output) {} -void draw_text(drawing *dr, int x, int y, int fonttype, int fontsize, - int align, int colour, char *text) {} -void draw_rect(drawing *dr, int x, int y, int w, int h, int colour) {} -void draw_rect_outline(drawing *dr, int x, int y, int w, int h, int colour) {} -void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour) {} -void draw_polygon(drawing *dr, int *coords, int npoints, - int fillcolour, int outlinecolour) {} -void clip(drawing *dr, int x, int y, int w, int h) {} -void unclip(drawing *dr) {} -void start_draw(drawing *dr) {} -void draw_update(drawing *dr, int x, int y, int w, int h) {} -void end_draw(drawing *dr) {} -int print_mono_colour(drawing *dr, int grey) { return 0; } -void print_line_width(drawing *dr, int width) {} -unsigned long random_bits(random_state *state, int bits) -{ assert(!"Shouldn't get randomness"); return 0; } -unsigned long random_upto(random_state *state, unsigned long limit) -{ assert(!"Shouldn't get randomness"); return 0; } -void shuffle(void *array, int nelts, int eltsize, random_state *rs) -{ assert(!"Shouldn't get randomness"); } - -void fatal(char *fmt, ...) -{ - va_list ap; - - fprintf(stderr, "fatal error: "); - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - fprintf(stderr, "\n"); - exit(1); -} - int main(int argc, char **argv) { game_params *p;