chiark
/
gitweb
/
~ian
/
sgt-puzzles.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Forbid undo of new-game if it would change the params.
[sgt-puzzles.git]
/
galaxies.c
diff --git
a/galaxies.c
b/galaxies.c
index d2d2eda75852dc8a21813ecf4ff56579492521a2..f4f75c629c7889b506b48c7c36f087e939003a37 100644
(file)
--- a/
galaxies.c
+++ b/
galaxies.c
@@
-152,8
+152,9
@@
static int check_complete(const game_state *state, int *dsf, int *colours);
static int solver_state(game_state *state, int maxdiff);
static int solver_obvious(game_state *state);
static int solver_obvious_dot(game_state *state, space *dot);
static int solver_state(game_state *state, int maxdiff);
static int solver_obvious(game_state *state);
static int solver_obvious_dot(game_state *state, space *dot);
-static space *space_opposite_dot(game_state *state, space *sp, space *dot);
-static space *tile_opposite(game_state *state, space *sp);
+static space *space_opposite_dot(const game_state *state, const space *sp,
+ const space *dot);
+static space *tile_opposite(const game_state *state, const space *sp);
/* ----------------------------------------------------------
* Game parameters and presets
/* ----------------------------------------------------------
* Game parameters and presets
@@
-372,7
+373,9
@@
static void add_assoc_with_opposite(game_state *state, space *tile, space *dot)
}
sfree(colors);
}
sfree(colors);
+ remove_assoc_with_opposite(state, tile);
add_assoc(state, tile, dot);
add_assoc(state, tile, dot);
+ remove_assoc_with_opposite(state, opposite);
add_assoc(state, opposite, dot);
}
add_assoc(state, opposite, dot);
}
@@
-552,7
+555,8
@@
static int edges_into_vertex(game_state *state,
}
#endif
}
#endif
-static space *space_opposite_dot(game_state *state, space *sp, space *dot)
+static space *space_opposite_dot(const game_state *state, const space *sp,
+ const space *dot)
{
int dx, dy, tx, ty;
space *sp2;
{
int dx, dy, tx, ty;
space *sp2;
@@
-568,7
+572,7
@@
static space *space_opposite_dot(game_state *state, space *sp, space *dot)
return sp2;
}
return sp2;
}
-static space *tile_opposite(
game_state *state,
space *sp)
+static space *tile_opposite(
const game_state *state, const
space *sp)
{
space *dot;
{
space *dot;
@@
-1297,6
+1301,8
@@
generate:
game_update_dots(state);
game_update_dots(state);
+ if (state->ndots == 1) goto generate;
+
#ifdef DEBUGGING
{
char *tmp = encode_game(state);
#ifdef DEBUGGING
{
char *tmp = encode_game(state);
@@
-2587,7
+2593,7
@@
static char *interpret_move(const game_state *state, game_ui *ui,
if (INUI(state, px, py)) {
sp = &SPACE(state, px, py);
if (INUI(state, px, py)) {
sp = &SPACE(state, px, py);
- if (!(sp->flags & F_DOT)
&& !(sp->flags & F_TILE_ASSOC)
)
+ if (!(sp->flags & F_DOT))
sprintf(buf + strlen(buf), "%sA%d,%d,%d,%d",
sep, px, py, ui->dotx, ui->doty);
}
sprintf(buf + strlen(buf), "%sA%d,%d,%d,%d",
sep, px, py, ui->dotx, ui->doty);
}
@@
-3261,7
+3267,7
@@
static void game_redraw(drawing *dr, game_drawstate *ds,
for (x = 0; x < w; x++) {
unsigned long flags = 0;
int ddx = 0, ddy = 0;
for (x = 0; x < w; x++) {
unsigned long flags = 0;
int ddx = 0, ddy = 0;
- space *sp;
+ space *sp
, *opp
;
int dx, dy;
/*
int dx, dy;
/*
@@
-3299,6
+3305,11
@@
static void game_redraw(drawing *dr, game_drawstate *ds,
* everything goes briefly back to background colour.
*/
sp = &SPACE(state, x*2+1, y*2+1);
* everything goes briefly back to background colour.
*/
sp = &SPACE(state, x*2+1, y*2+1);
+ if (sp->flags & F_TILE_ASSOC) {
+ opp = tile_opposite(state, sp);
+ } else {
+ opp = NULL;
+ }
if (ds->colour_scratch[y*w+x] && !flashing) {
flags |= (ds->colour_scratch[y*w+x] == 2 ?
DRAW_BLACK : DRAW_WHITE);
if (ds->colour_scratch[y*w+x] && !flashing) {
flags |= (ds->colour_scratch[y*w+x] == 2 ?
DRAW_BLACK : DRAW_WHITE);
@@
-3314,7
+3325,9
@@
static void game_redraw(drawing *dr, game_drawstate *ds,
*/
if ((sp->flags & F_TILE_ASSOC) && !ds->colour_scratch[y*w+x]) {
if (ui->dragging && ui->srcx == x*2+1 && ui->srcy == y*2+1) {
*/
if ((sp->flags & F_TILE_ASSOC) && !ds->colour_scratch[y*w+x]) {
if (ui->dragging && ui->srcx == x*2+1 && ui->srcy == y*2+1) {
- /* don't do it */
+ /* tile is the source, don't do it */
+ } else if (ui->dragging && opp && ui->srcx == opp->x && ui->srcy == opp->y) {
+ /* opposite tile is the source, don't do it */
} else if (sp->doty != y*2+1 || sp->dotx != x*2+1) {
flags |= DRAW_ARROW;
ddy = sp->doty - (y*2+1);
} else if (sp->doty != y*2+1 || sp->dotx != x*2+1) {
flags |= DRAW_ARROW;
ddy = sp->doty - (y*2+1);
@@
-3620,7
+3633,7
@@
static void game_print(drawing *dr, const game_state *state, int sz)
const struct game thegame = {
"Galaxies", "games.galaxies", "galaxies",
default_params,
const struct game thegame = {
"Galaxies", "games.galaxies", "galaxies",
default_params,
- game_fetch_preset,
+ game_fetch_preset,
NULL,
decode_params,
encode_params,
free_params,
decode_params,
encode_params,
free_params,