summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/solo.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2017-10-29 17:39:29 -0400
committerFranklin Wei <git@fwei.tk>2017-10-29 17:39:29 -0400
commit1f3e70aafcdeaf13eeb906fba97825b5d64ccde9 (patch)
tree47ad3f6677d46e4963a833280b7af85c3b0309e9 /apps/plugins/puzzles/src/solo.c
parent2423d3d4ae1e7093b65e0c56e50ec705e34327b6 (diff)
downloadrockbox-1f3e70aafcdeaf13eeb906fba97825b5d64ccde9.zip
rockbox-1f3e70aafcdeaf13eeb906fba97825b5d64ccde9.tar.gz
rockbox-1f3e70aafcdeaf13eeb906fba97825b5d64ccde9.tar.bz2
rockbox-1f3e70aafcdeaf13eeb906fba97825b5d64ccde9.tar.xz
puzzles: sync with upstream
This includes the fix for Map's incorrect cursor positioning when zoomed in. Change-Id: I7d7d1f3031bbe1390e89340039996f99efaa8ef5
Diffstat (limited to 'apps/plugins/puzzles/src/solo.c')
-rw-r--r--apps/plugins/puzzles/src/solo.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/apps/plugins/puzzles/src/solo.c b/apps/plugins/puzzles/src/solo.c
index ef2852f..dd04cdf 100644
--- a/apps/plugins/puzzles/src/solo.c
+++ b/apps/plugins/puzzles/src/solo.c
@@ -1013,12 +1013,23 @@ static int solver_set(struct solver_usage *usage,
/*
* If count == 0, then there's a row with no 1s at all and
- * the puzzle is internally inconsistent. However, we ought
- * to have caught this already during the simpler reasoning
- * methods, so we can safely fail an assertion if we reach
- * this point here.
+ * the puzzle is internally inconsistent.
*/
- assert(count > 0);
+ if (count == 0) {
+#ifdef STANDALONE_SOLVER
+ if (solver_show_working) {
+ va_list ap;
+ printf("%*s", solver_recurse_depth*4,
+ "");
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ printf(":\n%*s solver_set: impossible on entry\n",
+ solver_recurse_depth*4, "");
+ }
+#endif
+ return -1;
+ }
if (count == 1)
rowidx[i] = colidx[first] = FALSE;
}
@@ -1465,7 +1476,14 @@ static int solver_killer_sums(struct solver_usage *usage, int b,
assert(nsquares == 0);
return 0;
}
- assert(nsquares > 0);
+ if (nsquares == 0) {
+#ifdef STANDALONE_SOLVER
+ if (solver_show_working)
+ printf("%*skiller: cage has no usable squares left\n",
+ solver_recurse_depth*4, "");
+#endif
+ return -1;
+ }
if (nsquares < 2 || nsquares > 4)
return 0;