mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Special-case right-dragging of a numbered cell off the grid.
Chris Boyle reports that if you right-drag a numbered cell off the grid, _all_ numbered cells (except the immutable initial clues) get reset to blank, because this is treated as an attempt to erase a whole chain of linked cells (of the form a,a+1,...,a_k) and the cells with definite numbers are all treated as 'chain 0'. In that situation, I now substitute the same behaviour you'd get by left-dragging the numbered cell off the board, i.e. erase _just_ that cell and not the whole of the rest of the puzzle. (The previous unintended behaviour was a UI action you surely never want - and Chris also reports that due to the Android front end's way of representing right-drags, it's especially easy to hit by mistake.)
This commit is contained in:
@ -1578,6 +1578,8 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
si = sy*w+sx; ei = ey*w+ex;
|
si = sy*w+sx; ei = ey*w+ex;
|
||||||
makelink(ret, si, ei);
|
makelink(ret, si, ei);
|
||||||
} else if (sscanf(move, "%c%d,%d", &c, &sx, &sy) == 3) {
|
} else if (sscanf(move, "%c%d,%d", &c, &sx, &sy) == 3) {
|
||||||
|
int sset;
|
||||||
|
|
||||||
if (c != 'C' && c != 'X') return NULL;
|
if (c != 'C' && c != 'X') return NULL;
|
||||||
if (!INGRID(state, sx, sy)) return NULL;
|
if (!INGRID(state, sx, sy)) return NULL;
|
||||||
si = sy*w+sx;
|
si = sy*w+sx;
|
||||||
@ -1586,11 +1588,12 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
|
|
||||||
ret = dup_game(state);
|
ret = dup_game(state);
|
||||||
|
|
||||||
if (c == 'C') {
|
sset = state->nums[si] / (state->n+1);
|
||||||
|
if (c == 'C' || (c == 'X' && sset == 0)) {
|
||||||
/* Unlink the single cell we dragged from the board. */
|
/* Unlink the single cell we dragged from the board. */
|
||||||
unlink_cell(ret, si);
|
unlink_cell(ret, si);
|
||||||
} else {
|
} else {
|
||||||
int i, set, sset = state->nums[si] / (state->n+1);
|
int i, set;
|
||||||
for (i = 0; i < state->n; i++) {
|
for (i = 0; i < state->n; i++) {
|
||||||
/* Unlink all cells in the same set as the one we dragged
|
/* Unlink all cells in the same set as the one we dragged
|
||||||
* from the board. */
|
* from the board. */
|
||||||
|
Reference in New Issue
Block a user