chiark / gitweb /
Fix redrawing of Undead 'done' clues after a resize.
authorSimon Tatham <anakin@pobox.com>
Sun, 5 Jul 2015 20:57:38 +0000 (21:57 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 5 Jul 2015 20:57:38 +0000 (21:57 +0100)
The is_hint_stale() function has the side effect of copying a path
hint's new colour-relevant information into the game_drawstate, where
draw_path_hint will then use it. But it returns TRUE early in some
situations, notably !ds->started, which can happen after the actual
game start if the window is resized and a fresh drawstate is created.

This patch, thanks to Chris Boyle, fixes it by eliminating the early
returns from is_hint_stale - the return value is unchanged, but now
the side effects happen reliably.

undead.c

index f828ac04988f39b39bf880eef1da82f1db96097b..fe5954f2a8ea0ea554aac26539cbdd1ee03aae28 100644 (file)
--- a/undead.c
+++ b/undead.c
@@ -2506,20 +2506,21 @@ static void draw_pencils(drawing *dr, game_drawstate *ds,
 static int is_hint_stale(const game_drawstate *ds, int hflash,
                          const game_state *state, int index)
 {
-    if (!ds->started) return TRUE;
-    if (ds->hflash != hflash) return TRUE;
+    int ret = FALSE;
+    if (!ds->started) ret = TRUE;
+    if (ds->hflash != hflash) ret = TRUE;
 
     if (ds->hint_errors[index] != state->hint_errors[index]) {
         ds->hint_errors[index] = state->hint_errors[index];
-        return TRUE;
+        ret = TRUE;
     }
 
     if (ds->hints_done[index] != state->hints_done[index]) {
         ds->hints_done[index] = state->hints_done[index];
-        return TRUE;
+        ret = TRUE;
     }
 
-    return FALSE;
+    return ret;
 }
 
 static void game_redraw(drawing *dr, game_drawstate *ds,