changeset 2412:e7a551f458e1

LoadSound - cause of the crash exe file
author Ritor1
date Wed, 16 Jul 2014 17:22:12 +0600
parents 4106678916e1
children 0673a59ec9e5
files AudioPlayer.cpp OSAPI.cpp mm7_2.cpp
diffstat 3 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Tue Jul 15 20:21:08 2014 +0600
+++ b/AudioPlayer.cpp	Wed Jul 16 17:22:12 2014 +0600
@@ -85,8 +85,7 @@
       pSoundDesc = &pSoundList->pSL_Sounds[i];
       if ( pSoundList->pSL_Sounds[i].eType != SOUND_DESC_SYSTEM )
         continue;
-      sprintf(pSoundName, "%s", pSL_Sounds[i].pSoundName);
-      pSoundList->pSL_Sounds[i].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)-1, pSL_Sounds[i].uSoundID);
+      pSoundList->pSL_Sounds[i].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)-1, pSL_Sounds[i].uSoundID); // Ritor result crash exe file
       if ( !pAudioPlayer->b3DSoundInitialized )
         continue;
       pSoundDesc = &pSoundList->pSL_Sounds[i];
--- a/OSAPI.cpp	Tue Jul 15 20:21:08 2014 +0600
+++ b/OSAPI.cpp	Wed Jul 16 17:22:12 2014 +0600
@@ -16,15 +16,17 @@
   Log::Initialize();
   
   //if (HWND hMM7Window = FindWindowW(L"MM7", 0))
-  if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))
+  if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))//check whether the window is open(проверка открыто ли окно такое же)
   {
     if (IsIconic(hMM7Window))
       ShowWindow(hMM7Window, SW_RESTORE);
     SetForegroundWindow(GetLastActivePopup(hMM7Window));
     return 0;
   }
-
+  //GetActiveWindow() возвращает дескриптор активного окна текущего приложения(котоpое имеет текущий фокус ввода).
+  //В случае ошибки,или в случае,если в программе нет активных окон,функция возвращает 0. 
   HWND hPrevWindow = GetActiveWindow();
+  if (!hPrevWindow)
   {
     Log::Warning(L"OS init: ok");
     extern bool MM_Main(const wchar_t *pCmdLine);
--- a/mm7_2.cpp	Tue Jul 15 20:21:08 2014 +0600
+++ b/mm7_2.cpp	Wed Jul 16 17:22:12 2014 +0600
@@ -1778,6 +1778,7 @@
   //pSprites_LOD->can_load_hardware_sprites = 1;
   pObjectList->InitializeSprites();
   pOverlayList->InitializeSprites();
+
   if (!bNoSound)
     pSoundList->Initialize();