~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Modification of a patch from Debian: eliminate the endless rebuilds
[sgt/puzzles]
/
guess.c
diff --git
a/guess.c
b/guess.c
index
6fb3630
..
38cdf25
100644
(file)
--- a/
guess.c
+++ b/
guess.c
@@
-371,6
+371,11
@@
static char *solve_game(game_state *state, game_state *currstate,
return dupstr("S");
}
return dupstr("S");
}
+static int game_can_format_as_text_now(game_params *params)
+{
+ return TRUE;
+}
+
static char *game_text_format(game_state *state)
{
return NULL;
static char *game_text_format(game_state *state)
{
return NULL;
@@
-650,20
+655,24
@@
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
if (from->solved) return NULL;
if (from->solved) return NULL;
- if (x >= COL_OX && x <
=
(COL_OX + COL_W) &&
- y >= COL_OY && y <
=
(COL_OY + COL_H)) {
+ if (x >= COL_OX && x < (COL_OX + COL_W) &&
+ y >= COL_OY && y < (COL_OY + COL_H)) {
over_col = ((y - COL_OY) / PEGOFF) + 1;
over_col = ((y - COL_OY) / PEGOFF) + 1;
+ assert(over_col >= 1 && over_col <= ds->colours->npegs);
} else if (x >= guess_ox &&
} else if (x >= guess_ox &&
- y >= guess_oy && y <
=
(guess_oy + GUESS_H)) {
- if (x <
=
(guess_ox + GUESS_W)) {
+ y >= guess_oy && y < (guess_oy + GUESS_H)) {
+ if (x < (guess_ox + GUESS_W)) {
over_guess = (x - guess_ox) / PEGOFF;
over_guess = (x - guess_ox) / PEGOFF;
+ assert(over_guess >= 0 && over_guess < ds->solution->npegs);
} else {
over_hint = 1;
}
} else {
over_hint = 1;
}
- } else if (x >= guess_ox && x <
=
(guess_ox + GUESS_W) &&
+ } else if (x >= guess_ox && x < (guess_ox + GUESS_W) &&
y >= GUESS_OY && y < guess_oy) {
over_past_guess_y = (y - GUESS_OY) / PEGOFF;
over_past_guess_x = (x - guess_ox) / PEGOFF;
y >= GUESS_OY && y < guess_oy) {
over_past_guess_y = (y - GUESS_OY) / PEGOFF;
over_past_guess_x = (x - guess_ox) / PEGOFF;
+ assert(over_past_guess_y >= 0 && over_past_guess_y < from->next_go);
+ assert(over_past_guess_x >= 0 && over_past_guess_x < ds->solution->npegs);
}
debug(("make_move: over_col %d, over_guess %d, over_hint %d,"
" over_past_guess (%d,%d)", over_col, over_guess, over_hint,
}
debug(("make_move: over_col %d, over_guess %d, over_hint %d,"
" over_past_guess (%d,%d)", over_col, over_guess, over_hint,
@@
-753,8
+762,7
@@
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
if (button == CURSOR_LEFT && ui->peg_cur > 0)
ui->peg_cur--;
ret = "";
if (button == CURSOR_LEFT && ui->peg_cur > 0)
ui->peg_cur--;
ret = "";
- } else if (button == CURSOR_SELECT || button == ' ' || button == '\r' ||
- button == '\n') {
+ } else if (IS_CURSOR_SELECT(button)) {
ui->display_cur = 1;
if (ui->peg_cur == from->params.npegs) {
ret = encode_move(from, ui);
ui->display_cur = 1;
if (ui->peg_cur == from->params.npegs) {
ret = encode_move(from, ui);
@@
-988,9
+996,9
@@
static float *game_colours(frontend *fe, int *ncolours)
/* We also want to be able to tell the difference between BACKGROUND
* and EMPTY, for similar distinguishing-hint reasons. */
/* We also want to be able to tell the difference between BACKGROUND
* and EMPTY, for similar distinguishing-hint reasons. */
- ret[COL_EMPTY * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0
/ 3.0
;
- ret[COL_EMPTY * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0
/ 3.0
;
- ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0
/ 3.0
;
+ ret[COL_EMPTY * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0
F / 3.0F
;
+ ret[COL_EMPTY * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0
F / 3.0F
;
+ ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0
F / 3.0F
;
*ncolours = NCOLOURS;
return ret;
*ncolours = NCOLOURS;
return ret;
@@
-1339,7
+1347,7
@@
const struct game thegame = {
dup_game,
free_game,
TRUE, solve_game,
dup_game,
free_game,
TRUE, solve_game,
- FALSE, game_text_format,
+ FALSE, game_
can_format_as_text_now, game_
text_format,
new_ui,
free_ui,
encode_ui,
new_ui,
free_ui,
encode_ui,