mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Fixes for handling human-entered Flip games. The clicked-on square
always got a flip animation even when it wasn't one of the ones being turned, and a square with no effect at all was still counting as a move. Since it's an invariant of Flip's internal generator that every square includes itself as an effect, this never comes up in auto- generated games. [originally from svn r6384]
This commit is contained in:
26
flip.c
26
flip.c
@ -897,7 +897,7 @@ struct game_drawstate {
|
|||||||
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
||||||
int x, int y, int button)
|
int x, int y, int button)
|
||||||
{
|
{
|
||||||
int w = state->w, h = state->h /*, wh = w * h */;
|
int w = state->w, h = state->h, wh = w * h;
|
||||||
char buf[80], *nullret = NULL;
|
char buf[80], *nullret = NULL;
|
||||||
|
|
||||||
if (button == LEFT_BUTTON || button == CURSOR_SELECT ||
|
if (button == LEFT_BUTTON || button == CURSOR_SELECT ||
|
||||||
@ -913,8 +913,22 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
|||||||
nullret = "";
|
nullret = "";
|
||||||
|
|
||||||
if (tx >= 0 && tx < w && ty >= 0 && ty < h) {
|
if (tx >= 0 && tx < w && ty >= 0 && ty < h) {
|
||||||
sprintf(buf, "M%d,%d", tx, ty);
|
/*
|
||||||
return dupstr(buf);
|
* It's just possible that a manually entered game ID
|
||||||
|
* will have at least one square do nothing whatsoever.
|
||||||
|
* If so, we avoid encoding a move at all.
|
||||||
|
*/
|
||||||
|
int i = ty*w+tx, j, makemove = FALSE;
|
||||||
|
for (j = 0; j < wh; j++) {
|
||||||
|
if (state->matrix->matrix[i*wh+j])
|
||||||
|
makemove = TRUE;
|
||||||
|
}
|
||||||
|
if (makemove) {
|
||||||
|
sprintf(buf, "M%d,%d", tx, ty);
|
||||||
|
return dupstr(buf);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (button == CURSOR_UP || button == CURSOR_DOWN ||
|
else if (button == CURSOR_UP || button == CURSOR_DOWN ||
|
||||||
@ -1179,6 +1193,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
|
|||||||
int fx, fy, fd;
|
int fx, fy, fd;
|
||||||
int v = state->grid[i];
|
int v = state->grid[i];
|
||||||
int vv;
|
int vv;
|
||||||
|
int hintmask = (state->hints_active ? ~0 : ~2);
|
||||||
|
|
||||||
if (flashframe >= 0) {
|
if (flashframe >= 0) {
|
||||||
fx = (w+1)/2 - min(x+1, w-x);
|
fx = (w+1)/2 - min(x+1, w-x);
|
||||||
@ -1190,12 +1205,11 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
|
|||||||
v &= ~1;
|
v &= ~1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state->hints_active)
|
v &= hintmask;
|
||||||
v &= ~2;
|
|
||||||
if (ui->cdraw && ui->cx == x && ui->cy == y)
|
if (ui->cdraw && ui->cx == x && ui->cy == y)
|
||||||
v |= 4;
|
v |= 4;
|
||||||
|
|
||||||
if (oldstate && state->grid[i] != oldstate->grid[i])
|
if (oldstate && ((state->grid[i] ^ oldstate->grid[i]) & hintmask))
|
||||||
vv = 255; /* means `animated' */
|
vv = 255; /* means `animated' */
|
||||||
else
|
else
|
||||||
vv = v;
|
vv = v;
|
||||||
|
Reference in New Issue
Block a user