changeset 2423:1b6bf88f561b

fixing some memory access errors
author Grumpy7
date Tue, 22 Jul 2014 23:07:24 +0200
parents bb1273b1b9b6
children 255168c31655 d922225a6081
files OSWindow.cpp PaletteManager.cpp mm7_2.cpp texts.cpp
diffstat 4 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/OSWindow.cpp	Wed Jul 23 01:18:24 2014 +0600
+++ b/OSWindow.cpp	Tue Jul 22 23:07:24 2014 +0200
@@ -351,9 +351,12 @@
           else
             pMiscTimer->Pause();
 
-          pAudioPlayer->StopChannels(-1, -1);//приостановка воспроизведения звуков при неактивном окне игры
-          if ( pAudioPlayer->hAILRedbook )
-            AIL_redbook_pause(pAudioPlayer->hAILRedbook);
+          if (pAudioPlayer != nullptr)
+          {
+            pAudioPlayer->StopChannels(-1, -1);//приостановка воспроизведения звуков при неактивном окне игры
+            if ( pAudioPlayer->hAILRedbook )
+              AIL_redbook_pause(pAudioPlayer->hAILRedbook);
+          }
         }
       }
       return *result = 0, true;
--- a/PaletteManager.cpp	Wed Jul 23 01:18:24 2014 +0600
+++ b/PaletteManager.cpp	Tue Jul 22 23:07:24 2014 +0200
@@ -668,8 +668,10 @@
     pBaseColors[0][i][2] = i;
   }
 
+  memset(pPaletteIDs, 0, sizeof(pPaletteIDs));
+  memset(pPalette_tintColor, 0, sizeof(pPalette_tintColor));
+  memset(pPalette_mistColor, 0, sizeof(pPalette_mistColor));
   CalcPalettes_LUT(0);
-  memset(pPaletteIDs, 0, sizeof(pPaletteIDs));
 }
 
 //----- (0048A336) --------------------------------------------------------
--- a/mm7_2.cpp	Wed Jul 23 01:18:24 2014 +0600
+++ b/mm7_2.cpp	Tue Jul 22 23:07:24 2014 +0200
@@ -1422,6 +1422,8 @@
 
   srand(GetTickCount());
 
+  pEventTimer = Timer::Create();
+  pEventTimer->Initialize();
   window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);
 
   pRenderer = Render::Create();
@@ -1459,8 +1461,6 @@
 
   pKeyActionMap = new KeyboardActionMapping;
 
-  pEventTimer = Timer::Create();
-  pEventTimer->Initialize();
   // _CrtDumpMemoryLeaks();
   OnTimer(1);
   GameUI_StatusBar_UpdateTimedString(1);
--- a/texts.cpp	Wed Jul 23 01:18:24 2014 +0600
+++ b/texts.cpp	Tue Jul 22 23:07:24 2014 +0200
@@ -113,10 +113,10 @@
 		}*/
 	strtok((char *)pGlobalTXT_Raw, "\r");	   //Carriage Return 0D 13
 	strtok(NULL, "\r");					   	  //Carriage Return 0D 13
-	test_string = strtok(NULL, "\r") + 1;	 //Carriage Return 0D 13
 
 	for (int i = 0; i < MAX_LOC_STRINGS; ++i)
-		{
+  {
+    test_string = strtok(NULL, "\r") + 1;	 //Carriage Return 0D 13
 		step = 0;
 		string_end = false;
 		do
@@ -149,8 +149,6 @@
 			test_string=tmp_pos+1;
 			}
 		while ( step <= 2 && !string_end);  
-
-		test_string = strtok(NULL, "\r") + 1;  //Carriage Return 0D 13 //Invalid memory access
 		}	
 
   SetSomeItemsNames();