瀏覽代碼

Fix battle start with disabled opening sounds

Ivan Savenko 3 年之前
父節點
當前提交
da7766e90b
共有 2 個文件被更改,包括 17 次插入6 次删除
  1. 16 6
      client/battle/BattleInterface.cpp
  2. 1 0
      client/battle/BattleInterface.h

+ 16 - 6
client/battle/BattleInterface.cpp

@@ -104,12 +104,7 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet *
 		if(LOCPLINT->battleInt)
 		{
 			boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
-			CCS->musich->playMusicFromSet("battle", true, true);
-			setAnimationCondition(EAnimationEvents::OPENING, false);
-			if(tacticsMode)
-				tacticNextStack(nullptr);
-			activateStack();
-			battleIntroSoundChannel = -1;
+			onIntroSoundPlayed();
 		}
 	};
 
@@ -120,6 +115,16 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet *
 	windowObject->updateQueue();
 }
 
+void BattleInterface::onIntroSoundPlayed()
+{
+	setAnimationCondition(EAnimationEvents::OPENING, false);
+	CCS->musich->playMusicFromSet("battle", true, true);
+	if(tacticsMode)
+		tacticNextStack(nullptr);
+	activateStack();
+	battleIntroSoundChannel = -1;
+}
+
 BattleInterface::~BattleInterface()
 {
 	CPlayerInterface::battleInt = nullptr;
@@ -223,6 +228,11 @@ void BattleInterface::stackAttacking( const StackAttackInfo & attackInfo )
 
 void BattleInterface::newRoundFirst( int round )
 {
+	if (battleIntroSoundChannel == -1 &&
+		getAnimationCondition(EAnimationEvents::OPENING) == true)
+	{
+		onIntroSoundPlayed();
+	}
 	waitForAnimationCondition(EAnimationEvents::OPENING, false);
 }
 

+ 1 - 0
client/battle/BattleInterface.h

@@ -113,6 +113,7 @@ class BattleInterface
 	/// defender interface, not null if attacker is human in our vcmiclient
 	std::shared_ptr<CPlayerInterface> defenderInt;
 
+	void onIntroSoundPlayed();
 public:
 	/// copy of initial armies (for result window)
 	const CCreatureSet *army1;