aboutsummaryrefslogtreecommitdiff
path: root/guess.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2017-10-01 12:52:12 +0100
committerSimon Tatham <anakin@pobox.com>2017-10-01 15:18:14 +0100
commiteeb2db283de9115f7256fa4cc49597d63e06b0ab (patch)
tree48de59795d6a338ef56c5a0f1e1247478c6ad6b9 /guess.c
parentedcf839d4c557c3993d681665829390697353344 (diff)
downloadpuzzles-eeb2db283de9115f7256fa4cc49597d63e06b0ab.zip
puzzles-eeb2db283de9115f7256fa4cc49597d63e06b0ab.tar.gz
puzzles-eeb2db283de9115f7256fa4cc49597d63e06b0ab.tar.bz2
puzzles-eeb2db283de9115f7256fa4cc49597d63e06b0ab.tar.xz
New name UI_UPDATE for interpret_move's return "".
Now midend.c directly tests the returned pointer for equality to this value, instead of checking whether it's the empty string. A minor effect of this is that games may now return a dynamically allocated empty string from interpret_move() and treat it as just another legal move description. But I don't expect anyone to be perverse enough to actually do that! The main purpose is that it avoids returning a string literal from a function whose return type is a pointer to _non-const_ char, i.e. we are now one step closer to being able to make this code base clean under -Wwrite-strings.
Diffstat (limited to 'guess.c')
-rw-r--r--guess.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/guess.c b/guess.c
index 8f05863..b3d4a9a 100644
--- a/guess.c
+++ b/guess.c
@@ -779,7 +779,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
*/
if (button == 'l' || button == 'L') {
ui->show_labels = !ui->show_labels;
- return "";
+ return UI_UPDATE;
}
if (from->solved) return NULL;
@@ -836,13 +836,13 @@ static char *interpret_move(const game_state *from, game_ui *ui,
ui->drag_y = y;
debug(("Start dragging, col = %d, (%d,%d)",
ui->drag_col, ui->drag_x, ui->drag_y));
- ret = "";
+ ret = UI_UPDATE;
}
} else if (button == LEFT_DRAG && ui->drag_col) {
ui->drag_x = x;
ui->drag_y = y;
debug(("Keep dragging, (%d,%d)", ui->drag_x, ui->drag_y));
- ret = "";
+ ret = UI_UPDATE;
} else if (button == LEFT_RELEASE && ui->drag_col) {
if (over_guess > -1) {
debug(("Dropping colour %d onto guess peg %d",
@@ -859,13 +859,13 @@ static char *interpret_move(const game_state *from, game_ui *ui,
ui->drag_opeg = -1;
ui->display_cur = 0;
debug(("Stop dragging."));
- ret = "";
+ ret = UI_UPDATE;
} else if (button == RIGHT_BUTTON) {
if (over_guess > -1) {
/* we use ths feedback in the game_ui to signify
* 'carry this peg to the next guess as well'. */
ui->holds[over_guess] = 1 - ui->holds[over_guess];
- ret = "";
+ ret = UI_UPDATE;
}
} else if (button == LEFT_RELEASE && over_hint && ui->markable) {
/* NB this won't trigger if on the end of a drag; that's on
@@ -880,10 +880,10 @@ static char *interpret_move(const game_state *from, game_ui *ui,
ui->colour_cur++;
if (button == CURSOR_UP && ui->colour_cur > 0)
ui->colour_cur--;
- ret = "";
+ ret = UI_UPDATE;
} else if (button == 'h' || button == 'H' || button == '?') {
compute_hint(from, ui);
- ret = "";
+ ret = UI_UPDATE;
} else if (button == CURSOR_LEFT || button == CURSOR_RIGHT) {
int maxcur = from->params.npegs;
if (ui->markable) maxcur++;
@@ -893,25 +893,25 @@ static char *interpret_move(const game_state *from, game_ui *ui,
ui->peg_cur++;
if (button == CURSOR_LEFT && ui->peg_cur > 0)
ui->peg_cur--;
- ret = "";
+ ret = UI_UPDATE;
} else if (IS_CURSOR_SELECT(button)) {
ui->display_cur = 1;
if (ui->peg_cur == from->params.npegs) {
ret = encode_move(from, ui);
} else {
set_peg(&from->params, ui, ui->peg_cur, ui->colour_cur+1);
- ret = "";
+ ret = UI_UPDATE;
}
} else if (button == 'D' || button == 'd' || button == '\b') {
ui->display_cur = 1;
set_peg(&from->params, ui, ui->peg_cur, 0);
- ret = "";
+ ret = UI_UPDATE;
} else if (button == CURSOR_SELECT2) {
if (ui->peg_cur == from->params.npegs)
return NULL;
ui->display_cur = 1;
ui->holds[ui->peg_cur] = 1 - ui->holds[ui->peg_cur];
- ret = "";
+ ret = UI_UPDATE;
}
return ret;
}