mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Pegs
Slightly more complicated than usual, because Pegs has irregularly shaped grids so detecting whether a click is inside requires more than just a range check. Also fixed a typo in a nearby comment.
This commit is contained in:
33
pegs.c
33
pegs.c
@ -887,16 +887,23 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
|
|
||||||
tx = FROMCOORD(x);
|
tx = FROMCOORD(x);
|
||||||
ty = FROMCOORD(y);
|
ty = FROMCOORD(y);
|
||||||
if (tx >= 0 && tx < w && ty >= 0 && ty < h &&
|
if (tx >= 0 && tx < w && ty >= 0 && ty < h) {
|
||||||
state->grid[ty*w+tx] == GRID_PEG) {
|
switch (state->grid[ty*w+tx]) {
|
||||||
ui->dragging = true;
|
case GRID_PEG:
|
||||||
ui->sx = tx;
|
ui->dragging = true;
|
||||||
ui->sy = ty;
|
ui->sx = tx;
|
||||||
ui->dx = x;
|
ui->sy = ty;
|
||||||
ui->dy = y;
|
ui->dx = x;
|
||||||
ui->cur_visible = false;
|
ui->dy = y;
|
||||||
ui->cur_jumping = false;
|
ui->cur_visible = false;
|
||||||
return MOVE_UI_UPDATE;
|
ui->cur_jumping = false;
|
||||||
|
return MOVE_UI_UPDATE;
|
||||||
|
case GRID_HOLE:
|
||||||
|
return MOVE_NO_EFFECT;
|
||||||
|
case GRID_OBST:
|
||||||
|
default:
|
||||||
|
return MOVE_UNUSED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (button == LEFT_DRAG && ui->dragging) {
|
} else if (button == LEFT_DRAG && ui->dragging) {
|
||||||
/*
|
/*
|
||||||
@ -982,14 +989,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
return MOVE_UI_UPDATE;
|
return MOVE_UI_UPDATE;
|
||||||
}
|
}
|
||||||
if (state->grid[ui->cur_y*w+ui->cur_x] == GRID_PEG) {
|
if (state->grid[ui->cur_y*w+ui->cur_x] == GRID_PEG) {
|
||||||
/* cursor is on peg: next arrow-move wil jump. */
|
/* cursor is on peg: next arrow-move will jump. */
|
||||||
ui->cur_jumping = true;
|
ui->cur_jumping = true;
|
||||||
return MOVE_UI_UPDATE;
|
return MOVE_UI_UPDATE;
|
||||||
}
|
}
|
||||||
return NULL;
|
return MOVE_NO_EFFECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return MOVE_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static game_state *execute_move(const game_state *state, const char *move)
|
static game_state *execute_move(const game_state *state, const char *move)
|
||||||
|
Reference in New Issue
Block a user