mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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:
28
signpost.c
28
signpost.c
@ -1441,18 +1441,20 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
ui->dx = COORD(ui->cx) + TILE_SIZE/2;
|
||||
ui->dy = COORD(ui->cy) + TILE_SIZE/2;
|
||||
}
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
} else if (IS_CURSOR_SELECT(button)) {
|
||||
if (!ui->cshow)
|
||||
ui->cshow = 1;
|
||||
else if (ui->dragging) {
|
||||
ui->dragging = FALSE;
|
||||
if (ui->sx == ui->cx && ui->sy == ui->cy) return "";
|
||||
if (ui->sx == ui->cx && ui->sy == ui->cy) return UI_UPDATE;
|
||||
if (ui->drag_is_from) {
|
||||
if (!isvalidmove(state, 0, ui->sx, ui->sy, ui->cx, ui->cy)) return "";
|
||||
if (!isvalidmove(state, 0, ui->sx, ui->sy, ui->cx, ui->cy))
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "L%d,%d-%d,%d", ui->sx, ui->sy, ui->cx, ui->cy);
|
||||
} else {
|
||||
if (!isvalidmove(state, 0, ui->cx, ui->cy, ui->sx, ui->sy)) return "";
|
||||
if (!isvalidmove(state, 0, ui->cx, ui->cy, ui->sx, ui->sy))
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "L%d,%d-%d,%d", ui->cx, ui->cy, ui->sx, ui->sy);
|
||||
}
|
||||
return dupstr(buf);
|
||||
@ -1464,7 +1466,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
ui->dy = COORD(ui->cy) + TILE_SIZE/2;
|
||||
ui->drag_is_from = (button == CURSOR_SELECT) ? 1 : 0;
|
||||
}
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
}
|
||||
if (IS_MOUSE_DOWN(button)) {
|
||||
if (ui->cshow) {
|
||||
@ -1492,29 +1494,31 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
ui->dx = mx;
|
||||
ui->dy = my;
|
||||
ui->cshow = 0;
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
} else if (IS_MOUSE_DRAG(button) && ui->dragging) {
|
||||
ui->dx = mx;
|
||||
ui->dy = my;
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
} else if (IS_MOUSE_RELEASE(button) && ui->dragging) {
|
||||
ui->dragging = FALSE;
|
||||
if (ui->sx == x && ui->sy == y) return ""; /* single click */
|
||||
if (ui->sx == x && ui->sy == y) return UI_UPDATE; /* single click */
|
||||
|
||||
if (!INGRID(state, x, y)) {
|
||||
int si = ui->sy*w+ui->sx;
|
||||
if (state->prev[si] == -1 && state->next[si] == -1)
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "%c%d,%d",
|
||||
(int)(ui->drag_is_from ? 'C' : 'X'), ui->sx, ui->sy);
|
||||
return dupstr(buf);
|
||||
}
|
||||
|
||||
if (ui->drag_is_from) {
|
||||
if (!isvalidmove(state, 0, ui->sx, ui->sy, x, y)) return "";
|
||||
if (!isvalidmove(state, 0, ui->sx, ui->sy, x, y))
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "L%d,%d-%d,%d", ui->sx, ui->sy, x, y);
|
||||
} else {
|
||||
if (!isvalidmove(state, 0, x, y, ui->sx, ui->sy)) return "";
|
||||
if (!isvalidmove(state, 0, x, y, ui->sx, ui->sy))
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "L%d,%d-%d,%d", x, y, ui->sx, ui->sy);
|
||||
}
|
||||
return dupstr(buf);
|
||||
@ -1523,7 +1527,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
else if ((button == 'x' || button == 'X') && ui->cshow) {
|
||||
int si = ui->cy*w + ui->cx;
|
||||
if (state->prev[si] == -1 && state->next[si] == -1)
|
||||
return "";
|
||||
return UI_UPDATE;
|
||||
sprintf(buf, "%c%d,%d",
|
||||
(int)((button == 'x') ? 'C' : 'X'), ui->cx, ui->cy);
|
||||
return dupstr(buf);
|
||||
|
Reference in New Issue
Block a user