chiark / gitweb /
New name UI_UPDATE for interpret_move's return "".
authorSimon Tatham <anakin@pobox.com>
Sun, 1 Oct 2017 11:52:12 +0000 (12:52 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 1 Oct 2017 14:18:14 +0000 (15:18 +0100)
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.

41 files changed:
blackbox.c
bridges.c
devel.but
dominosa.c
filling.c
flip.c
flood.c
galaxies.c
guess.c
keen.c
lightup.c
magnets.c
map.c
midend.c
mines.c
misc.c
net.c
netslide.c
palisade.c
pattern.c
pearl.c
pegs.c
puzzles.h
range.c
rect.c
samegame.c
signpost.c
singles.c
sixteen.c
slant.c
solo.c
tents.c
towers.c
tracks.c
twiddle.c
undead.c
unequal.c
unfinished/group.c
unfinished/slide.c
unruly.c
untangle.c

index b334cf7117ec6423cef22e9bb5dec03ef6ffb96d..422b7521a496ba2967559b80f9ce0f4f1b4597ef 100644 (file)
@@ -902,7 +902,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->cur_x = cx;
         ui->cur_y = cy;
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
@@ -912,7 +912,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         wouldflash = 1;
     } else if (button == LEFT_RELEASE) {
         ui->flash_laser = 0;
-        return "";
+        return UI_UPDATE;
     } else if (IS_CURSOR_SELECT(button)) {
         if (ui->cur_visible) {
             gx = ui->cur_x;
@@ -921,7 +921,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             wouldflash = 2;
         } else {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         /* Fix up 'button' for the below logic. */
         if (button == CURSOR_SELECT2) button = RIGHT_BUTTON;
@@ -970,9 +970,9 @@ static char *interpret_move(const game_state *state, game_ui *ui,
            return nullret;
         ui->flash_laserno = rangeno;
         ui->flash_laser = wouldflash;
-        nullret = "";
+        nullret = UI_UPDATE;
         if (state->exits[rangeno] != LASER_EMPTY)
-            return "";
+            return UI_UPDATE;
         sprintf(buf, "F%d", rangeno);
         break;
 
index 6975208fd62094c64f8c8d1d5bbcd4c170efcc92..ebf73234cf2cb15d18e698c5862fd2dced5b6499 100644 (file)
--- a/bridges.c
+++ b/bridges.c
@@ -2094,7 +2094,7 @@ static char *ui_cancel_drag(game_ui *ui)
     ui->dragx_src = ui->dragy_src = -1;
     ui->dragx_dst = ui->dragy_dst = -1;
     ui->dragging = 0;
-    return "";
+    return UI_UPDATE;
 }
 
 static game_ui *new_ui(const game_state *state)
@@ -2282,7 +2282,7 @@ static char *update_drag_dst(const game_state *state, game_ui *ui,
     /*debug(("update_drag src (%d,%d) d(%d,%d) dst (%d,%d)\n",
            ui->dragx_src, ui->dragy_src, dx, dy,
            ui->dragx_dst, ui->dragy_dst));*/
-    return "";
+    return UI_UPDATE;
 }
 
 static char *finish_drag(const game_state *state, game_ui *ui)
@@ -2325,7 +2325,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         if (ggrid & G_ISLAND) {
             ui->dragx_src = gx;
             ui->dragy_src = gy;
-            return "";
+            return UI_UPDATE;
         } else
             return ui_cancel_drag(ui);
     } else if (button == LEFT_DRAG || button == RIGHT_DRAG) {
@@ -2339,7 +2339,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             /* cancel a drag when we go back to the starting point */
             ui->dragx_dst = -1;
             ui->dragy_dst = -1;
-            return "";
+            return UI_UPDATE;
         }
     } else if (button == LEFT_RELEASE || button == RIGHT_RELEASE) {
         if (ui->dragging) {
@@ -2424,19 +2424,19 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
                     if (!dingrid) break;
                 }
-                if (!oingrid) return "";
+                if (!oingrid) return UI_UPDATE;
             }
             /* not reached */
 
 found:
             ui->cur_x = nx;
             ui->cur_y = ny;
-            return "";
+            return UI_UPDATE;
         }
     } else if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         if (ui->dragging || button == CURSOR_SELECT2) {
             ui_cancel_drag(ui);
@@ -2444,7 +2444,7 @@ found:
                 sprintf(buf, "M%d,%d", ui->cur_x, ui->cur_y);
                 return dupstr(buf);
             } else
-                return "";
+                return UI_UPDATE;
         } else {
             grid_type v = GRID(state, ui->cur_x, ui->cur_y);
             if (v & G_ISLAND) {
@@ -2453,7 +2453,7 @@ found:
                 ui->dragy_src = ui->cur_y;
                 ui->dragx_dst = ui->dragy_dst = -1;
                 ui->drag_is_noline = (button == CURSOR_SELECT2) ? 1 : 0;
-                return "";
+                return UI_UPDATE;
             }
         }
     } else if ((button >= '0' && button <= '9') ||
@@ -2471,7 +2471,7 @@ found:
 
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
 
         for (i = 0; i < state->n_islands; ++i) {
@@ -2498,12 +2498,12 @@ found:
         if (best_x != -1 && best_y != -1) {
             ui->cur_x = best_x;
             ui->cur_y = best_y;
-            return "";
+            return UI_UPDATE;
         } else
             return NULL;
     } else if (button == 'g' || button == 'G') {
         ui->show_hints = 1 - ui->show_hints;
-        return "";
+        return UI_UPDATE;
     }
 
     return NULL;
index 25a6c62dfa5d3fb198a35c0432e8523cfd9993fb..16aaf02d35dc3fd99128dbeb3678fb7489c0d9bb 100644 (file)
--- a/devel.but
+++ b/devel.but
@@ -907,10 +907,10 @@ divide mouse coordinates by it.)
 in response to the input event; the puzzle was not interested in it
 at all.
 
-\b Returning the empty string (\cw{""}) indicates that the input
+\b Returning the special value \cw{UI_UPDATE} indicates that the input
 event has resulted in a change being made to the \c{game_ui} which
-will require a redraw of the game window, but that no actual
-\e{move} was made (i.e. no new \c{game_state} needs to be created).
+will require a redraw of the game window, but that no actual \e{move}
+was made (i.e. no new \c{game_state} needs to be created).
 
 \b Returning anything else indicates that a move was made and that a
 new \c{game_state} must be created. However, instead of actually
@@ -925,7 +925,7 @@ strings can be written to disk when saving the game and fed to
 
 The return value from \cw{interpret_move()} is expected to be
 dynamically allocated if and only if it is not either \cw{NULL}
-\e{or} the empty string.
+\e{or} the special string constant \c{UI_UPDATE}.
 
 After this function is called, the back end is permitted to rely on
 some subsequent operations happening in sequence:
index c86ba19dfade335d9925fbef8ca1b354513e5037..5a3016b4bed2f5e459002920ba0b2dbe145b65e4 100644 (file)
@@ -1119,7 +1119,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
         move_cursor(button, &ui->cur_x, &ui->cur_y, 2*w-1, 2*h-1, 0);
 
-       return "";
+       return UI_UPDATE;
     } else if (IS_CURSOR_SELECT(button)) {
         int d1, d2;
 
@@ -1152,7 +1152,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         } else {
             return NULL;
         }
-        return "";
+        return UI_UPDATE;
     }
 
     return NULL;
index d8d0c8cbb035b62addce8d3f35462807847e7fbf..d0883afc46b469fac5b5b73a3af486b1a5a333fe 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -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)
diff --git a/flip.c b/flip.c
index c7126fb7d964fa240cfef570eae446f9daa4bf8e..68979fee9dacdac6e5c58cccc6e274003965c618 100644 (file)
--- a/flip.c
+++ b/flip.c
@@ -951,7 +951,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             tx = ui->cx; ty = ui->cy;
             ui->cdraw = 1;
         }
-        nullret = "";
+        nullret = UI_UPDATE;
 
         if (tx >= 0 && tx < w && ty >= 0 && ty < h) {
             /*
@@ -985,7 +985,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->cx = min(max(ui->cx, 0), state->w - 1);
         ui->cy = min(max(ui->cy, 0), state->h - 1);
         ui->cdraw = 1;
-        nullret = "";
+        nullret = UI_UPDATE;
     }
 
     return nullret;
diff --git a/flood.c b/flood.c
index 1262be8175cbb4ac17de13d0110f3b8753965781..247c5096a2b03c596c4a173cd16ecf9c0c5bca6a 100644 (file)
--- a/flood.c
+++ b/flood.c
@@ -830,19 +830,19 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     } else if (button == CURSOR_LEFT && ui->cx > 0) {
         ui->cx--;
         ui->cursor_visible = TRUE;
-        return "";
+        return UI_UPDATE;
     } else if (button == CURSOR_RIGHT && ui->cx+1 < w) {
         ui->cx++;
         ui->cursor_visible = TRUE;
-        return "";
+        return UI_UPDATE;
     } else if (button == CURSOR_UP && ui->cy > 0) {
         ui->cy--;
         ui->cursor_visible = TRUE;
-        return "";
+        return UI_UPDATE;
     } else if (button == CURSOR_DOWN && ui->cy+1 < h) {
         ui->cy++;
         ui->cursor_visible = TRUE;
-        return "";
+        return UI_UPDATE;
     } else if (button == CURSOR_SELECT) {
         tx = ui->cx;
         ty = ui->cy;
index f4f75c629c7889b506b48c7c36f087e939003a37..03bed9cbbf9755e28ff9b0d9e8490cc89377fc35 100644 (file)
@@ -2553,13 +2553,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->dy = y;
             ui->dotx = dot->x;
             ui->doty = dot->y;
-            return "";
+            return UI_UPDATE;
         }
     } else if (button == RIGHT_DRAG && ui->dragging) {
         /* just move the drag coords. */
         ui->dx = x;
         ui->dy = y;
-        return "";
+        return UI_UPDATE;
     } else if (button == RIGHT_RELEASE && ui->dragging) {
         ui->dragging = FALSE;
 
@@ -2574,7 +2574,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         * is a null move; just update the ui and finish.
         */
        if (px == ui->srcx && py == ui->srcy)
-           return "";
+           return UI_UPDATE;
 
        /*
         * Otherwise, we remove the arrow from its starting
@@ -2601,7 +2601,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        if (buf[0])
            return dupstr(buf);
        else
-           return "";
+           return UI_UPDATE;
     } else if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->cur_x, &ui->cur_y, state->sx-1, state->sy-1, 0);
         if (ui->cur_x < 1) ui->cur_x = 1;
@@ -2611,11 +2611,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->dx = SCOORD(ui->cur_x);
             ui->dy = SCOORD(ui->cur_y);
         }
-        return "";
+        return UI_UPDATE;
     } else if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         sp = &SPACE(state, ui->cur_x, ui->cur_y);
         if (ui->dragging) {
@@ -2637,7 +2637,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->dy = SCOORD(ui->cur_y);
             ui->dotx = ui->srcx = ui->cur_x;
             ui->doty = ui->srcy = ui->cur_y;
-            return "";
+            return UI_UPDATE;
         } else if (sp->flags & F_TILE_ASSOC) {
             assert(sp->type == s_tile);
             ui->dragging = TRUE;
@@ -2647,7 +2647,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->doty = sp->doty;
             ui->srcx = ui->cur_x;
             ui->srcy = ui->cur_y;
-            return "";
+            return UI_UPDATE;
         } else if (sp->type == s_edge) {
             sprintf(buf, "E%d,%d", ui->cur_x, ui->cur_y);
             return dupstr(buf);
diff --git a/guess.c b/guess.c
index 8f058638daa68d521b2d9aada412484b82aa493d..b3d4a9a8e9ce2d5cfc1d8cccd695a8f11817ddaa 100644 (file)
--- 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;
 }
diff --git a/keen.c b/keen.c
index fdaae32e5dd263fd54a5724618b267a04dad6254..a3fbb74217c887cc3bdab79f900846393bb20c6f 100644 (file)
--- a/keen.c
+++ b/keen.c
@@ -1616,7 +1616,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hpencil = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
         if (button == RIGHT_BUTTON) {
             /*
@@ -1636,19 +1636,19 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hshow = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
     }
     if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->hx, &ui->hy, w, w, 0);
         ui->hshow = ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (ui->hshow &&
         (button == CURSOR_SELECT)) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (ui->hshow &&
index 4dd46c8392eec7111297628b7e6e292340ab086c..a56f3a995189deaa18f758abe817278f39092282 100644 (file)
--- a/lightup.c
+++ b/lightup.c
@@ -1882,7 +1882,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     enum { NONE, FLIP_LIGHT, FLIP_IMPOSSIBLE } action = NONE;
     int cx = -1, cy = -1;
     unsigned int flags;
-    char buf[80], *nullret = NULL, *empty = "", c;
+    char buf[80], *nullret = UI_UPDATE, *empty = UI_UPDATE, c;
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
         if (ui->cur_visible)
index 553ca0d0da13995048a3d91dde6a8c305e5046bc..354c00a524aa0745d303df2cd42c07b02d3cdb8e 100644 (file)
--- a/magnets.c
+++ b/magnets.c
@@ -1804,11 +1804,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->cur_x, &ui->cur_y, state->w, state->h, 0);
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     } else if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         action = (button == CURSOR_SELECT) ? CYCLE_MAGNET : CYCLE_NEUTRAL;
         gx = ui->cur_x;
@@ -1817,7 +1817,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                (button == LEFT_BUTTON || button == RIGHT_BUTTON)) {
         if (ui->cur_visible) {
             ui->cur_visible = 0;
-            nullret = "";
+            nullret = UI_UPDATE;
         }
         action = (button == LEFT_BUTTON) ? CYCLE_MAGNET : CYCLE_NEUTRAL;
     } else if (button == LEFT_BUTTON && is_clue(state, gx, gy)) {
diff --git a/map.c b/map.c
index f1af38ba5edaa0d80af92cee5160079b92ad5a0e..c66e7e2ea409f1e17815c30caaae4e425bbb00fd 100644 (file)
--- a/map.c
+++ b/map.c
@@ -2375,7 +2375,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
      */
     if (button == 'l' || button == 'L') {
         ui->show_numbers = !ui->show_numbers;
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_CURSOR_MOVE(button)) {
@@ -2385,14 +2385,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->cur_lastmove = button;
         ui->dragx = COORD(ui->cur_x) + TILESIZE/2 + EPSILON_X(button);
         ui->dragy = COORD(ui->cur_y) + TILESIZE/2 + EPSILON_Y(button);
-        return "";
+        return UI_UPDATE;
     }
     if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->dragx = COORD(ui->cur_x) + TILESIZE/2 + EPSILON_X(ui->cur_lastmove);
             ui->dragy = COORD(ui->cur_y) + TILESIZE/2 + EPSILON_Y(ui->cur_lastmove);
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         if (ui->drag_colour == -2) { /* not currently cursor-dragging, start. */
             int r = region_from_coords(state, ds, ui->dragx, ui->dragy);
@@ -2404,7 +2404,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->drag_pencil = 0;
             }
             ui->cur_moved = 0;
-            return "";
+            return UI_UPDATE;
         } else { /* currently cursor-dragging; drop the colour in the new region. */
             x = COORD(ui->cur_x) + TILESIZE/2 + EPSILON_X(ui->cur_lastmove);
             y = COORD(ui->cur_y) + TILESIZE/2 + EPSILON_Y(ui->cur_lastmove);
@@ -2430,14 +2430,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->dragx = x;
         ui->dragy = y;
         ui->cur_visible = 0;
-        return "";
+        return UI_UPDATE;
     }
 
     if ((button == LEFT_DRAG || button == RIGHT_DRAG) &&
         ui->drag_colour > -2) {
         ui->dragx = x;
         ui->dragy = y;
-        return "";
+        return UI_UPDATE;
     }
 
     if ((button == LEFT_RELEASE || button == RIGHT_RELEASE) &&
@@ -2461,18 +2461,18 @@ drag_dropped:
         ui->drag_colour = -2;
 
        if (r < 0)
-            return "";                 /* drag into border; do nothing else */
+            return UI_UPDATE;          /* drag into border; do nothing else */
 
        if (state->map->immutable[r])
-           return "";                 /* can't change this region */
+           return UI_UPDATE;          /* can't change this region */
 
         if (state->colouring[r] == c && state->pencil[r] == p)
-            return "";                 /* don't _need_ to change this region */
+            return UI_UPDATE;          /* don't _need_ to change this region */
 
        if (alt_button) {
            if (state->colouring[r] >= 0) {
                /* Can't pencil on a coloured region */
-               return "";
+               return UI_UPDATE;
            } else if (c >= 0) {
                /* Right-dragging from colour to blank toggles one pencil */
                p = state->pencil[r] ^ (1 << c);
index 93334f6807bd60164aaf4b0f2e5d62f78544ff46..913b322414e50f47688f9fe6aef47bb2b3a29523 100644 (file)
--- a/midend.c
+++ b/midend.c
@@ -782,7 +782,7 @@ static int midend_really_process_key(midend *me, int x, int y, int button)
        } else
            goto done;
     } else {
-       if (!*movestr)
+       if (movestr == UI_UPDATE)
            s = me->states[me->statepos-1].state;
        else {
            s = me->ourgame->execute_move(me->states[me->statepos-1].state,
@@ -1662,6 +1662,7 @@ char *midend_solve(midend *me)
     movestr = me->ourgame->solve(me->states[0].state,
                                 me->states[me->statepos-1].state,
                                 me->aux_info, &msg);
+    assert(movestr != UI_UPDATE);
     if (!movestr) {
        if (!msg)
            msg = "Solve operation failed";   /* _shouldn't_ happen, but can */
diff --git a/mines.c b/mines.c
index 57f778a168890a7532928614c8890e08ef253a3d..5bae0e841e18dd150f339d2adc6e7e9f57df2355 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -2432,14 +2432,14 @@ static char *interpret_move(const game_state *from, game_ui *ui,
     if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0);
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (IS_CURSOR_SELECT(button)) {
         int v = from->grid[ui->cur_y * from->w + ui->cur_x];
 
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         if (button == CURSOR_SELECT2) {
             /* As for RIGHT_BUTTON; only works on covered square. */
@@ -2479,7 +2479,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
        else if (button == MIDDLE_BUTTON)
            ui->validradius = 1;
         ui->cur_visible = 0;
-       return "";
+       return UI_UPDATE;
     }
 
     if (button == RIGHT_BUTTON) {
@@ -2507,10 +2507,10 @@ static char *interpret_move(const game_state *from, game_ui *ui,
 
        /*
         * At this stage we must never return NULL: we have adjusted
-        * the ui, so at worst we return "".
+        * the ui, so at worst we return UI_UPDATE.
         */
        if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h)
-           return "";
+           return UI_UPDATE;
 
        /*
         * Left-clicking on a covered square opens a tile. Not
@@ -2588,7 +2588,7 @@ uncover:
            }
        }
 
-       return "";
+       return UI_UPDATE;
     }
 }
 
diff --git a/misc.c b/misc.c
index c1a595fefa77a4dffa1b560f03f7d416e2ba52eb..b44f1b14f854aa8e8a24cf190f95cc6fd39a3102 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -9,6 +9,8 @@
 
 #include "puzzles.h"
 
+char UI_UPDATE[] = "";
+
 void free_cfg(config_item *cfg)
 {
     config_item *i;
diff --git a/net.c b/net.c
index f4a1e39b451981844c66ab365e83aff90cdb4fb3..fc603d1e031683faea275ce7c95ad63726d94128 100644 (file)
--- a/net.c
+++ b/net.c
@@ -2096,7 +2096,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
        if (ui->cur_visible) {
            ui->cur_visible = FALSE;
-           nullret = "";
+           nullret = UI_UPDATE;
        }
 
        /*
@@ -2336,7 +2336,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             OFFSET(ui->cur_x, ui->cur_y, ui->cur_x, ui->cur_y, dir, state);
             ui->cur_visible = TRUE;
         }
-        return "";
+        return UI_UPDATE;
     } else {
        return NULL;
     }
index c56e1abd6a822f88560a3bb1d817a7ef31e3d887..d43dc2e0cb7b94e749bd21788c661888c4b2e6ac 100644 (file)
@@ -1079,7 +1079,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         }
 
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
@@ -1093,7 +1093,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         } else {
             /* 'click' when cursor is invisible just makes cursor visible. */
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
     } else
         return NULL;
index b9d578d0f7f05e1f55c61b95c52f231c86f5c5d4..93c1ad6e51b9e5d9e70b241e4fdff1fe42937604 100644 (file)
@@ -986,7 +986,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                           ui->x, ui->y, flag, x, y, newflag);
         } else {
             move_cursor(button, &ui->x, &ui->y, w, h, FALSE);
-            return "";
+            return UI_UPDATE;
         }
     }
 
index e5f958abb817a600f10b1f9985ca2fd095380b7c..9964dd5d4dbd2ed78c27eeeb2542121ac218eb83 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1285,7 +1285,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->drag_start_y = ui->drag_end_y = y;
         ui->cur_visible = 0;
 
-        return "";                    /* UI activity occurred */
+        return UI_UPDATE;
     }
 
     if (ui->dragging && button == ui->drag) {
@@ -1314,7 +1314,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->drag_end_x = x;
         ui->drag_end_y = y;
 
-        return "";                    /* UI activity occurred */
+        return UI_UPDATE;
     }
 
     if (ui->dragging && button == ui->release) {
@@ -1342,7 +1342,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                    x1, y1, x2-x1+1, y2-y1+1);
            return dupstr(buf);
         } else
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
     }
 
     if (IS_CURSOR_MOVE(button)) {
@@ -1350,12 +1350,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        char buf[80];
         move_cursor(button, &ui->cur_x, &ui->cur_y, state->common->w, state->common->h, 0);
         ui->cur_visible = 1;
-       if (!control && !shift) return "";
+       if (!control && !shift) return UI_UPDATE;
 
        newstate = control ? shift ? GRID_UNKNOWN : GRID_FULL : GRID_EMPTY;
        if (state->grid[y * state->common->w + x] == newstate &&
            state->grid[ui->cur_y * state->common->w + ui->cur_x] == newstate)
-           return "";
+           return UI_UPDATE;
 
        sprintf(buf, "%c%d,%d,%d,%d", control ? shift ? 'U' : 'F' : 'E',
                min(x, ui->cur_x), min(y, ui->cur_y),
@@ -1370,7 +1370,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
 
         if (button == CURSOR_SELECT2)
diff --git a/pearl.c b/pearl.c
index c6c305f3f22a477d69e177b78770ef04b590d588..2241b46315831c8ca91470e94cac5631d0e66956 100644 (file)
--- a/pearl.c
+++ b/pearl.c
@@ -2022,11 +2022,11 @@ static char *mark_in_direction(const game_state *state, int x, int y, int dir,
 
     char ch = primary ? 'F' : 'M', *other;
 
-    if (!INGRID(state, x, y) || !INGRID(state, x2, y2)) return "";
+    if (!INGRID(state, x, y) || !INGRID(state, x2, y2)) return UI_UPDATE;
 
     /* disallow laying a mark over a line, or vice versa. */
     other = primary ? state->marks : state->lines;
-    if (other[y*w+x] & dir || other[y2*w+x2] & dir2) return "";
+    if (other[y*w+x] & dir || other[y2*w+x2] & dir2) return UI_UPDATE;
     
     sprintf(buf, "%c%d,%d,%d;%c%d,%d,%d", ch, dir, x, y, ch, dir2, x2, y2);
     return dupstr(buf);
@@ -2060,12 +2060,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->dragcoords[0] = gy * w + gx;
         ui->ndragcoords = 0;           /* will be 1 once drag is confirmed */
 
-        return "";
+        return UI_UPDATE;
     }
 
     if (button == LEFT_DRAG && ui->ndragcoords >= 0) {
         update_ui_drag(state, ui, gx, gy);
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_MOUSE_RELEASE(button)) release = TRUE;
@@ -2087,30 +2087,30 @@ static char *interpret_move(const game_state *state, game_ui *ui,
            if (ui->ndragcoords >= 0)
                update_ui_drag(state, ui, ui->curx, ui->cury);
        }
-       return "";
+       return UI_UPDATE;
     }
 
     if (IS_CURSOR_SELECT(button)) {
        if (!ui->cursor_active) {
            ui->cursor_active = TRUE;
-           return "";
+           return UI_UPDATE;
        } else if (button == CURSOR_SELECT) {
            if (ui->ndragcoords == -1) {
                ui->ndragcoords = 0;
                ui->dragcoords[0] = ui->cury * w + ui->curx;
                ui->clickx = CENTERED_COORD(ui->curx);
                ui->clicky = CENTERED_COORD(ui->cury);
-               return "";
+               return UI_UPDATE;
            } else release = TRUE;
        } else if (button == CURSOR_SELECT2 && ui->ndragcoords >= 0) {
            ui->ndragcoords = -1;
-           return "";
+           return UI_UPDATE;
        }
     }
 
     if (button == 27 || button == '\b') {
         ui->ndragcoords = -1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (release) {
@@ -2142,7 +2142,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
             ui->ndragcoords = -1;
 
-            return buf ? buf : "";
+            return buf ? buf : UI_UPDATE;
         } else if (ui->ndragcoords == 0) {
             /* Click (or tiny drag). Work out which edge we were
              * closest to. */
@@ -2163,12 +2163,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             cx = CENTERED_COORD(gx);
             cy = CENTERED_COORD(gy);
 
-            if (!INGRID(state, gx, gy)) return "";
+            if (!INGRID(state, gx, gy)) return UI_UPDATE;
 
             if (max(abs(x-cx),abs(y-cy)) < TILE_SIZE/4) {
                 /* TODO closer to centre of grid: process as a cell click not an edge click. */
 
-                return "";
+                return UI_UPDATE;
             } else {
                int direction;
                 if (abs(x-cx) < abs(y-cy)) {
diff --git a/pegs.c b/pegs.c
index 82868519546e872f79c39d6a149d2e6dbae361a2..38e73b74f65698115ab48faa4eb34deaf25f7952 100644 (file)
--- a/pegs.c
+++ b/pegs.c
@@ -848,7 +848,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
            ui->dx = x;
            ui->dy = y;
             ui->cur_visible = ui->cur_jumping = 0;
-           return "";                 /* ui modified */
+           return UI_UPDATE;
        }
     } else if (button == LEFT_DRAG && ui->dragging) {
        /*
@@ -856,7 +856,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         */
        ui->dx = x;
        ui->dy = y;
-       return "";                     /* ui modified */
+       return UI_UPDATE;
     } else if (button == LEFT_RELEASE && ui->dragging) {
        int tx, ty, dx, dy;
 
@@ -868,18 +868,18 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        tx = FROMCOORD(x);
        ty = FROMCOORD(y);
        if (tx < 0 || tx >= w || ty < 0 || ty >= h)
-           return "";                 /* target out of range */
+           return UI_UPDATE;          /* target out of range */
        dx = tx - ui->sx;
        dy = ty - ui->sy;
        if (max(abs(dx),abs(dy)) != 2 || min(abs(dx),abs(dy)) != 0)
-           return "";                 /* move length was wrong */
+           return UI_UPDATE;          /* move length was wrong */
        dx /= 2;
        dy /= 2;
 
        if (state->grid[ty*w+tx] != GRID_HOLE ||
            state->grid[(ty-dy)*w+(tx-dx)] != GRID_PEG ||
            state->grid[ui->sy*w+ui->sx] != GRID_PEG)
-           return "";                 /* grid contents were invalid */
+           return UI_UPDATE;          /* grid contents were invalid */
 
        /*
         * We have a valid move. Encode it simply as source and
@@ -899,7 +899,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->cur_x = cx;
                 ui->cur_y = cy;
             }
-            return "";
+            return UI_UPDATE;
         } else {
             int dx, dy, mx, my, jx, jy;
 
@@ -922,21 +922,21 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->cur_x = jx; ui->cur_y = jy;
                 return dupstr(buf);
             }
-            return "";
+            return UI_UPDATE;
         }
     } else if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         if (ui->cur_jumping) {
             ui->cur_jumping = 0;
-            return "";
+            return UI_UPDATE;
         }
         if (state->grid[ui->cur_y*w+ui->cur_x] == GRID_PEG) {
             /* cursor is on peg: next arrow-move wil jump. */
             ui->cur_jumping = 1;
-            return "";
+            return UI_UPDATE;
         }
         return NULL;
     }
index 47c164c163b6fc6220a6a5f0fbf8eb06de7b05ed..f43ee8345f29315a139f19cabb750bda7d4f1e25 100644 (file)
--- a/puzzles.h
+++ b/puzzles.h
@@ -684,6 +684,14 @@ extern const int gamecount;
 extern const game thegame;
 #endif
 
+/*
+ * Special string value to return from interpret_move in the case
+ * where the game UI has been updated but no actual move is being
+ * appended to the undo chain. Must be declared as a non-const char,
+ * but should never actually be modified by anyone.
+ */
+extern char UI_UPDATE[];
+
 /* A little bit of help to lazy developers */
 #define DEFAULT_STATUSBAR_TEXT "Use status_bar() to fill this in."
 
diff --git a/range.c b/range.c
index 4dd39b97cd499f62cbd53c0d636cb26713b92d09..8017f8dc4b14c21058550d4ece6730e9abae9179 100644 (file)
--- a/range.c
+++ b/range.c
@@ -1360,14 +1360,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 else if (do_post)
                     return nfmtstr(40, "W,%d,%d", ui->r, ui->c);
                 else
-                    return "";
+                    return UI_UPDATE;
 
             } else if (!out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) {
                 ui->r += dr[i];
                 ui->c += dc[i];
             }
         } else ui->cursor_show = TRUE;
-        return "";
+        return UI_UPDATE;
     }
 
     if (action == hint) {
diff --git a/rect.c b/rect.c
index 465e1436fac50b2cfc8b125224011316f3b83178..67cc30a41c85b1008fcca5454dcee4baa25f393d 100644 (file)
--- a/rect.c
+++ b/rect.c
@@ -2407,7 +2407,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
         move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0);
         ui->cur_visible = TRUE;
         active = TRUE;
-        if (!ui->cur_dragging) return "";
+        if (!ui->cur_dragging) return UI_UPDATE;
         coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc);
     } else if (IS_CURSOR_SELECT(button)) {
         if (ui->drag_start_x >= 0 && !ui->cur_dragging) {
@@ -2420,7 +2420,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
         if (!ui->cur_visible) {
             assert(!ui->cur_dragging);
             ui->cur_visible = TRUE;
-            return "";
+            return UI_UPDATE;
         }
         coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc);
         erasing = (button == CURSOR_SELECT2);
@@ -2441,7 +2441,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
             reset_ui(ui); /* cancel keyboard dragging */
             ui->cur_dragging = FALSE;
         }
-        return "";
+        return UI_UPDATE;
     } else if (button != LEFT_DRAG && button != RIGHT_DRAG) {
         return NULL;
     }
@@ -2525,7 +2525,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
     if (ret)
        return ret;                    /* a move has been made */
     else if (active)
-        return "";                    /* UI activity has occurred */
+        return UI_UPDATE;
     else
        return NULL;
 }
index 88edad32b16f614da3c798f99d4d155bc7037eee..7a40fcc0fef28c669b93be99d8845bf9d2fd38a5 100644 (file)
@@ -1273,7 +1273,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                             int x, int y, int button)
 {
     int tx, ty;
-    char *ret = "";
+    char *ret = UI_UPDATE;
 
     ui->displaysel = 0;
 
index ca72768c27530e1a8ce43954666727987738fa85..9d782f084aaa3cbf9c4a61e75899fd82f307396a 100644 (file)
@@ -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);
index 5fe054c6638ecdc2fa1a19a09b42742ed09b08f4..ff6960fb0c81592b2f7b679c25b61b8166da2b02 100644 (file)
--- a/singles.c
+++ b/singles.c
@@ -1522,7 +1522,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             action = TOGGLE_CIRCLE;
         }
     }
-    if (action == UI) return "";
+    if (action == UI) return UI_UPDATE;
 
     if (action == TOGGLE_BLACK || action == TOGGLE_CIRCLE) {
         i = y * state->w + x;
index edc97718672b51d502ab5ae9fb948b691532b740..562eeb8c1401755421ad02a1dc336bdfcfe5c169 100644 (file)
--- a/sixteen.c
+++ b/sixteen.c
@@ -618,7 +618,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     if (IS_CURSOR_MOVE(button) || pad) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
 
         if (control || shift || ui->cur_mode) {
@@ -673,7 +673,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             }
 
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
     }
 
@@ -691,11 +691,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 const enum cursor_mode m = (button == CURSOR_SELECT2 ?
                                             lock_position : lock_tile);
                 ui->cur_mode = (ui->cur_mode == m ? unlocked : m);
-                return "";
+                return UI_UPDATE;
             }
         } else {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
     } else {
        return NULL;
@@ -710,7 +710,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     else if (cy == state->h && cx >= 0 && cx < state->w)
         dy = +1, dx = 0;
     else
-        return "";                   /* invalid click location */
+        return UI_UPDATE;            /* invalid click location */
 
     /* reverse direction if right hand button is pressed */
     if (button == RIGHT_BUTTON || button == CURSOR_SELECT2) {
diff --git a/slant.c b/slant.c
index 5f9f4f6fedda8030a4de84d00ad7ffa12bb8f583..5980eb2125a02c8776a84af888d1d61e2833b5a7 100644 (file)
--- a/slant.c
+++ b/slant.c
@@ -1683,7 +1683,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     } else if (IS_CURSOR_SELECT(button)) {
         if (!ui->cur_visible) {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
         x = ui->cur_x;
         y = ui->cur_y;
@@ -1692,7 +1692,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     } else if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0);
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     } else if (button == '\\' || button == '\b' || button == '/') {
        int x = ui->cur_x, y = ui->cur_y;
        if (button == ("\\" "\b" "/")[state->soln[y*w + x] + 1]) return NULL;
diff --git a/solo.c b/solo.c
index 0d383c39aad22ed904447435b1c99ba338fb7cc2..b40901d1ddf9d4c773c0b09ca283054bc6044cbd 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -4586,7 +4586,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hpencil = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
         if (button == RIGHT_BUTTON) {
             /*
@@ -4606,19 +4606,19 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hshow = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
     }
     if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->hx, &ui->hy, cr, cr, 0);
         ui->hshow = ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (ui->hshow &&
         (button == CURSOR_SELECT)) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (ui->hshow &&
diff --git a/tents.c b/tents.c
index 4ffeb7be64f95e0224f988ba8f1e138f07f6515c..e17a893a106e8cd9a7ee1619f132795b9c106eb4 100644 (file)
--- a/tents.c
+++ b/tents.c
@@ -1559,7 +1559,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->dsy = ui->dey = y;
         ui->drag_ok = TRUE;
         ui->cdisp = 0;
-        return "";             /* ui updated */
+        return UI_UPDATE;
     }
 
     if ((IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) &&
@@ -1590,14 +1590,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         }
 
         if (IS_MOUSE_DRAG(button))
-            return "";                 /* ui updated */
+            return UI_UPDATE;
 
         /*
          * The drag has been released. Enact it.
          */
         if (!ui->drag_ok) {
             ui->drag_button = -1;
-            return "";                 /* drag was just cancelled */
+            return UI_UPDATE;          /* drag was just cancelled */
         }
 
         xmin = min(ui->dsx, ui->dex);
@@ -1635,7 +1635,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
         if (buflen == 0) {
             sfree(buf);
-            return "";                 /* ui updated (drag was terminated) */
+            return UI_UPDATE;          /* drag was terminated */
         } else {
             buf[buflen] = '\0';
             return buf;
@@ -1663,7 +1663,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             if (len) return dupstr(tmpbuf);
         } else
             move_cursor(button, &ui->cx, &ui->cy, w, h, 0);
-        return "";
+        return UI_UPDATE;
     }
     if (ui->cdisp) {
         char rep = 0;
@@ -1690,7 +1690,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         }
     } else if (IS_CURSOR_SELECT(button)) {
         ui->cdisp = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     return NULL;
index a3a7e55a45f01166932ad7ca0b5f42df06ca20a7..06b7279380b91050b94cba353f4fe6be2eb76931 100644 (file)
--- a/towers.c
+++ b/towers.c
@@ -1349,7 +1349,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hpencil = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
         if (button == RIGHT_BUTTON) {
             /*
@@ -1369,7 +1369,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hshow = 0;
             }
             ui->hcursor = 0;
-            return "";                /* UI activity occurred */
+            return UI_UPDATE;
         }
     } else if (button == LEFT_BUTTON) {
         if (is_clue(state, tx, ty)) {
@@ -1394,13 +1394,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         }
         move_cursor(button, &ui->hx, &ui->hy, w, w, 0);
         ui->hshow = ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (ui->hshow &&
         (button == CURSOR_SELECT)) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (ui->hshow &&
index e4e7b5ca9c8e4611759c0fad6f538f7cf5fb28cc..f5f3e0b97d5b868264184cea781c8c16b0a7a8a8 100644 (file)
--- a/tracks.c
+++ b/tracks.c
@@ -1922,13 +1922,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->drag_sx = ui->drag_ex = gx;
         ui->drag_sy = ui->drag_ey = gy;
 
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_MOUSE_DRAG(button)) {
         ui->cursor_active = FALSE;
         update_ui_drag(state, ui, gx, gy);
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_MOUSE_RELEASE(button)) {
@@ -1965,12 +1965,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             cy = CENTERED_COORD(gy);
 
             if (!INGRID(state, gx, gy) || FROMCOORD(x) != gx || FROMCOORD(y) != gy)
-                return "";
+                return UI_UPDATE;
 
             if (max(abs(x-cx),abs(y-cy)) < TILE_SIZE/4) {
                 if (ui_can_flip_square(state, gx, gy, button == RIGHT_RELEASE))
                     return square_flip_str(state, gx, gy, button == RIGHT_RELEASE, tmpbuf);
-                return "";
+                return UI_UPDATE;
             } else {
                 if (abs(x-cx) < abs(y-cy)) {
                     /* Closest to top/bottom edge. */
@@ -1984,7 +1984,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                     return edge_flip_str(state, gx, gy, direction,
                             button == RIGHT_RELEASE, tmpbuf);
                 else
-                    return "";
+                    return UI_UPDATE;
             }
         }
     }
@@ -1997,7 +1997,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
         if (!ui->cursor_active) {
             ui->cursor_active = TRUE;
-            return "";
+            return UI_UPDATE;
         }
 
         ui->curx = ui->curx + dx;
@@ -2008,17 +2008,17 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         }
         ui->curx = min(max(ui->curx, 1), 2*w-1);
         ui->cury = min(max(ui->cury, 1), 2*h-1);
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_CURSOR_SELECT(button)) {
         if (!ui->cursor_active) {
             ui->cursor_active = TRUE;
-            return "";
+            return UI_UPDATE;
         }
         /* click on square corner does nothing (shouldn't get here) */
         if ((ui->curx % 2) == 0 && (ui->cury % 2 == 0))
-            return "";
+            return UI_UPDATE;
 
         gx = ui->curx / 2;
         gy = ui->cury / 2;
@@ -2030,7 +2030,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         else if (!direction &&
                  ui_can_flip_square(state, gx, gy, button == CURSOR_SELECT2))
             return square_flip_str(state, gx, gy, button == CURSOR_SELECT2, tmpbuf);
-        return "";
+        return UI_UPDATE;
     }
 
 #if 0
index 6e05f4ddeced8a95cd46377289da9dec7c91d62d..f52e99950793910ca26544cbbb842044897bf7ce 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -661,7 +661,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         if (button == CURSOR_DOWN && (ui->cur_y+n) < (h))
             ui->cur_y++;
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
@@ -685,7 +685,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             dir = (button == CURSOR_SELECT2) ? -1 : +1;
         } else {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
     } else if (button == 'a' || button == 'A' || button==MOD_NUM_KEYPAD+'7') {
         x = y = 0;
index b1f536e8d0233183a3d0ecf553999038670bf120..27102239a6cedad53a041bd4a119ad484d690be7 100644 (file)
--- a/undead.c
+++ b/undead.c
@@ -1725,7 +1725,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
 
     if (button == 'a' || button == 'A') {
         ui->ascii = !ui->ascii;
-        return "";      
+        return UI_UPDATE;
     }
 
     if (button == 'm' || button == 'M') {
@@ -1771,12 +1771,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
               case CURSOR_LEFT:   ui->hx -= (ui->hx > 1)     ? 1 : 0; break;
             }
         ui->hshow = ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (ui->hshow && button == CURSOR_SELECT) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (ui->hshow == 1 && ui->hpencil == 1) {
@@ -1814,12 +1814,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 if (button == LEFT_BUTTON) {
                     ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
                     ui->hx = gx; ui->hy = gy;
-                    return "";
+                    return UI_UPDATE;
                 }
                 else if (button == RIGHT_BUTTON && g == 7) {
                     ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
                     ui->hx = gx; ui->hy = gy;
-                    return "";
+                    return UI_UPDATE;
                 }
             }
             else if (ui->hshow == 1) {
@@ -1828,36 +1828,36 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                         if (gx == ui->hx && gy == ui->hy) {
                             ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0;
                             ui->hx = 0; ui->hy = 0;
-                            return "";
+                            return UI_UPDATE;
                         }
                         else {
                             ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
                             ui->hx = gx; ui->hy = gy;
-                            return "";
+                            return UI_UPDATE;
                         }
                     }
                     else {
                         ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
                         ui->hx = gx; ui->hy = gy;
-                        return "";
+                        return UI_UPDATE;
                     }
                 }
                 else if (button == RIGHT_BUTTON) {
                     if (ui->hpencil == 0 && g == 7) {
                         ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
                         ui->hx = gx; ui->hy = gy;
-                        return "";
+                        return UI_UPDATE;
                     }
                     else {
                         if (gx == ui->hx && gy == ui->hy) {
                             ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0;
                             ui->hx = 0; ui->hy = 0;
-                            return "";
+                            return UI_UPDATE;
                         }
                         else if (g == 7) {
                             ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
                             ui->hx = gx; ui->hy = gy;
-                            return "";
+                            return UI_UPDATE;
                         }
                     }
                 }
index a63b7d8ed0971515e5ceaa27c02582edd1aadaab..6342318b044507ba2286eeed24792e6e634b29dd 100644 (file)
--- a/unequal.c
+++ b/unequal.c
@@ -1425,7 +1425,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hshow = 1;
             }
             ui->hcursor = 0;
-            return "";
+            return UI_UPDATE;
         }
         if (button == RIGHT_BUTTON) {
             /* pencil highlighting for non-filled squares */
@@ -1439,7 +1439,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                 ui->hshow = 1;
             }
             ui->hcursor = 0;
-            return "";
+            return UI_UPDATE;
         }
     }
 
@@ -1453,11 +1453,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                                  ny != ui->hy + adjthan[i].dy); ++i);
 
            if (i == 4)
-               return ""; /* invalid direction, i.e. out of the board */
+               return UI_UPDATE; /* invalid direction, i.e. out of
+                                   * the board */
 
            if (!(GRID(state, flags, ui->hx, ui->hy) & adjthan[i].f ||
                  GRID(state, flags, nx,     ny    ) & adjthan[i].fo))
-               return ""; /* no clue to toggle */
+               return UI_UPDATE; /* no clue to toggle */
 
            if (state->adjacent)
                self = (adjthan[i].dx >= 0 && adjthan[i].dy >= 0);
@@ -1475,13 +1476,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        } else {
            move_cursor(button, &ui->hx, &ui->hy, ds->order, ds->order, FALSE);
            ui->hshow = ui->hcursor = 1;
-           return "";
+           return UI_UPDATE;
        }
     }
     if (ui->hshow && IS_CURSOR_SELECT(button)) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     n = c2n(button, state->order);
index 4a4ad6ce533de4a8cd96bd8a174f395cbc7851a4..0d2f915c2537698c0d131cd5ec33c2da4cd4e585 100644 (file)
@@ -1281,13 +1281,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->drag |= 4;             /* some movement has happened */
             if (tcoord >= 0 && tcoord < w) {
                 ui->dragpos = tcoord;
-                return "";
+                return UI_UPDATE;
             }
         } else if (IS_MOUSE_RELEASE(button)) {
             if (ui->drag & 4) {
                 ui->drag = 0;          /* end drag */
                 if (state->sequence[ui->dragpos] == ui->dragnum)
-                    return "";         /* drag was a no-op overall */
+                    return UI_UPDATE;  /* drag was a no-op overall */
                 sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos);
                 return dupstr(buf);
             } else {
@@ -1298,7 +1298,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                             state->sequence[ui->edgepos]);
                     return dupstr(buf);
                 } else
-                    return "";         /* no-op */
+                    return UI_UPDATE;  /* no-op */
             }
         }
     } else if (IS_MOUSE_DOWN(button)) {
@@ -1321,7 +1321,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                     ui->hpencil = 0;
                 }
                 ui->hcursor = 0;
-                return "";                    /* UI activity occurred */
+                return UI_UPDATE;
             }
             if (button == RIGHT_BUTTON) {
                 /*
@@ -1345,20 +1345,20 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                     ui->hshow = 0;
                 }
                 ui->hcursor = 0;
-                return "";                    /* UI activity occurred */
+                return UI_UPDATE;
             }
         } else if (tx >= 0 && tx < w && ty == -1) {
             ui->drag = 2;
             ui->dragnum = state->sequence[tx];
             ui->dragpos = tx;
             ui->edgepos = FROMCOORD(x + TILESIZE/2);
-            return "";
+            return UI_UPDATE;
         } else if (ty >= 0 && ty < w && tx == -1) {
             ui->drag = 1;
             ui->dragnum = state->sequence[ty];
             ui->dragpos = ty;
             ui->edgepos = FROMCOORD(y + TILESIZE/2);
-            return "";
+            return UI_UPDATE;
         }
     } else if (IS_MOUSE_DRAG(button)) {
         if (!ui->hpencil &&
@@ -1371,7 +1371,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->odx = ui->ody = 0;
             ui->odn = 1;
         }
-        return "";
+        return UI_UPDATE;
     }
 
     if (IS_CURSOR_MOVE(button)) {
@@ -1381,13 +1381,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         ui->hx = state->sequence[cx];
         ui->hy = state->sequence[cy];
         ui->hshow = ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
     if (ui->hshow &&
         (button == CURSOR_SELECT)) {
         ui->hpencil = 1 - ui->hpencil;
         ui->hcursor = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (ui->hshow &&
index 9d4fce14612e1f8d11b959e8bca91306818078da..51ac7cbe1e46726aebb507102be52641d8a3fdb5 100644 (file)
@@ -1349,7 +1349,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         * And that's it. Update the display to reflect the start
         * of a drag.
         */
-       return "";
+       return UI_UPDATE;
     } else if (button == LEFT_DRAG && ui->dragging) {
        int dist, distlimit, dx, dy, s, px, py;
 
@@ -1376,7 +1376,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
                    if (px >= 0 && px < w && py >= 0 && py < h &&
                        ui->reachable[py*w+px]) {
                        ui->drag_currpos = py*w+px;
-                       return "";
+                       return UI_UPDATE;
                    }
                }
        }
index f418efa7769e1629e8c487bd8d5939a9549228e8..51b168a72df73deec6ae48375ccc40eae43ef0e0 100644 (file)
--- a/unruly.c
+++ b/unruly.c
@@ -1531,7 +1531,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
     if (IS_CURSOR_MOVE(button)) {
         move_cursor(button, &ui->cx, &ui->cy, w2, h2, 0);
         ui->cursor = TRUE;
-        return "";
+        return UI_UPDATE;
     }
 
     /* Place one */
index ac40418efc705c3b0e62c6e8915c3556c68a0ee4..4dd93be36165c7327a3e16242c0b3636650d3124 100644 (file)
@@ -1117,14 +1117,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
            ui->newpoint.x = x;
            ui->newpoint.y = y;
            ui->newpoint.d = ds->tilesize;
-           return "";
+           return UI_UPDATE;
        }
 
     } else if (IS_MOUSE_DRAG(button) && ui->dragpoint >= 0) {
        ui->newpoint.x = x;
        ui->newpoint.y = y;
        ui->newpoint.d = ds->tilesize;
-       return "";
+       return UI_UPDATE;
     } else if (IS_MOUSE_RELEASE(button) && ui->dragpoint >= 0) {
        int p = ui->dragpoint;
        char buf[80];
@@ -1139,7 +1139,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             ui->newpoint.x >= (long)state->w*ui->newpoint.d ||
            ui->newpoint.y < 0 ||
             ui->newpoint.y >= (long)state->h*ui->newpoint.d)
-           return "";
+           return UI_UPDATE;
 
        /*
         * We aren't cancelling the drag. Construct a move string