mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Magnets: add a check that magnets don't wrap between lines
There was nothing in Magnet's description validation to prevent there being the left end of a magnet at the right end of a row and the right end of a magnet at the left end of the row below. Indeed as far as I can such a game (e.g. 3x3:..2,2..,...,1.1,TLRB*LRLR) plays entirely correctly except that one magnet is discontinuous. While this worked, it was entirely an artefact of the particular memory layout that Magnets uses and shouldn't have been allowed, so I've added an additional validation rule to stop it.
This commit is contained in:
@ -521,6 +521,8 @@ nextchar:
|
|||||||
for (idx = 0; idx < state->wh; idx++) {
|
for (idx = 0; idx < state->wh; idx++) {
|
||||||
if (state->common->dominoes[idx] < 0 ||
|
if (state->common->dominoes[idx] < 0 ||
|
||||||
state->common->dominoes[idx] >= state->wh ||
|
state->common->dominoes[idx] >= state->wh ||
|
||||||
|
(state->common->dominoes[idx] % state->w != idx % state->w &&
|
||||||
|
state->common->dominoes[idx] / state->w != idx / state->w) ||
|
||||||
state->common->dominoes[state->common->dominoes[idx]] != idx) {
|
state->common->dominoes[state->common->dominoes[idx]] != idx) {
|
||||||
*prob = "Domino descriptions inconsistent";
|
*prob = "Domino descriptions inconsistent";
|
||||||
goto done;
|
goto done;
|
||||||
|
Reference in New Issue
Block a user