shithub: puzzles

Download patch

ref: 7024735f89c7b04b57e7ea41d5104a3455c91348
parent: b5cb02b61ac70ce92631c1a39d66e7668e870c8a
author: Simon Tatham <anakin@pobox.com>
date: Wed Dec 28 13:17:30 EST 2011

Allow --save to work with --soln, causing saved game files to be
written out with the Solve operation having already been performed.

[originally from svn r9375]

--- a/gtk.c
+++ b/gtk.c
@@ -2698,6 +2698,16 @@
 		char *realname = snewn(40 + strlen(savefile) +
 				       strlen(savesuffix), char);
 		sprintf(realname, "%s%d%s", savefile, i, savesuffix);
+
+                if (soln) {
+                    char *err = midend_solve(me);
+                    if (err) {
+                        fprintf(stderr, "%s: unable to show solution: %s\n",
+                                realname, err);
+                        return 1;
+                    }
+                }
+
 		ctx.fp = fopen(realname, "w");
 		if (!ctx.fp) {
 		    fprintf(stderr, "%s: open: %s\n", realname,
--- a/midend.c
+++ b/midend.c
@@ -1331,7 +1331,8 @@
 	me->anim_time = 0.0;
 	midend_finish_move(me);
     }
-    midend_redraw(me);
+    if (me->drawing)
+        midend_redraw(me);
     midend_set_timer(me);
     return NULL;
 }