break; /* got it */
}
+ debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h));
+
return ngen;
}
{
char *grid, *clues;
char *desc;
- int ngen, w = params->w, h = params->h, i, j;
+ int w = params->w, h = params->h, i, j;
grid = snewn(w*h, char);
clues = snewn(w*h, char);
- ngen = new_clues(params, rs, clues, grid);
-
- debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h));
+ new_clues(params, rs, clues, grid);
desc = snewn(w * h + 1, char);
for (i = j = 0; i < w*h; i++) {
if (ox == gx || oy == gy) {
int dx = (gx < ox ? -1 : gx > ox ? +1 : 0);
int dy = (gy < oy ? -1 : gy > oy ? +1 : 0);
+ int dir = (dy>0 ? D : dy<0 ? U : dx>0 ? R : L);
while (ox != gx || oy != gy) {
+ /*
+ * If the drag attempts to cross a 'no line here' mark,
+ * stop there. We physically don't allow the user to drag
+ * over those marks.
+ */
+ if (state->marks[oy*w+ox] & dir)
+ break;
ox += dx;
oy += dy;
ui->dragcoords[ui->ndragcoords++] = oy * w + ox;
if (!INGRID(state, x, y)) goto badmove;
if (l < 0 || l > 15) goto badmove;
- /* TODO trying to set a line over a no-line mark should be
- * a failed move? */
-
if (c == 'L')
ret->lines[y*w + x] |= (char)l;
else if (c == 'N')
else if (c == 'M')
ret->marks[y*w + x] ^= (char)l;
+ /*
+ * If we ended up trying to lay a line _over_ a mark,
+ * that's a failed move: interpret_move() should have
+ * ensured we never received a move string like that in
+ * the first place.
+ */
+ if ((ret->lines[y*w + x] & (char)l) &&
+ (ret->marks[y*w + x] & (char)l))
+ goto badmove;
+
move += n;
} else if (strcmp(move, "H") == 0) {
pearl_solve(ret->shared->w, ret->shared->h,