From d157735846433d52fd0c1c9f7c0f376f6260252c Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 4 Jan 2023 18:15:26 +0200 Subject: [PATCH] Initialize new animations if current one is over --- client/battle/BattleStacksController.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index ab96710e0..78ce32836 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -350,27 +350,22 @@ void BattleStacksController::updateBattleAnimations() { // operate on copy - to prevent potential iterator invalidation due to push_back's // FIXME? : remove remaining calls to addNewAnim from BattleAnimation::nextFrame (only Catapult explosion at the time of writing) + auto copiedVector = currentAnimations; for (auto & elem : copiedVector) - { - if (!elem) - continue; - - if (elem->isInitialized()) + if (elem && elem->isInitialized()) elem->nextFrame(); - else + + for (auto & elem : copiedVector) + if (elem && !elem->isInitialized()) elem->tryInitialize(); - } bool hadAnimations = !currentAnimations.empty(); vstd::erase(currentAnimations, nullptr); if (hadAnimations && currentAnimations.empty()) - { - //anims ended owner.setAnimationCondition(EAnimationEvents::ACTION, false); - } } void BattleStacksController::addNewAnim(BattleAnimation *anim)