1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Fixes #831 - do not process any incoming Packs until opening is over

This commit is contained in:
Ivan Savenko 2022-12-16 23:22:04 +02:00
parent 9e5f72166b
commit 4d5311789e
3 changed files with 12 additions and 17 deletions

View File

@ -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.
//

View File

@ -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

View File

@ -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<void()>;