mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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
This commit is contained in:
10
pearl.c
10
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))
|
(ret->marks[y*w + x] & (char)l))
|
||||||
goto badmove;
|
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;
|
move += n;
|
||||||
} else if (strcmp(move, "H") == 0) {
|
} else if (strcmp(move, "H") == 0) {
|
||||||
pearl_solve(ret->shared->w, ret->shared->h,
|
pearl_solve(ret->shared->w, ret->shared->h,
|
||||||
|
Reference in New Issue
Block a user