From 9b9c3e0649eb19e4488fd3c59d0ebf2830232810 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 9 Nov 2024 21:48:30 +0200
Subject: [PATCH 79/79] Redraw full screen for animations

See RM #1095

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/client_main.c |  5 +++++
 client/tilespec.c    | 13 +++++++++++--
 client/tilespec.h    |  2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/client/client_main.c b/client/client_main.c
index aec4b2179b..c301fcc27c 100644
--- a/client/client_main.c
+++ b/client/client_main.c
@@ -1214,6 +1214,11 @@ double real_timer_callback(void)
     time_until_next_call = MIN(time_until_next_call, blink_time);
   }
 
+  if (gui_properties.animations) {
+    advance_global_anim_state();
+    time_until_next_call = MIN(time_until_next_call, 0.1);
+  }
+
   if (get_num_units_in_focus() > 0) {
     double blink_time = blink_active_unit();
 
diff --git a/client/tilespec.c b/client/tilespec.c
index a0cd4c13cb..b56cf8756a 100644
--- a/client/tilespec.c
+++ b/client/tilespec.c
@@ -6701,8 +6701,6 @@ void focus_unit_in_combat(struct tileset *t)
 ****************************************************************************/
 void toggle_focus_unit_state(struct tileset *t)
 {
-  global_anim_time++;
-
   if (t->sprites.unit.select != nullptr) {
     anim_advance_time(t->sprites.unit.select);
   } else {
@@ -6710,6 +6708,17 @@ void toggle_focus_unit_state(struct tileset *t)
   }
 }
 
+/************************************************************************//**
+  Advance animations.
+****************************************************************************/
+void advance_global_anim_state(void)
+{
+  global_anim_time++;
+
+  dirty_all();
+  update_map_canvas(0, 0, mapview.store_width, mapview.store_height);
+}
+
 /************************************************************************//**
   Find unit that we can display from given tile.
 ****************************************************************************/
diff --git a/client/tilespec.h b/client/tilespec.h
index f39e9a4d23..a9371db12e 100644
--- a/client/tilespec.h
+++ b/client/tilespec.h
@@ -469,6 +469,8 @@ int index_ts_topology(int idx);
 struct sprite *load_popup_sprite(const char *tag);
 void unload_popup_sprite(const char *tag);
 
+void advance_global_anim_state(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-- 
2.45.2

