X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/48dcdd627698354063fa1b551cfa1917dea1b25e..41184c244487c6f50cd174a0a913b02c5255aab9:/netslide.c diff --git a/netslide.c b/netslide.c index bf5fc75..f6282eb 100644 --- a/netslide.c +++ b/netslide.c @@ -13,8 +13,6 @@ #include "puzzles.h" #include "tree234.h" -#define PI 3.141592653589793238462643383279502884197169399 - #define MATMUL(xr,yr,m,x,y) do { \ float rx, ry, xx = (x), yy = (y), *mat = (m); \ rx = mat[0] * xx + mat[2] * yy; \ @@ -163,34 +161,35 @@ static game_params *default_params(void) return ret; } +static const struct { int x, y, wrap, bprob; const char* desc; } +netslide_presets[] = { + {3, 3, FALSE, 1.0, " easy"}, + {3, 3, FALSE, 0.0, " medium"}, + {3, 3, TRUE, 0.0, " hard"}, + {4, 4, FALSE, 1.0, " easy"}, + {4, 4, FALSE, 0.0, " medium"}, + {4, 4, TRUE, 0.0, " hard"}, + {5, 5, FALSE, 1.0, " easy"}, + {5, 5, FALSE, 0.0, " medium"}, + {5, 5, TRUE, 0.0, " hard"}, +}; + static int game_fetch_preset(int i, char **name, game_params **params) { game_params *ret; char str[80]; - static const struct { int x, y, wrap, bprob; const char* desc; } values[] = { - {3, 3, FALSE, 1.0, " easy"}, - {3, 3, FALSE, 0.0, " medium"}, - {3, 3, TRUE, 0.0, " hard"}, - {4, 4, FALSE, 1.0, " easy"}, - {4, 4, FALSE, 0.0, " medium"}, - {4, 4, TRUE, 0.0, " hard"}, - {5, 5, FALSE, 1.0, " easy"}, - {5, 5, FALSE, 0.0, " medium"}, - {5, 5, TRUE, 0.0, " hard"}, - }; - - if (i < 0 || i >= lenof(values)) + + if (i < 0 || i >= lenof(netslide_presets)) return FALSE; ret = snew(game_params); - ret->width = values[i].x; - ret->height = values[i].y; - ret->wrapping = values[i].wrap; - ret->barrier_probability = values[i].bprob; + ret->width = netslide_presets[i].x; + ret->height = netslide_presets[i].y; + ret->wrapping = netslide_presets[i].wrap; + ret->barrier_probability = netslide_presets[i].bprob; ret->movetarget = 0; - sprintf(str, "%dx%d%s", ret->width, ret->height, - values[i].desc); + sprintf(str, "%dx%d%s", ret->width, ret->height, netslide_presets[i].desc); *name = dupstr(str); *params = ret; @@ -316,12 +315,8 @@ static game_params *custom_params(config_item *cfg) static char *validate_params(game_params *params) { - if (params->width <= 1 && params->height <= 1) + if (params->width <= 1 || params->height <= 1) return "Width and height must both be greater than one"; - if (params->width <= 1) - return "Width must be greater than one"; - if (params->height <= 1) - return "Height must be greater than one"; if (params->barrier_probability < 0) return "Barrier probability may not be negative"; if (params->barrier_probability > 1) @@ -334,7 +329,7 @@ static char *validate_params(game_params *params) */ static char *new_game_desc(game_params *params, random_state *rs, - game_aux_info **aux) + game_aux_info **aux, int interactive) { tree234 *possibilities, *barriertree; int w, h, x, y, cx, cy, nbarriers; @@ -1051,7 +1046,7 @@ static void slide_col(game_state *state, int dir, int col) } static game_state *make_move(game_state *state, game_ui *ui, - int x, int y, int button) + game_drawstate *ds, int x, int y, int button) { int cx, cy; int n, dx, dy; @@ -1764,4 +1759,5 @@ const struct game thegame = { game_flash_length, game_wants_statusbar, FALSE, game_timing_state, + 0, /* mouse_priorities */ };