~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change of policy on game_changed_state(). Originally, it was called
[sgt/puzzles]
/
midend.c
diff --git
a/midend.c
b/midend.c
index
8223d87
..
b5ce237
100644
(file)
--- a/
midend.c
+++ b/
midend.c
@@
-491,6
+491,10
@@
static int midend_really_process_key(midend_data *me, int x, int y, int button)
me->states[me->nstates].movetype = MOVE;
me->statepos = ++me->nstates;
me->dir = +1;
me->states[me->nstates].movetype = MOVE;
me->statepos = ++me->nstates;
me->dir = +1;
+ if (me->ui)
+ me->ourgame->changed_state(me->ui,
+ me->states[me->statepos-2].state,
+ me->states[me->statepos-1].state);
} else {
goto done;
}
} else {
goto done;
}
@@
-789,7
+793,7
@@
int midend_num_presets(midend_data *me)
preset = me->ourgame->default_params();
me->ourgame->decode_params(preset, val);
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;
/* Drop this one from the list. */
me->ourgame->free_params(preset);
continue;
@@
-955,7
+959,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);
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;
if (error) {
me->ourgame->free_params(newcurparams);
return error;
@@
-1046,7
+1050,7
@@
char *midend_set_config(midend_data *me, int which, config_item *cfg)
switch (which) {
case CFG_SETTINGS:
params = me->ourgame->custom_params(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);
if (error) {
me->ourgame->free_params(params);
@@
-1350,6
+1354,7
@@
char *midend_deserialise(midend_data *me,
if (key[8] != ':') {
if (started)
ret = "Data was incorrectly formatted for a saved game file";
if (key[8] != ':') {
if (started)
ret = "Data was incorrectly formatted for a saved game file";
+ goto cleanup;
}
len = strcspn(key, ": ");
assert(len <= 8);
}
len = strcspn(key, ": ");
assert(len <= 8);
@@
-1480,16
+1485,24
@@
char *midend_deserialise(midend_data *me,
params = me->ourgame->default_params();
me->ourgame->decode_params(params, parstr);
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);
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;
}
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;
if (!desc) {
ret = "Game description in save file is missing";
goto cleanup;