diff Engine/Game.cpp @ 2508:491f0babd563

use_music_folder
author Ritor1
date Thu, 02 Oct 2014 11:52:31 +0600
parents 9b96a51011fb
children fb1c61a82a55
line wrap: on
line diff
--- a/Engine/Game.cpp	Thu Sep 25 10:40:16 2014 +0600
+++ b/Engine/Game.cpp	Thu Oct 02 11:52:31 2014 +0600
@@ -316,7 +316,10 @@
 
   LoadPlayerPortraintsAndVoices();
   pIcons_LOD->_inlined_sub1();
-  pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+  if ( use_music_folder )
+    alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+  else
+    pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
 
   while ( 2 )
   {
@@ -1715,7 +1718,10 @@
             GUIWindow::Create(243, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0);
-            pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+		    if ( use_music_folder )
+              alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+			else
+              pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
             continue;
           }
           if ( uMessageParam == 5 )//+
@@ -1726,7 +1732,10 @@
             GUIWindow::Create(435, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0);
-            pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+		    if ( use_music_folder )
+              alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+			else
+              pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
             continue;
           }
           uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;//for mouse
@@ -1734,7 +1743,10 @@
             uMusicVolimeMultiplier = 9;
           if ( uMusicVolimeMultiplier )
             pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0);
-          pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+	      if ( use_music_folder )
+            alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+		  else
+            pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
           continue;
         case UIMSG_ChangeSoundVolume:
           if ( uMessageParam == 4 )//reduce sound level button left
@@ -4756,15 +4768,15 @@
 	if (GetFileAttributesW(pMagicPath) == -1)
 		return false;
 
+	//Open CD audio
 	wsprintfA(strCommand, "open %c: type cdaudio alias CD", c);
-	if (!mciSendStringA(strCommand, DstBuf, 255, 0))//Uninitialized memory access
-
-	{
-		wsprintfA(strCommand, "info CD UPC wait");
-		mciSendStringA(strCommand, DstBuf, 255, 0);
-		wsprintfA(strCommand, "close CD");
-		mciSendStringA(strCommand, DstBuf, 255, 0);
-	}
+    if (!mciSendStringA(strCommand, DstBuf, 255, 0))
+    {
+      wsprintfA(strCommand, "info CD UPC wait");
+      mciSendStringA(strCommand, DstBuf, 255, 0);
+      wsprintfA(strCommand, "close CD");
+      mciSendStringA(strCommand, DstBuf, 255, 0);
+    }
 
 	memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename));
 	*Filename = c;
@@ -4962,11 +4974,11 @@
 	pEventTimer->Initialize();
 	window = OSWindow::Create(L"Might and MagicŪ Trilogy", game_width, game_height);//Create  game window
 
-	//bool use_d3d11 = false;
-	//if (use_d3d11)
-		//pRenderer = RenderD3D11::Create();
-	//else
-		pRenderer = Render::Create();//Create DirectX
+	bool use_d3d11 = false;
+	if (use_d3d11)
+      pRenderer = RenderD3D11::Create();
+	else
+      pRenderer = Render::Create();//Create DirectX
 	if (!pRenderer)
 	{
 		Log::Warning(L"Render creation failed");
@@ -5382,6 +5394,7 @@
 bool new_sky = false;            //new sky(need texture)
 int max_flight_height = 4000;    //maximum altitude
 bool use_MMT = false;
+bool use_music_folder = true;
 bool for_refactoring = false;
 
 //----- (00462C94) --------------------------------------------------------
@@ -5477,8 +5490,13 @@
 
 			if (GetCurrentMenuID() == MENU_NEWGAME)
 			{
+              if ( use_music_folder )
+                alSourceStop(mSourceID);
+              else
+			  {
 				if (pAudioPlayer->hAILRedbook)
 					AIL_redbook_stop(pAudioPlayer->hAILRedbook);
+			  }
 				pParty->Reset();
 				pOtherOverlayList->Reset();
 				strcpy(pCurrentMapName, pStartingMapName);
@@ -5508,10 +5526,15 @@
 			}
 			if (GetCurrentMenuID() == MENU_CREDITS)
 			{
+              if ( use_music_folder )
+                alSourceStop(mSourceID);
+              else
+			  {
 				if (pAudioPlayer->hAILRedbook)
 					AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-				MainMenuUI_Credits_Loop();
-				break;
+			  }
+			  MainMenuUI_Credits_Loop();
+			  break;
 			}
 			if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
 			{
@@ -5561,13 +5584,21 @@
 				break;
 			}
 		}
-		if (!bNoSound && pAudioPlayer->hAILRedbook)
+		if (!bNoSound )
 		{
+		  if ( use_music_folder )
+	      {
+	       PlayAudio(L"Music\\14.mp3");
+	       alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+	      }
+	      else if ( pAudioPlayer->hAILRedbook)
+		  {
 			pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
 			AIL_redbook_stop(pAudioPlayer->hAILRedbook);
 			unsigned int startms, end_ms;
 			AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms);
 			AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
+		  }
 		}
 	}
 	//lua_close(L);