mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Add a `full' parameter to validate_params(), analogous to the one in
encode_params(). This is necessary for cases where generation-time parameters that are normally omitted from descriptive IDs can place restrictions on other parameters; in particular, when the default value of a relevant generation-time parameter is not the one used to generate the descriptive ID, validation could reject self-generated IDs (e.g., Net `5x2w:56182ae7c2', and some cases in `Pegs'). [originally from svn r6068]
This commit is contained in:
11
pegs.c
11
pegs.c
@ -120,6 +120,11 @@ static void decode_params(game_params *params, char const *string)
|
||||
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;
|
||||
@ -178,9 +183,9 @@ static game_params *custom_params(config_item *cfg)
|
||||
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";
|
||||
|
||||
/*
|
||||
@ -189,7 +194,7 @@ static char *validate_params(game_params *params)
|
||||
* 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";
|
||||
}
|
||||
|
Reference in New Issue
Block a user