classes[thisclass]++;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
int classes[5];
int i;
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w < 2 || params->h < 2)
return "Width and height must both be at least two";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w <= 0 || params->h <= 0)
return "Width and height must both be greater than zero";
*seed++ = '\0';
thegame.decode_params(par, params);
}
- if ((error = thegame.validate_params(par)) != NULL) {
+ if ((error = thegame.validate_params(par, TRUE)) != NULL) {
fprintf(stderr, "%s: %s\n", pname, error);
return 1;
}
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->ncolours < 2 || params->npegs < 2)
return "Trivial solutions are uninteresting";
preset = me->ourgame->default_params();
me->ourgame->decode_params(preset, val);
- if (me->ourgame->validate_params(preset)) {
+ if (me->ourgame->validate_params(preset, TRUE)) {
/* Drop this one from the list. */
me->ourgame->free_params(preset);
continue;
if (par) {
newcurparams = me->ourgame->dup_params(me->params);
me->ourgame->decode_params(newcurparams, par);
- error = me->ourgame->validate_params(newcurparams);
+ error = me->ourgame->validate_params(newcurparams, desc == NULL);
if (error) {
me->ourgame->free_params(newcurparams);
return error;
switch (which) {
case CFG_SETTINGS:
params = me->ourgame->custom_params(cfg);
- error = me->ourgame->validate_params(params);
+ error = me->ourgame->validate_params(params, TRUE);
if (error) {
me->ourgame->free_params(params);
params = me->ourgame->default_params();
me->ourgame->decode_params(params, parstr);
- if (me->ourgame->validate_params(params)) {
+ if (me->ourgame->validate_params(params, TRUE)) {
ret = "Long-term parameters in save file are invalid";
goto cleanup;
}
cparams = me->ourgame->default_params();
me->ourgame->decode_params(cparams, cparstr);
- if (me->ourgame->validate_params(cparams)) {
+ if (me->ourgame->validate_params(cparams, FALSE)) {
ret = "Short-term parameters in save file are invalid";
goto cleanup;
}
+ if (seed && me->ourgame->validate_params(cparams, TRUE)) {
+ /*
+ * The seed's no use with this version, but we can perfectly
+ * well use the rest of the data.
+ */
+ sfree(seed);
+ seed = NULL;
+ }
if (!desc) {
ret = "Game description in save file is missing";
goto cleanup;
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
/*
* Lower limit on grid size: each dimension must be at least 3.
* _have_ to have a gap somewhere which you can't determine the
* position of.
*/
- if (params->w <= 2 || params->h <= 2)
+ if (full && params->unique && (params->w <= 2 || params->h <= 2))
return "Width and height must both be greater than two";
if (params->n > params->w * params->h - 9)
return "Too many mines for grid size";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->width <= 0 || params->height <= 0)
return "Width and height must both be greater than zero";
* is at least 2^(number of such rows), and in particular is at
* least 2 since there must be at least one such row. []
*/
- if (params->unique && params->wrapping &&
+ if (full && params->unique && params->wrapping &&
(params->width == 2 || params->height == 2))
return "No wrapping puzzle with a width or height of 2 can have"
" a unique solution";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->width <= 1 || params->height <= 1)
return "Width and height must both be greater than one";
return NULL;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
return NULL;
}
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w <= 0 || params->h <= 0)
return "Width and height must both be greater than zero";
params->h = params->w;
}
+ /*
+ * Assume a random generation scheme unless told otherwise, for the
+ * sake of internal consistency.
+ */
+ params->type = TYPE_RANDOM;
for (i = 0; i < lenof(pegs_lowertypes); i++)
if (!strcmp(p, pegs_lowertypes[i]))
params->type = i;
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
- if (params->w <= 3 || params->h <= 3)
+ if (full && (params->w <= 3 || params->h <= 3))
return "Width and height must both be greater than three";
/*
* soluble. For the moment, therefore, I'm going to disallow
* them at any size other than the standard one.
*/
- if (params->type == TYPE_CROSS || params->type == TYPE_OCTAGON) {
+ if (full && (params->type == TYPE_CROSS || params->type == TYPE_OCTAGON)) {
if (params->w != 7 || params->h != 7)
return "This board type is only supported at 7x7";
}
int can_configure;
config_item *(*configure)(game_params *params);
game_params *(*custom_params)(config_item *cfg);
- char *(*validate_params)(game_params *params);
+ char *(*validate_params)(game_params *params, int full);
char *(*new_desc)(game_params *params, random_state *rs,
char **aux, int interactive);
char *(*validate_desc)(game_params *params, char *desc);
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w <= 0 || params->h <= 0)
return "Width and height must both be greater than zero";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w < 1 || params->h < 1)
return "Width and height must both be positive";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->w < 2 || params->h < 2)
return "Width and height must both be at least two";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->c < 2 || params->r < 2)
return "Both dimensions must be at least 2";
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->n < 2)
return "Rotation radius must be at least two";