From 7d9a73be32bf2e560188ecef44376306189d9933 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 26 Oct 2026 21:50:50 +0200
Subject: [PATCH 87/87] Fix client crash on exit when movement animations still
 running

Reported by Dean Brown

See RM #2424

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/mapview_common.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/client/mapview_common.c b/client/mapview_common.c
index f7425136f6..9b43fafc6d 100644
--- a/client/mapview_common.c
+++ b/client/mapview_common.c
@@ -195,18 +195,21 @@ void animations_free(void)
     for (i = 0; i < last; i++) {
       struct animation *anim = animation_list_get(animations, i);
 
-      switch (anim->type) {
-      case ANIM_MOVEMENT:
-        unit_virtual_destroy(anim->movement.mover);
-        break;
-      case ANIM_BATTLE:
-        unit_virtual_destroy(anim->battle.virt_winner);
-        unit_virtual_destroy(anim->battle.virt_loser);
-        break;
-      case ANIM_EXPL:
-      case ANIM_NUKE:
-        /* Nothing to free */
-        break;
+      /* Finished animation has virtual units already destroyed */
+      if (!anim->finished) {
+        switch (anim->type) {
+        case ANIM_MOVEMENT:
+          unit_virtual_destroy(anim->movement.mover);
+          break;
+        case ANIM_BATTLE:
+          unit_virtual_destroy(anim->battle.virt_winner);
+          unit_virtual_destroy(anim->battle.virt_loser);
+          break;
+        case ANIM_EXPL:
+        case ANIM_NUKE:
+          /* Nothing to free */
+          break;
+        }
       }
 
       free(anim);
-- 
2.53.0

