aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filling.c5
-rw-r--r--galaxies.c4
-rw-r--r--latin.c14
-rw-r--r--map.c2
-rw-r--r--pattern.c11
-rw-r--r--unequal.c22
6 files changed, 33 insertions, 25 deletions
diff --git a/filling.c b/filling.c
index 1ce04eb..b9dff73 100644
--- a/filling.c
+++ b/filling.c
@@ -299,7 +299,7 @@ static game_state *new_game(midend *, game_params *, char *);
static void free_game(game_state *);
/* generate a random valid board; uses validate_board. */
-void make_board(int *board, int w, int h, random_state *rs) {
+static void make_board(int *board, int w, int h, random_state *rs) {
int *dsf;
const unsigned int sz = w * h;
@@ -974,9 +974,9 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
static game_state *execute_move(game_state *state, char *move)
{
game_state *new_state;
+ const int sz = state->shared->params.w * state->shared->params.h;
if (*move == 's') {
- const int sz = state->shared->params.w * state->shared->params.h;
int i = 0;
new_state = dup_game(state);
for (++move; i < sz; ++i) new_state->board[i] = move[i] - '0';
@@ -991,6 +991,7 @@ static game_state *execute_move(game_state *state, char *move)
value = strtol(move, &endptr, 0);
if (endptr == move) return NULL;
if (*endptr != '\0') return NULL;
+ if (i < 0 || i >= sz || value < 0 || value > 9) return NULL;
new_state = dup_game(state);
new_state->board[i] = value;
}
diff --git a/galaxies.c b/galaxies.c
index 4c69de0..6989fe3 100644
--- a/galaxies.c
+++ b/galaxies.c
@@ -298,8 +298,8 @@ static void add_assoc(game_state *state, space *tile, space *dot) {
tile->dotx = dot->x;
tile->doty = dot->y;
dot->nassoc++;
- debug(("add_assoc sp %d %d --> dot %d,%d, new nassoc %d.\n",
- tile->x, tile->y, dot->x, dot->y, dot->nassoc));
+ /*debug(("add_assoc sp %d %d --> dot %d,%d, new nassoc %d.\n",
+ tile->x, tile->y, dot->x, dot->y, dot->nassoc));*/
}
static struct space *sp2dot(game_state *state, int x, int y)
diff --git a/latin.c b/latin.c
index dc2af8f..bfed671 100644
--- a/latin.c
+++ b/latin.c
@@ -12,11 +12,6 @@
#include "latin.h"
-static void assert_f(p)
-{
- assert(p);
-}
-
/* --------------------------------------------------------
* Solver.
*/
@@ -31,7 +26,7 @@ void latin_solver_place(struct latin_solver *solver, int x, int y, int n)
int i, o = solver->o;
assert(n <= o);
- assert_f(cube(x,y,n));
+ assert(cube(x,y,n));
/*
* Rule out all other numbers in this square.
@@ -961,7 +956,7 @@ void latin_solver_debug(unsigned char *cube, int o)
#ifdef STANDALONE_SOLVER
if (solver_show_working) {
struct latin_solver ls, *solver = &ls;
- unsigned char *dbg;
+ char *dbg;
int x, y, i, c = 0;
ls.cube = cube; ls.o = o; /* for cube() to work */
@@ -1181,7 +1176,7 @@ int latin_check(digit *sq, int order)
tree234 *dict = newtree234(latin_check_cmp);
int c, r;
int ret = 0;
- lcparams *lcp, lc;
+ lcparams *lcp, lc, *aret;
/* Use a tree234 as a simple hash table, go through the square
* adding elements as we go or incrementing their counts. */
@@ -1193,7 +1188,8 @@ int latin_check(digit *sq, int order)
lcp = snew(lcparams);
lcp->elt = ELT(sq, c, r);
lcp->count = 1;
- assert_f(add234(dict, lcp) == lcp);
+ aret = add234(dict, lcp);
+ assert(aret == lcp);
} else {
lcp->count++;
}
diff --git a/map.c b/map.c
index b6b6194..da3c4ba 100644
--- a/map.c
+++ b/map.c
@@ -2532,7 +2532,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds,
const float map_colours[FOUR][3] = {
#ifdef VIVID_COLOURS
- // Use more vivid colours (e.g. on the Pocket PC)
+ /* Use more vivid colours (e.g. on the Pocket PC) */
{0.75F, 0.25F, 0.25F},
{0.3F, 0.7F, 0.3F},
{0.3F, 0.3F, 0.7F},
diff --git a/pattern.c b/pattern.c
index 2c24ad2..740f434 100644
--- a/pattern.c
+++ b/pattern.c
@@ -789,17 +789,28 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
if (x >= 0 && x < state->w && y >= 0 && y < state->h &&
(button == LEFT_BUTTON || button == RIGHT_BUTTON ||
button == MIDDLE_BUTTON)) {
+#ifdef STYLUS_BASED
+ int currstate = state->grid[y * state->w + x];
+#endif
ui->dragging = TRUE;
if (button == LEFT_BUTTON) {
ui->drag = LEFT_DRAG;
ui->release = LEFT_RELEASE;
+#ifdef STYLUS_BASED
+ ui->state = currstate == GRID_FULL ? GRID_UNKNOWN : GRID_FULL;
+#else
ui->state = GRID_FULL;
+#endif
} else if (button == RIGHT_BUTTON) {
ui->drag = RIGHT_DRAG;
ui->release = RIGHT_RELEASE;
+#ifdef STYLUS_BASED
+ ui->state = currstate == GRID_EMPTY ? GRID_UNKNOWN : GRID_EMPTY;
+#else
ui->state = GRID_EMPTY;
+#endif
} else /* if (button == MIDDLE_BUTTON) */ {
ui->drag = MIDDLE_DRAG;
ui->release = MIDDLE_RELEASE;
diff --git a/unequal.c b/unequal.c
index 8006ea1..c805975 100644
--- a/unequal.c
+++ b/unequal.c
@@ -26,11 +26,6 @@
#include "puzzles.h"
#include "latin.h" /* contains typedef for digit */
-static void assert_f(p)
-{
- assert(p);
-}
-
/* ----------------------------------------------------------
* Constant and structure definitions
*/
@@ -885,7 +880,7 @@ static int gg_best_clue(game_state *state, int *scratch, digit *latin)
}
#endif
- for (i = 0; i < ls; i++) {
+ for (i = ls; i-- > 0 ;) {
if (!gg_place_clue(state, scratch[i], latin, 1)) continue;
loc = scratch[i] / 5;
@@ -976,7 +971,8 @@ static void game_strip(game_state *new, int *scratch, digit *latin,
gg_solved++;
if (solver_state(copy, difficulty) != 1) {
/* put clue back, we can't solve without it. */
- assert_f(gg_place_clue(new, scratch[i], latin, 0) == 1);
+ int ret = gg_place_clue(new, scratch[i], latin, 0);
+ assert(ret == 1);
} else {
#ifdef STANDALONE_SOLVER
if (solver_show_working)
@@ -1007,7 +1003,8 @@ static char *new_game_desc(game_params *params, random_state *rs,
/* Generate a list of 'things to strip' (randomised later) */
scratch = snewn(lscratch, int);
- for (i = 0; i < lscratch; i++) scratch[i] = i;
+ /* Put the numbers (4 mod 5) before the inequalities (0-3 mod 5) */
+ for (i = 0; i < lscratch; i++) scratch[i] = (i%o2)*5 + 4 - (i/o2);
generate:
#ifdef STANDALONE_SOLVER
@@ -1018,7 +1015,9 @@ generate:
if (sq) sfree(sq);
sq = latin_generate(params->order, rs);
latin_debug(sq, params->order);
- shuffle(scratch, lscratch, sizeof(int), rs);
+ /* Separately shuffle the numeric and inequality clues */
+ shuffle(scratch, lscratch/5, sizeof(int), rs);
+ shuffle(scratch+lscratch/5, 4*lscratch/5, sizeof(int), rs);
memset(state->nums, 0, o2 * sizeof(digit));
memset(state->flags, 0, o2 * sizeof(unsigned int));
@@ -1324,7 +1323,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
static game_state *execute_move(game_state *state, char *move)
{
game_state *ret = NULL;
- int x, y, n, i;
+ int x, y, n, i, rc;
debug(("execute_move: %s", move));
@@ -1360,7 +1359,8 @@ static game_state *execute_move(game_state *state, char *move)
p++;
}
if (*p) goto badmove;
- assert_f(check_complete(ret->nums, ret, 1) > 0);
+ rc = check_complete(ret->nums, ret, 1);
+ assert(rc > 0);
return ret;
} else if (move[0] == 'H') {
return solver_hint(state, NULL, DIFF_EASY, DIFF_EASY);