Game completion detection was occasionally failing to spot a
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 8 Dec 2004 08:08:00 +0000 (08:08 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 8 Dec 2004 08:08:00 +0000 (08:08 +0000)
lingering GRID_UNKNOWN, causing it to declare victory too soon.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@4954 cda61777-01e9-0310-a592-d414129be87e

pattern.c

index d597127..ca71fba 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -322,16 +322,16 @@ int compute_rowdata(int *ret, unsigned char *start, int len, int step)
     n = 0;
 
     for (i = 0; i < len; i++) {
-        if (start[i*step] == GRID_UNKNOWN)
-            return -1;
-
         if (start[i*step] == GRID_FULL) {
             int runlen = 1;
-            while (i+runlen < len && start[(i+runlen)*step])
+            while (i+runlen < len && start[(i+runlen)*step] == GRID_FULL)
                 runlen++;
             ret[n++] = runlen;
             i += runlen;
         }
+
+        if (start[i*step] == GRID_UNKNOWN)
+            return -1;
     }
 
     return n;