X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/b2a646f1af7858878025bdae14bef9482bee8e26..eb5f5f5d260d3e3b9b5e5027f60a7071a4f3c766:/netslide.c diff --git a/netslide.c b/netslide.c index 86efb2f..b0d975f 100644 --- a/netslide.c +++ b/netslide.c @@ -129,7 +129,7 @@ static int xyd_cmp(void *av, void *bv) { if (a->direction > b->direction) return +1; return 0; -}; +} static struct xyd *new_xyd(int x, int y, int direction) { @@ -161,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; @@ -314,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) @@ -1762,4 +1759,5 @@ const struct game thegame = { game_flash_length, game_wants_statusbar, FALSE, game_timing_state, + 0, /* mouse_priorities */ };