From c6bd537b5276aeed9835079abc912adfeaae33e7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 27 Aug 2023 06:18:48 +0300 Subject: [PATCH 13/13] animations_free(): Free all animations data Previously only the main animations list was freed, not individual animations. See osdn #48446 Signed-off-by: Marko Lindqvist --- client/mapview_common.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index f876adff72..f89772ec21 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -188,6 +188,29 @@ void animations_init(void) void animations_free(void) { if (animations != NULL) { + int i; + size_t last = animation_list_size(animations); + + for (i = 0; i < last; i++) { + struct animation *anim = animation_list_get(animations, i); + + switch (anim->type) { + case ANIM_MOVEMENT: + free(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); + } + animation_list_destroy(animations); } } @@ -248,8 +271,9 @@ static bool movement_animation(struct animation *anim, double time_gone) if (time_gone >= timing_sec) { /* Animation over */ if (--anim->movement.mover->refcount <= 0) { - FC_FREE(anim->movement.mover); + free(anim->movement.mover); } + return TRUE; } } else { -- 2.40.1