From 4d5311789e6a62cfddf19f00162604588db8c092 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 16 Dec 2022 23:22:04 +0200 Subject: [PATCH] Fixes #831 - do not process any incoming Packs until opening is over --- client/battle/BattleActionsController.cpp | 14 +++++++------- client/battle/BattleInterface.cpp | 14 +++++--------- client/battle/BattleInterface.h | 1 - 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/client/battle/BattleActionsController.cpp b/client/battle/BattleActionsController.cpp index 638efbf14..1e367af51 100644 --- a/client/battle/BattleActionsController.cpp +++ b/client/battle/BattleActionsController.cpp @@ -230,13 +230,13 @@ void BattleActionsController::castThisSpell(SpellID spellID) } } - -void BattleActionsController::handleHex(BattleHex myNumber, int eventType) -{ - if (!owner.myTurn || !owner.battleActionsStarted) //we are not permit to do anything - return; - - // This function handles mouse move over hexes and l-clicking on them. + +void BattleActionsController::handleHex(BattleHex myNumber, int eventType) +{ + if (!owner.myTurn) //we are not permit to do anything + return; + + // This function handles mouse move over hexes and l-clicking on them. // First we decide what happens if player clicks on this hex and set appropriately // consoleMsg, cursorFrame/Type and prepare lambda realizeAction. // diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index 3d59babb0..f68217a48 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -59,7 +59,6 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet * , myTurn(false) , moveSoundHander(-1) , bresult(nullptr) - , battleActionsStarted(false) { OBJ_CONSTRUCTION; @@ -169,13 +168,14 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet * tacticNextStack(nullptr); CCS->musich->stopMusic(); + setAnimationCondition(EAnimationEvents::OPENING, true); battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds); auto onIntroPlayed = [&]() { if(LOCPLINT->battleInt) { CCS->musich->playMusicFromSet("battle", true, true); - battleActionsStarted = true; + setAnimationCondition(EAnimationEvents::OPENING, false); activateStack(); battleIntroSoundChannel = -1; } @@ -290,7 +290,7 @@ void BattleInterface::keyPressed(const SDL_KeyboardEvent & key) } else if(key.keysym.sym == SDLK_ESCAPE) { - if(!battleActionsStarted) + if(getAnimationCondition(EAnimationEvents::OPENING) == true) CCS->soundh->stopSound(battleIntroSoundChannel); else actionsController->endCastingSpell(); @@ -371,7 +371,7 @@ void BattleInterface::stackAttacking( const StackAttackInfo & attackInfo ) void BattleInterface::newRoundFirst( int round ) { - waitForAnimationCondition(EAnimationEvents::ACTION, false); + waitForAnimationCondition(EAnimationEvents::OPENING, false); } void BattleInterface::newRound(int number) @@ -689,9 +689,6 @@ void BattleInterface::trySetActivePlayer( PlayerColor player ) void BattleInterface::activateStack() { - if(!battleActionsStarted) - return; //"show" function should re-call this function - stacksController->activateStack(); const CStack * s = stacksController->getActiveStack(); @@ -905,8 +902,7 @@ void BattleInterface::show(SDL_Surface *to) fieldController->renderBattlefield(canvas); - if(battleActionsStarted) - stacksController->updateBattleAnimations(); + stacksController->updateBattleAnimations(); SDL_SetClipRect(to, &buf); //restoring previous clip_rect diff --git a/client/battle/BattleInterface.h b/client/battle/BattleInterface.h index a29602379..4a64a6794 100644 --- a/client/battle/BattleInterface.h +++ b/client/battle/BattleInterface.h @@ -110,7 +110,6 @@ private: ui8 animCount; bool tacticsMode; - bool battleActionsStarted; //used for delaying battle actions until intro sound stops int battleIntroSoundChannel; //required as variable for disabling it via ESC key using AwaitingAnimationAction = std::function;