X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tents.c;h=4ffeb7be64f95e0224f988ba8f1e138f07f6515c;hb=db313b3948d27244dd7c34c2609c66d6204d8931;hp=6ad71ef3e186477f4bfff40c23d24b7072f86c30;hpb=9e1a7d87cd30e1f3fde7eedf1439b48ce1610009;p=sgt-puzzles.git diff --git a/tents.c b/tents.c index 6ad71ef..4ffeb7b 100644 --- a/tents.c +++ b/tents.c @@ -1063,7 +1063,7 @@ static char *new_game_desc(const game_params *params_in, random_state *rs, j = maxflow(w*h+2, w*h+1, w*h, nedges, edges, capacity, flow, NULL); if (j < ntrees) - continue; /* couldn't place all the tents */ + continue; /* couldn't place all the trees */ /* * We've placed the trees. Now we need to work out _where_ @@ -1544,6 +1544,9 @@ static char *interpret_move(const game_state *state, game_ui *ui, { int w = state->p.w, h = state->p.h; char tmpbuf[80]; + int shift = button & MOD_SHFT, control = button & MOD_CTRL; + + button &= ~MOD_MASK; if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { x = FROMCOORD(x); @@ -1640,8 +1643,26 @@ static char *interpret_move(const game_state *state, game_ui *ui, } if (IS_CURSOR_MOVE(button)) { - move_cursor(button, &ui->cx, &ui->cy, w, h, 0); ui->cdisp = 1; + if (shift || control) { + int len = 0, i, indices[2]; + indices[0] = ui->cx + w * ui->cy; + move_cursor(button, &ui->cx, &ui->cy, w, h, 0); + indices[1] = ui->cx + w * ui->cy; + + /* NONTENTify all unique traversed eligible squares */ + for (i = 0; i <= (indices[0] != indices[1]); ++i) + if (state->grid[indices[i]] == BLANK || + (control && state->grid[indices[i]] == TENT)) { + len += sprintf(tmpbuf + len, "%sN%d,%d", len ? ";" : "", + indices[i] % w, indices[i] / w); + assert(len < lenof(tmpbuf)); + } + + tmpbuf[len] = '\0'; + if (len) return dupstr(tmpbuf); + } else + move_cursor(button, &ui->cx, &ui->cy, w, h, 0); return ""; } if (ui->cdisp) { @@ -2590,7 +2611,7 @@ static void game_print(drawing *dr, const game_state *state, int tilesize) const struct game thegame = { "Tents", "games.tents", "tents", default_params, - game_fetch_preset, + game_fetch_preset, NULL, decode_params, encode_params, free_params,