chiark / gitweb /
Marginally greater robustness in the face of solve_game() failing to
authorSimon Tatham <anakin@pobox.com>
Sun, 11 Sep 2005 11:57:24 +0000 (11:57 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 11 Sep 2005 11:57:24 +0000 (11:57 +0000)
return an error message.

[originally from svn r6288]

midend.c

index 64edfd3394f7544f1ab36b812f2413d77ff85983..cc360b50c4bd4bb567da4c08f93f5ff1be9444af 100644 (file)
--- 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);