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:
Ben Harris
2023-04-01 18:54:29 +01:00
parent 91735e5019
commit 0bd1a80578

View File

@ -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;