aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorJacob Nevins <jacobn@chiark.greenend.org.uk>2005-07-05 21:27:19 +0000
committerJacob Nevins <jacobn@chiark.greenend.org.uk>2005-07-05 21:27:19 +0000
commitf3c95109c7b905f74b5f149eea21f68444c31ef7 (patch)
tree77e7eeb6b297b201bbd40f67010318d2c4421c85 /midend.c
parent968828283b7a0aacd71d4868846291b381884eb1 (diff)
downloadpuzzles-f3c95109c7b905f74b5f149eea21f68444c31ef7.zip
puzzles-f3c95109c7b905f74b5f149eea21f68444c31ef7.tar.gz
puzzles-f3c95109c7b905f74b5f149eea21f68444c31ef7.tar.bz2
puzzles-f3c95109c7b905f74b5f149eea21f68444c31ef7.tar.xz
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]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/midend.c b/midend.c
index 8223d87..7ef05cb 100644
--- a/midend.c
+++ b/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;