mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Patch from James H which shouldn't change the functionality of
Loopy, but makes it build more sensibly on the Palm. [originally from svn r7114]
This commit is contained in:
27
loopy.c
27
loopy.c
@ -1876,10 +1876,7 @@ const static struct dline dlines[] = {
|
|||||||
(d==DLINE_DR) ? "DLINE_DR": \
|
(d==DLINE_DR) ? "DLINE_DR": \
|
||||||
"oops")
|
"oops")
|
||||||
|
|
||||||
static const struct dline *get_dline(enum dline_desc desc)
|
#define CHECK_DLINE_SENSIBLE(d) assert(dlines[(d)].dx != -1 && dlines[(d)].dy != -1)
|
||||||
{
|
|
||||||
return &dlines[desc];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This will fail an assertion if the directions handed to it are the same, as
|
/* This will fail an assertion if the directions handed to it are the same, as
|
||||||
* no dline corresponds to that */
|
* no dline corresponds to that */
|
||||||
@ -1932,10 +1929,9 @@ static int set_dot_dline(game_state *state, char *dline_array,
|
|||||||
static int get_square_dline(game_state *state, char *dline_array,
|
static int get_square_dline(game_state *state, char *dline_array,
|
||||||
int i, int j, enum dline_desc desc)
|
int i, int j, enum dline_desc desc)
|
||||||
{
|
{
|
||||||
const struct dline *dl = get_dline(desc);
|
CHECK_DLINE_SENSIBLE(desc);
|
||||||
assert(dl->dx != -1 && dl->dy != -1);
|
|
||||||
/* fprintf(stderr, "get_square_dline %p [%d,%d] %s\n", dline_array, i, j, DL2STR(desc)); */
|
/* fprintf(stderr, "get_square_dline %p [%d,%d] %s\n", dline_array, i, j, DL2STR(desc)); */
|
||||||
return BIT_SET(dline_array[(i+dl->dx) + (state->w + 1) * (j+dl->dy)],
|
return BIT_SET(dline_array[(i+dlines[desc].dx) + (state->w + 1) * (j+dlines[desc].dy)],
|
||||||
desc);
|
desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1946,10 +1942,9 @@ static int set_square_dline(game_state *state, char *dline_array,
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const struct dline *dl = get_dline(desc);
|
|
||||||
int ret;
|
int ret;
|
||||||
assert(dl->dx != -1 && dl->dy != -1);
|
CHECK_DLINE_SENSIBLE(desc);
|
||||||
ret = SET_BIT(dline_array[(i+dl->dx) + (state->w + 1) * (j+dl->dy)], desc);
|
ret = SET_BIT(dline_array[(i+dlines[desc].dx) + (state->w + 1) * (j+dlines[desc].dy)], desc);
|
||||||
#ifdef SHOW_WORKING
|
#ifdef SHOW_WORKING
|
||||||
if (ret)
|
if (ret)
|
||||||
fprintf(stderr, "set_square_dline %p [%d,%d] %s (%s)\n", dline_array, i, j, DL2STR(desc), reason);
|
fprintf(stderr, "set_square_dline %p [%d,%d] %s (%s)\n", dline_array, i, j, DL2STR(desc), reason);
|
||||||
@ -1980,10 +1975,9 @@ static int set_square_opp_dline(game_state *state, char *dline_array,
|
|||||||
static int dline_both_unknown(const game_state *state, int i, int j,
|
static int dline_both_unknown(const game_state *state, int i, int j,
|
||||||
enum dline_desc desc)
|
enum dline_desc desc)
|
||||||
{
|
{
|
||||||
const struct dline *dl = get_dline(desc);
|
|
||||||
return
|
return
|
||||||
(get_line_status_from_point(state, i, j, dl->dir1) == LINE_UNKNOWN) &&
|
(get_line_status_from_point(state, i, j, dlines[desc].dir1) == LINE_UNKNOWN) &&
|
||||||
(get_line_status_from_point(state, i, j, dl->dir2) == LINE_UNKNOWN);
|
(get_line_status_from_point(state, i, j, dlines[desc].dir2) == LINE_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SQUARE_DLINES \
|
#define SQUARE_DLINES \
|
||||||
@ -2143,14 +2137,14 @@ static int square_setboth_in_dline(solver_state *sstate, enum dline_desc dd,
|
|||||||
int i, int j, enum line_state line_new)
|
int i, int j, enum line_state line_new)
|
||||||
{
|
{
|
||||||
int retval = FALSE;
|
int retval = FALSE;
|
||||||
const struct dline *dl = get_dline(dd);
|
const struct dline dll = dlines[dd], *dl = &dll;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "square_setboth_in_dline %s [%d,%d] to %d\n",
|
fprintf(stderr, "square_setboth_in_dline %s [%d,%d] to %d\n",
|
||||||
DL2STR(dd), i, j, line_new);
|
DL2STR(dd), i, j, line_new);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(dl->dx != -1 && dl->dy != -1);
|
CHECK_DLINE_SENSIBLE(dd);
|
||||||
|
|
||||||
retval |=
|
retval |=
|
||||||
set_line_bydot(sstate, i+dl->dx, j+dl->dy, dl->dir1, line_new);
|
set_line_bydot(sstate, i+dl->dx, j+dl->dy, dl->dir1, line_new);
|
||||||
@ -2651,7 +2645,6 @@ static int hard_mode_deductions(solver_state *sstate)
|
|||||||
enum direction dir1, dir2;
|
enum direction dir1, dir2;
|
||||||
int can1, can2, inv1, inv2;
|
int can1, can2, inv1, inv2;
|
||||||
int diff = DIFF_MAX;
|
int diff = DIFF_MAX;
|
||||||
const struct dline *dl;
|
|
||||||
enum dline_desc dd;
|
enum dline_desc dd;
|
||||||
|
|
||||||
FORALL_SQUARES(state, i, j) {
|
FORALL_SQUARES(state, i, j) {
|
||||||
@ -2774,7 +2767,7 @@ static int hard_mode_deductions(solver_state *sstate)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
FORALL_DOT_DLINES(dd) {
|
FORALL_DOT_DLINES(dd) {
|
||||||
dl = get_dline(dd);
|
const struct dline dll = dlines[dd], *dl = &dll;
|
||||||
if (i == 0 && (dl->dir1 == LEFT || dl->dir2 == LEFT))
|
if (i == 0 && (dl->dir1 == LEFT || dl->dir2 == LEFT))
|
||||||
continue;
|
continue;
|
||||||
if (i == w && (dl->dir1 == RIGHT || dl->dir2 == RIGHT))
|
if (i == w && (dl->dir1 == RIGHT || dl->dir2 == RIGHT))
|
||||||
|
Reference in New Issue
Block a user