mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -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:
18
midend.c
18
midend.c
@ -789,7 +789,7 @@ int midend_num_presets(midend_data *me)
|
||||
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;
|
||||
@ -955,7 +955,7 @@ static char *midend_game_id_int(midend_data *me, char *id, int defmode)
|
||||
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;
|
||||
@ -1046,7 +1046,7 @@ char *midend_set_config(midend_data *me, int which, config_item *cfg)
|
||||
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);
|
||||
@ -1480,16 +1480,24 @@ char *midend_deserialise(midend_data *me,
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user