diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index e5b7c2dd6..ac63b6ee8 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -103,12 +103,6 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet * void BattleInterface::playIntroSoundAndUnlockInterface() { - if(settings["gameTweaks"]["skipBattleIntroMusic"].Bool()) - { - onIntroSoundPlayed(); - return; - } - auto onIntroPlayed = [this]() { if(LOCPLINT->battleInt) @@ -120,19 +114,22 @@ void BattleInterface::playIntroSoundAndUnlockInterface() battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds); if (battleIntroSoundChannel != -1) + { CCS->soundh->setCallback(battleIntroSoundChannel, onIntroPlayed); + + if (settings["gameTweaks"]["skipBattleIntroMusic"].Bool()) + openingEnd(); + } else onIntroSoundPlayed(); } void BattleInterface::onIntroSoundPlayed() { - onAnimationsFinished(); + if (openingPlaying()) + openingEnd(); + CCS->musich->playMusicFromSet("battle", true, true); - if(tacticsMode) - tacticNextStack(nullptr); - activateStack(); - battleIntroSoundChannel = -1; } BattleInterface::~BattleInterface() @@ -532,13 +529,17 @@ bool BattleInterface::openingPlaying() return battleIntroSoundChannel != -1; } -void BattleInterface::openingAbort() +void BattleInterface::openingEnd() { + assert(openingPlaying()); if (!openingPlaying()) return; - // stop playing sound, causing SDL to call sound finished callback - CCS->soundh->stopSound(battleIntroSoundChannel); + onAnimationsFinished(); + if(tacticsMode) + tacticNextStack(nullptr); + activateStack(); + battleIntroSoundChannel = -1; } bool BattleInterface::makingTurn() const diff --git a/client/battle/BattleInterface.h b/client/battle/BattleInterface.h index b5cbaedb6..e2d4db1ff 100644 --- a/client/battle/BattleInterface.h +++ b/client/battle/BattleInterface.h @@ -146,7 +146,7 @@ public: static CondSh givenCommand; //data != nullptr if we have i.e. moved current unit bool openingPlaying(); - void openingAbort(); + void openingEnd(); bool makingTurn() const; diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index fa3bcc69e..865a410d0 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -181,7 +181,7 @@ void BattleWindow::keyPressed(const SDL_Keycode & key) { if (owner.openingPlaying()) { - owner.openingAbort(); + owner.openingEnd(); return; }