chiark / gitweb /
Patch I've had lurking around for over a year and not remembered to
authorSimon Tatham <anakin@pobox.com>
Mon, 20 Nov 2006 10:20:46 +0000 (10:20 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 20 Nov 2006 10:20:46 +0000 (10:20 +0000)
commit: arrange that midend_set_timer(), hence game_timing_state(),
is called when the game_ui is changed. This allows timed games to
work by obscuring the initial layout until an initial click causes
it to be revealed, without requiring that they store that reveal
operation as a move in the undo chain. Not that any games actually
do this, but it's clearly a sensible thing to want to do: since
game_timing_state() _receives_ a game_ui as a parameter, obviously
it should be consulted when the game_ui changes.

[originally from svn r6914]

midend.c

index 47d9b2ca5e7a0fdf11a1a5f4a59325240b9f7092..4d729e354af6a35ab053e79019a3371d9f277157 100644 (file)
--- a/midend.c
+++ b/midend.c
@@ -550,6 +550,7 @@ static int midend_really_process_key(midend *me, int x, int y, int button)
              * state has been updated and a redraw is called for.
              */
             midend_redraw(me);
+            midend_set_timer(me);
             goto done;
         } else if (s) {
            midend_stop_anim(me);
@@ -741,6 +742,8 @@ void midend_redraw(midend *me)
 
 void midend_timer(midend *me, float tplus)
 {
+    int need_redraw = (me->anim_time > 0 || me->flash_time > 0);
+
     me->anim_pos += tplus;
     if (me->anim_pos >= me->anim_time ||
         me->anim_time == 0 || !me->oldstate) {
@@ -753,7 +756,8 @@ void midend_timer(midend *me, float tplus)
        me->flash_pos = me->flash_time = 0;
     }
 
-    midend_redraw(me);
+    if (need_redraw)
+        midend_redraw(me);
 
     if (me->timing) {
        float oldelapsed = me->elapsed;