Selaa lähdekoodia

Do not abort battle opening sound, only allow actions

Ivan Savenko 2 vuotta sitten
vanhempi
sitoutus
4968ac58b4

+ 15 - 14
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

+ 1 - 1
client/battle/BattleInterface.h

@@ -146,7 +146,7 @@ public:
 	static CondSh<BattleAction *> givenCommand; //data != nullptr if we have i.e. moved current unit
 
 	bool openingPlaying();
-	void openingAbort();
+	void openingEnd();
 
 	bool makingTurn() const;
 

+ 1 - 1
client/battle/BattleWindow.cpp

@@ -181,7 +181,7 @@ void BattleWindow::keyPressed(const SDL_Keycode & key)
 {
 	if (owner.openingPlaying())
 	{
-		owner.openingAbort();
+		owner.openingEnd();
 		return;
 	}