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.
This commit is contained in:
Simon Tatham
2017-10-01 12:52:12 +01:00
parent edcf839d4c
commit eeb2db283d
41 changed files with 217 additions and 201 deletions

View File

@ -1449,22 +1449,22 @@ static char *interpret_move(const game_state *state, game_ui *ui,
ui->sel[w*ty+tx] = 1;
}
ui->cur_visible = 0;
return ""; /* redraw */
return UI_UPDATE;
}
if (IS_CURSOR_MOVE(button)) {
ui->cur_visible = 1;
move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0);
if (ui->keydragging) goto select_square;
return "";
return UI_UPDATE;
}
if (button == CURSOR_SELECT) {
if (!ui->cur_visible) {
ui->cur_visible = 1;
return "";
return UI_UPDATE;
}
ui->keydragging = !ui->keydragging;
if (!ui->keydragging) return "";
if (!ui->keydragging) return UI_UPDATE;
select_square:
if (!ui->sel) {
@ -1473,12 +1473,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
}
if (!state->shared->clues[w*ui->cur_y + ui->cur_x])
ui->sel[w*ui->cur_y + ui->cur_x] = 1;
return "";
return UI_UPDATE;
}
if (button == CURSOR_SELECT2) {
if (!ui->cur_visible) {
ui->cur_visible = 1;
return "";
return UI_UPDATE;
}
if (!ui->sel) {
ui->sel = snewn(w*h, int);
@ -1492,14 +1492,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
sfree(ui->sel);
ui->sel = NULL;
}
return "";
return UI_UPDATE;
}
if (button == '\b' || button == 27) {
sfree(ui->sel);
ui->sel = NULL;
ui->keydragging = FALSE;
return "";
return UI_UPDATE;
}
if (button < '0' || button > '9') return NULL;
@ -1534,7 +1534,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
sfree(ui->sel);
ui->sel = NULL;
/* Need to update UI at least, as we cleared the selection */
return move ? move : "";
return move ? move : UI_UPDATE;
}
static game_state *execute_move(const game_state *state, const char *move)