chiark / gitweb /
New rule: interpret_move() is passed a pointer to the game_drawstate
authorSimon Tatham <anakin@pobox.com>
Sun, 9 Sep 2012 18:40:12 +0000 (18:40 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 9 Sep 2012 18:40:12 +0000 (18:40 +0000)
basically just so that it can divide mouse coordinates by the tile
size, but is definitely not expected to _write_ to it, and it hadn't
previously occurred to me that anyone might try. Therefore,
interpret_move() now gets a pointer to a _const_ game_drawstate
instead of a writable one.

All existing puzzles cope fine with this API change (as long as the
new const qualifier is also added to a couple of subfunctions to which
interpret_move delegates work), except for the just-committed Undead,
which somehow had ds->ascii and ui->ascii the wrong way round but is
otherwise unproblematic.

[originally from svn r9657]

38 files changed:
blackbox.c
bridges.c
cube.c
devel.but
dominosa.c
fifteen.c
filling.c
flip.c
galaxies.c
guess.c
inertia.c
keen.c
lightup.c
loopy.c
magnets.c
map.c
mines.c
net.c
netslide.c
nullgame.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
twiddle.c
undead.c
unequal.c
untangle.c

index 3a85bd7d3bf83d65b8c50d421696433ab8df1f21..1546d918c5019c9f23f57ae9e805b17e45c35f1c 100644 (file)
@@ -879,7 +879,7 @@ struct game_drawstate {
     int flash_laserno, isflash;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int gx = -1, gy = -1, rangeno = -1, wouldflash = 0;
index 0717a88c6aeb0b7e3886af4004ec5183f56cee7a..a5eef25d740c21f520facc4e45c3cf02845dc771 100644 (file)
--- a/bridges.c
+++ b/bridges.c
@@ -2157,8 +2157,8 @@ struct game_drawstate {
     int show_hints;
 };
 
-static char *update_drag_dst(game_state *state, game_ui *ui, game_drawstate *ds,
-                            int nx, int ny)
+static char *update_drag_dst(game_state *state, game_ui *ui,
+                             const game_drawstate *ds, int nx, int ny)
 {
     int ox, oy, dx, dy, i, currl, maxb;
     struct island *is;
@@ -2253,7 +2253,7 @@ static char *finish_drag(game_state *state, game_ui *ui)
     return dupstr(buf);
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int gx = FROMCOORD(x), gy = FROMCOORD(y);
diff --git a/cube.c b/cube.c
index cac464076e047069edfeecaf48427df03774fa37..15c479bb86dae51ea8515c805e17b215a99752c5 100644 (file)
--- a/cube.c
+++ b/cube.c
@@ -1100,7 +1100,7 @@ static int find_move_dest(game_state *from, int direction,
     return dest;
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int direction, mask, i;
index 27ef5d75dc1f8337b806def05bec2a5e147d8284..970a73a1a73437b285235d684de51124da37a349 100644 (file)
--- a/devel.but
+++ b/devel.but
@@ -856,7 +856,7 @@ producing new \c{game_state}s.
 \S{backend-interpret-move} \cw{interpret_move()}
 
 \c char *(*interpret_move)(game_state *state, game_ui *ui,
-\c                         game_drawstate *ds,
+\c                         const game_drawstate *ds,
 \c                         int x, int y, int button);
 
 This function receives user input and processes it. Its input
@@ -868,6 +868,11 @@ indicating an arrow or function key or a mouse event; when
 coordinates of the mouse pointer relative to the top left of the
 puzzle's drawing area.
 
+(The pointer to the \c{game_drawstate} is marked \c{const}, because
+\c{interpret_move} should not write to it. The normal use of that
+pointer will be to read the game's tile size parameter in order to
+divide mouse coordinates by it.)
+
 \cw{interpret_move()} may return in three different ways:
 
 \b Returning \cw{NULL} indicates that no action whatsoever occurred
index 02e276c9d5cfc0465b2e51b0e1f84a538c35ce8a..26624103f954872e793ef8a95642256a56bcf6b1 100644 (file)
@@ -1001,7 +1001,7 @@ struct game_drawstate {
     unsigned long *visible;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->w, h = state->h;
index 5419f41c75265506cc17bd46eafebf7fb419bdbf..1a106e815f29b28387edaaa2b8e9888bbc15f989 100644 (file)
--- a/fifteen.c
+++ b/fifteen.c
@@ -460,7 +460,7 @@ struct game_drawstate {
     int tilesize;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int gx, gy, dx, dy;
index df68ea7301c881231dd9a948987c1e120360d19d..a0c9fc45bb6960f191b452602cbad461c7cb9481 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -1036,7 +1036,7 @@ struct game_drawstate {
     int *dsf_scratch, *border_scratch;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                             int x, int y, int button)
 {
     const int w = state->shared->params.w;
diff --git a/flip.c b/flip.c
index 6ba683b4adacaca7c68bb4d26435cd43319f3cd1..c30e484bea4fd7b21729fc568132ecf38542bdb5 100644 (file)
--- a/flip.c
+++ b/flip.c
@@ -899,7 +899,7 @@ struct game_drawstate {
     int tilesize;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->w, h = state->h, wh = w * h;
index b9eb603a29b9e91862b0c137bf8ea1976d08c8ec..db89700e3f5f6345d25eb941200f60731c3843e1 100644 (file)
@@ -2369,7 +2369,7 @@ static void coord_round_to_edge(float x, float y, int *xr, int *yr)
 #endif
 
 #ifdef EDITOR
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     char buf[80];
@@ -2404,7 +2404,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
     return NULL;
 }
 #else
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     /* UI operations (play mode):
diff --git a/guess.c b/guess.c
index 88a0024e3745e9c4fac78bd32d88f91aa0381031..15cf0d99945164681707bf011a4aa0624dc75e54 100644 (file)
--- a/guess.c
+++ b/guess.c
@@ -632,7 +632,7 @@ static char *encode_move(game_state *from, game_ui *ui)
     return buf;
 }
 
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int over_col = 0;           /* one-indexed */
index 74fc3c1682597e3c43c54da95e45845957a76e0c..eb850ac436bc7beca0556eef48704b569bc750c2 100644 (file)
--- a/inertia.c
+++ b/inertia.c
@@ -1534,7 +1534,7 @@ struct game_drawstate {
 #define COORD(x)  ( (x) * TILESIZE + BORDER )
 #define FROMCOORD(x)  ( ((x) - BORDER + TILESIZE) / TILESIZE - 1 )
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->p.w, h = state->p.h /*, wh = w*h */;
diff --git a/keen.c b/keen.c
index 3776283d7f41008f97d2c2254918efced8491596..5087465ef675accee91070f4db5074b8686f06b9 100644 (file)
--- a/keen.c
+++ b/keen.c
@@ -1512,7 +1512,7 @@ static int check_errors(game_state *state, long *errors)
     return errs;
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->par.w;
index 8f0926347838982c70974fc23e2019712274db3c..5beacc71b09fbc860935953dfb43d8c876467432 100644 (file)
--- a/lightup.c
+++ b/lightup.c
@@ -1871,7 +1871,7 @@ struct game_drawstate {
             (pc)) -1 (nil)
         (nil))
  */
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     enum { NONE, FLIP_LIGHT, FLIP_IMPOSSIBLE } action = NONE;
diff --git a/loopy.c b/loopy.c
index 85590fae986b9a47ea6ec6031943a65c949952a0..5df13d59f857a51a40de5a134c40627bdf05ccf2 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -2813,7 +2813,7 @@ static char *solve_game(game_state *state, game_state *currstate,
  * Drawing and mouse-handling
  */
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                             int x, int y, int button)
 {
     grid *g = state->game_grid;
index e49b7a51216bd7a00a2ed850be0a050f0d4531a0..e9b8c7dfa2eff7412bb5e7e6818652cedf7d04cb 100644 (file)
--- a/magnets.c
+++ b/magnets.c
@@ -1754,7 +1754,7 @@ struct game_drawstate {
 #define COORD(x) ( (x+1) * TILE_SIZE + BORDER )
 #define FROMCOORD(x) ( (x - BORDER) / TILE_SIZE - 1 )
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int gx = FROMCOORD(x), gy = FROMCOORD(y), idx, curr;
diff --git a/map.c b/map.c
index 5d170d10d34fc82bbb36959d6c9e1a8edabda962..af7c0af47aa3f55e643fc89f13abed2c42aea6e8 100644 (file)
--- a/map.c
+++ b/map.c
@@ -2342,7 +2342,7 @@ struct game_drawstate {
                            ((button) == CURSOR_UP)    ? -1 : 0)
 
 
-static int region_from_coords(game_state *state, game_drawstate *ds,
+static int region_from_coords(game_state *state, const game_drawstate *ds,
                               int x, int y)
 {
     int w = state->p.w, h = state->p.h, wh = w*h /*, n = state->p.n */;
@@ -2361,7 +2361,7 @@ static int region_from_coords(game_state *state, game_drawstate *ds,
     return state->map->map[quadrant * wh + ty*w+tx];
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     char *bufp, buf[256];
diff --git a/mines.c b/mines.c
index 7801ab47d81f33fa97c4b4af9d2e519e60a8e3fd..abd1ad8e61ccf34dc99d302920a8b817858657dc 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -2415,7 +2415,7 @@ struct game_drawstate {
     int cur_x, cur_y; /* -1, -1 for no cursor displayed. */
 };
 
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int cx, cy;
diff --git a/net.c b/net.c
index 667f9396be9c516f1db99e65bac417b506a6a8ad..2e19f1f0273e06f1cf4baa5825436c2851dac931 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1922,7 +1922,7 @@ struct game_drawstate {
  * Process a move.
  */
 static char *interpret_move(game_state *state, game_ui *ui,
-                           game_drawstate *ds, int x, int y, int button)
+                           const game_drawstate *ds, int x, int y, int button)
 {
     char *nullret;
     int tx = -1, ty = -1, dir = 0;
index 076cad41b2fee1c1a814edc2f8a899c78ea8b606..8d18652bb48f278de647574027764cc9f4c4b77b 100644 (file)
@@ -1056,7 +1056,7 @@ struct game_drawstate {
 };
 
 static char *interpret_move(game_state *state, game_ui *ui,
-                           game_drawstate *ds, int x, int y, int button)
+                           const game_drawstate *ds, int x, int y, int button)
 {
     int cx, cy;
     int dx, dy;
index 9e9910939241e10627600fce79bbdf38b79ffa6f..5a0ba42e69c215a6281e9e7b8dc8954f18078252 100644 (file)
@@ -161,7 +161,7 @@ struct game_drawstate {
     int FIXME;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     return NULL;
index b88edc5dbac0f07be7b0cee82142019e03db5778..ab5be76c1a51964c7ad90a4b7702ae0d6217e6d9 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -833,7 +833,7 @@ struct game_drawstate {
     int cur_x, cur_y;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     button &= ~MOD_MASK;
diff --git a/pearl.c b/pearl.c
index 40c32eba50d08d482d17dd72d24cc18c6d86e066..967059290185e218cc925ca5acf4784ac38949de 100644 (file)
--- a/pearl.c
+++ b/pearl.c
@@ -1962,7 +1962,7 @@ static char *mark_in_direction(game_state *state, int x, int y, int dir,
     (btn) == CURSOR_DOWN ? D : (btn) == CURSOR_UP ? U :\
     (btn) == CURSOR_LEFT ? L : R)
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->shared->w, h = state->shared->h /*, sz = state->shared->sz */;
diff --git a/pegs.c b/pegs.c
index d77860cf07aa0072c8e2bf0dca7ce3a6ff69482e..3dac5fc719767974afa7210480b0ba98741beb6d 100644 (file)
--- a/pegs.c
+++ b/pegs.c
@@ -814,7 +814,7 @@ struct game_drawstate {
     int bgcolour;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->w, h = state->h;
index 48b5b1a937602578cd7c42590473b79bd538f21c..c9cca0500f35275121f226fc9ce56dc087543258 100644 (file)
--- a/puzzles.h
+++ b/puzzles.h
@@ -499,8 +499,8 @@ struct game {
     void (*decode_ui)(game_ui *ui, char *encoding);
     void (*changed_state)(game_ui *ui, game_state *oldstate,
                           game_state *newstate);
-    char *(*interpret_move)(game_state *state, game_ui *ui, game_drawstate *ds,
-                           int x, int y, int button);
+    char *(*interpret_move)(game_state *state, game_ui *ui,
+                            const game_drawstate *ds, int x, int y, int button);
     game_state *(*execute_move)(game_state *state, char *move);
     int preferred_tilesize;
     void (*compute_size)(game_params *params, int tilesize, int *x, int *y);
diff --git a/range.c b/range.c
index 425259f01c8fd6e46b68165512dd0d3019ea4f62..43231d9683361b428a2572b6f7d2cbdf51b4fa1f 100644 (file)
--- a/range.c
+++ b/range.c
@@ -1248,7 +1248,7 @@ struct game_drawstate {
 #define COORD(x) ((x) * TILESIZE + BORDER)
 #define FROMCOORD(x) (((x) - BORDER) / TILESIZE)
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                             int x, int y, int button)
 {
     enum {none, forwards, backwards, hint};
diff --git a/rect.c b/rect.c
index 72a00e14ec1a60f978568b572ef319497f4fc48a..25b2132553b374d10c1ab03702130177b40fc45d 100644 (file)
--- a/rect.c
+++ b/rect.c
@@ -2365,7 +2365,7 @@ struct game_drawstate {
     unsigned long *visible;
 };
 
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int xc, yc;
index 49dd64eae9dc5e9e76ae901849caca3e9e053ff9..65ebef746f346f56503b5219d9459cb5778bec93 100644 (file)
@@ -1267,7 +1267,7 @@ struct game_drawstate {
     int *tiles; /* contains colour and SELECTED. */
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int tx, ty;
index 5286b42e99f8b4ebee815129cbd8559e085cbdad..b5e22edd357046bae4ac0eb94249247c6bbac245 100644 (file)
@@ -1418,7 +1418,7 @@ struct game_drawstate {
     blitter *dragb;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int mx, int my, int button)
 {
     int x = FROMCOORD(mx), y = FROMCOORD(my), w = state->w;
index 6d583aa2e1e4d3069d5fa5203f70a03dd9b16451..32449b6b525bd94e79035054b674698d899e55eb 100644 (file)
--- a/singles.c
+++ b/singles.c
@@ -1471,7 +1471,7 @@ struct game_drawstate {
     unsigned int *flags;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int mx, int my, int button)
 {
     char buf[80], c;
index 8079facfcfc52ba3a441a87e07ad7a4d6e257c18..88c7ef49b682b8603a69a0e91f688274835d8c80 100644 (file)
--- a/sixteen.c
+++ b/sixteen.c
@@ -595,7 +595,7 @@ struct game_drawstate {
     int cur_x, cur_y;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int cx = -1, cy = -1, dx, dy;
diff --git a/slant.c b/slant.c
index 52f21d6b86e6db651096147649fa576d58c3d0ff..2f9de52c73ae468d8f053b93ea0876fee66d6448 100644 (file)
--- a/slant.c
+++ b/slant.c
@@ -1666,7 +1666,7 @@ struct game_drawstate {
     long *todraw;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->p.w, h = state->p.h;
diff --git a/solo.c b/solo.c
index 43abc1f8e7213cad033b848556f1f50e9d5f8164..d9bf18d7677312d1049f7ede44032e260d39d0a5 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -4511,7 +4511,7 @@ struct game_drawstate {
     int nregions, *entered_items;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int cr = state->cr;
diff --git a/tents.c b/tents.c
index cfdcdc37786e2db8e4689fcc71a77ab07ad33019..ef5debcc90c0bb8aa0c518ba8b2649dc2da405e2 100644 (file)
--- a/tents.c
+++ b/tents.c
@@ -1520,7 +1520,7 @@ static int drag_xform(game_ui *ui, int x, int y, int v)
     return v;
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->p.w, h = state->p.h;
index be0a7306d7a36abe9a507cadefb8e73f501f39fe..bd395549e3b371b2e8ba91fee16f71e8a84e64c0 100644 (file)
--- a/towers.c
+++ b/towers.c
@@ -1255,7 +1255,7 @@ static int check_errors(game_state *state, int *errors)
     return errs;
 }
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->par.w;
index 51a21f04749bc305512fd15ecf040cf518c1bfe6..b5b276f0aa50e1a820718ba47260c8497f5d6f56 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -640,7 +640,7 @@ struct game_drawstate {
     int cur_x, cur_y;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->w, h = state->h, n = state->n /* , wh = w*h */;
index 6ce6eaa272bbd3f6fa90904e3295a451a6b5487f..dab3f504e6abca4a303916295d3d72ee9d46e654 100644 (file)
--- a/undead.c
+++ b/undead.c
@@ -1646,8 +1646,9 @@ struct game_drawstate {
 #define TILESIZE (ds->tilesize)
 #define BORDER (TILESIZE/2)
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
-                            int x, int y, int button) {
+static char *interpret_move(game_state *state, game_ui *ui,
+                            const game_drawstate *ds, int x, int y, int button)
+{
     int gx,gy;
     int g,xi;
     char buf[80]; 
@@ -1656,7 +1657,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
     gy = ((y-BORDER-2) / TILESIZE ) - 1;
 
     if (button == 'a' || button == 'A') {
-        ds->ascii = ui->ascii ? FALSE : TRUE;
+        ui->ascii = !ui->ascii;
         return "";      
     }
     
@@ -2395,7 +2396,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
             game_state *state, int dir, game_ui *ui,
             float animtime, float flashtime) {
     int i,j,x,y,xy;
-    int stale, xi, c, hflash, hchanged;
+    int stale, xi, c, hflash, hchanged, changed_ascii;
 
     hflash = (int)(flashtime * 5 / FLASH_TIME) % 2;
 
@@ -2419,13 +2420,18 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
         ds->hshow != ui->hshow || ds->hpencil != ui->hpencil)
         hchanged = TRUE;
 
+    if (ds->ascii != ui->ascii) {
+        ds->ascii = ui->ascii;
+        changed_ascii = TRUE;
+    }
+
     /* Draw monster count hints */
 
     for (i=0;i<3;i++) {
         stale = FALSE;
         if (!ds->started) stale = TRUE;
         if (ds->hflash != hflash) stale = TRUE;
-        if (ds->ascii != ui->ascii) stale = TRUE;
+        if (changed_ascii) stale = TRUE;
         if (ds->count_errors[i] != state->count_errors[i]) {
             stale = TRUE;
             ds->count_errors[i] = state->count_errors[i];
@@ -2481,7 +2487,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
     
         if (!ds->started) stale = TRUE;
         if (ds->hflash != hflash) stale = TRUE;
-        if (ds->ascii != ui->ascii) stale = TRUE;
+        if (changed_ascii) stale = TRUE;
         
         if (hchanged) {
             if ((x == ui->hx && y == ui->hy) ||
@@ -2520,7 +2526,6 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
     ds->hshow = ui->hshow;
     ds->hpencil = ui->hpencil;
     ds->hflash = hflash;
-    ui->ascii = ds->ascii;
     ds->started = TRUE;
     return;
 }
index 5dcca368061ecd1a9f9fd7b99818b5e735e13b84..d16a572364caa7c9e3d697980e49db5bc526c26f 100644 (file)
--- a/unequal.c
+++ b/unequal.c
@@ -1371,7 +1371,7 @@ struct game_drawstate {
     int hflash;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int ox, int oy, int button)
 {
     int x = FROMCOORD(ox), y = FROMCOORD(oy), n;
index c07c957e0ec736984705a190db75eaf5f339aa47..beb28717cccb423af09548629c30f1c843b0adb5 100644 (file)
@@ -1072,7 +1072,7 @@ struct game_drawstate {
     long *x, *y;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int n = state->params.n;