aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-09-11 11:57:24 +0000
committerSimon Tatham <anakin@pobox.com>2005-09-11 11:57:24 +0000
commit08c8cf370ef7575a78988eb7d8f98c2a0bb92c63 (patch)
treecf493cebbe51b1bef224e818bf00111d14673a4f
parentefda6cff49e7579b5c10b16694ac57340ce2fc2b (diff)
downloadpuzzles-08c8cf370ef7575a78988eb7d8f98c2a0bb92c63.zip
puzzles-08c8cf370ef7575a78988eb7d8f98c2a0bb92c63.tar.gz
puzzles-08c8cf370ef7575a78988eb7d8f98c2a0bb92c63.tar.bz2
puzzles-08c8cf370ef7575a78988eb7d8f98c2a0bb92c63.tar.xz
Marginally greater robustness in the face of solve_game() failing to
return an error message. [originally from svn r6288]
-rw-r--r--midend.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/midend.c b/midend.c
index 64edfd3..cc360b5 100644
--- a/midend.c
+++ b/midend.c
@@ -1167,12 +1167,15 @@ char *midend_solve(midend *me)
if (me->statepos < 1)
return "No game set up to solve"; /* _shouldn't_ happen! */
- msg = "Solve operation failed"; /* game _should_ overwrite on error */
+ msg = NULL;
movestr = me->ourgame->solve(me->states[0].state,
me->states[me->statepos-1].state,
me->aux_info, &msg);
- if (!movestr)
+ if (!movestr) {
+ if (!msg)
+ msg = "Solve operation failed"; /* _shouldn't_ happen, but can */
return msg;
+ }
s = me->ourgame->execute_move(me->states[me->statepos-1].state, movestr);
assert(s);