aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-02-02 23:09:19 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-02 23:09:19 +0000
commit15f4fa851a5781cf77984a6046405ffa758e7b33 (patch)
tree5088167c25bb82fd6065424f1aa4aa81b9bc7bd0
parent294a3ac6e703c2820ceb7b28a1a5492b61e9a531 (diff)
downloadpuzzles-15f4fa851a5781cf77984a6046405ffa758e7b33.zip
puzzles-15f4fa851a5781cf77984a6046405ffa758e7b33.tar.gz
puzzles-15f4fa851a5781cf77984a6046405ffa758e7b33.tar.bz2
puzzles-15f4fa851a5781cf77984a6046405ffa758e7b33.tar.xz
Forbid lines off the grid in Pearl
While they couldn't be generated in normal play, execute_move() would permit lines and marks across the edge of the grid that would then generate assertion failures ("dsf_update_completion: Assertion `INGRID(state, bx, by)' failed."). I've added a check to execute_move() that after updating a square, the square doesn't have any lines or marks that leave the grid. This save file demonstrated the problem: SAVEFILE:41:Simon Tatham's Portable Puzzle Collection VERSZON :1:1 GAME :5:Pearl PARAMS :5:5x6dt CPARAMS :5:5x6dt DESC :6:eeeeee NSTATES :1:2 STATEPOS:1:1 MOVE :6:F1,4,2
-rw-r--r--pearl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/pearl.c b/pearl.c
index 72f36f7..f79a6dc 100644
--- a/pearl.c
+++ b/pearl.c
@@ -2278,6 +2278,16 @@ static game_state *execute_move(const game_state *state, const char *move)
(ret->marks[y*w + x] & (char)l))
goto badmove;
+ /*
+ * Similarly, if we've ended up with a line or mark going
+ * off the board, that's not acceptable.
+ */
+ for (l = 1; l <= 8; l <<= 1)
+ if (((ret->lines[y*w + x] & (char)l) ||
+ (ret->marks[y*w + x] & (char)l)) &&
+ !INGRID(state, x+DX(l), y+DY(l)))
+ goto badmove;
+
move += n;
} else if (strcmp(move, "H") == 0) {
pearl_solve(ret->shared->w, ret->shared->h,