From 15f4fa851a5781cf77984a6046405ffa758e7b33 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 2 Feb 2023 23:09:19 +0000 Subject: [PATCH] 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 --- pearl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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,