changeset 2555:67d837007a4c

ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
author a.parshin
date Thu, 14 May 2015 10:34:40 +0200
parents f2a8ed07e921
children 91c75d202d30
files Engine/Engine.cpp Engine/Graphics/Render.cpp Engine/Graphics/RenderStruct.h
diffstat 3 files changed, 56 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/Engine/Engine.cpp	Wed May 13 11:31:58 2015 +0200
+++ b/Engine/Engine.cpp	Thu May 14 10:34:40 2015 +0200
@@ -2094,8 +2094,6 @@
 //----- (00464479) --------------------------------------------------------
 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
 {
-    int v0; // esi@9
-
     if (pMouse)
         pMouse->SetCursorBitmap("MICON1");
 
@@ -2113,13 +2111,15 @@
     pSoundList->_4A9D79(0);
     uCurrentlyLoadedLevelType = LEVEL_null;
     pSpriteFrameTable->ResetSomeSpriteFlags();
-    v0 = uNumVisibleWindows;
     pParty->armageddon_timer = 0;
-    while (v0 > 0)
+
+    while (uNumVisibleWindows > 0)
     {
-        pWindowList[pVisibleWindowsIdxs[v0--] - 1]->Release();
-        delete pWindowList[pVisibleWindowsIdxs[v0--] - 1];
-        pWindowList[pVisibleWindowsIdxs[v0--] - 1] = nullptr;
+        pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1]->Release();
+        delete pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1];
+        pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1] = nullptr;
+
+        uNumVisibleWindows--;
     }
 }
 
--- a/Engine/Graphics/Render.cpp	Wed May 13 11:31:58 2015 +0200
+++ b/Engine/Graphics/Render.cpp	Thu May 14 10:34:40 2015 +0200
@@ -1250,28 +1250,49 @@
     }
   }
 
-  for (int i = 0; i < 4; i++)
-  {
-    delete[] this->pAvailableDevices[i].pDriverName;
-    this->pAvailableDevices[i].pDriverName = nullptr;
-
-    delete[] this->pAvailableDevices[i].pDeviceDesc;
-    this->pAvailableDevices[i].pDeviceDesc = nullptr;
-
-    delete[] this->pAvailableDevices[i].pDDraw4DevDesc;
-    this->pAvailableDevices[i].pDDraw4DevDesc = nullptr;
-
-    delete this->pAvailableDevices[i].pDirectDrawGUID;
-    this->pAvailableDevices[i].pDirectDrawGUID = nullptr;
-
-    delete[] this->pAvailableDevices[i].pName;
-    this->pAvailableDevices[i].pName = nullptr;
-
-    delete[] this->pAvailableDevices[i].pDescription;
-    this->pAvailableDevices[i].pDescription = nullptr;
-
-    delete this->pAvailableDevices[i].pGUID;
-    this->pAvailableDevices[i].pGUID = nullptr;
+    for (int i = 0; i < 4; i++)
+    {
+        if (this->pAvailableDevices[i].pDriverName)
+        {
+            delete[] this->pAvailableDevices[i].pDriverName;
+            this->pAvailableDevices[i].pDriverName = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pDeviceDesc)
+        {
+            delete[] this->pAvailableDevices[i].pDeviceDesc;
+            this->pAvailableDevices[i].pDeviceDesc = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pDDraw4DevDesc)
+        {
+            delete[] this->pAvailableDevices[i].pDDraw4DevDesc;
+            this->pAvailableDevices[i].pDDraw4DevDesc = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pDirectDrawGUID)
+        {
+            delete this->pAvailableDevices[i].pDirectDrawGUID;
+            this->pAvailableDevices[i].pDirectDrawGUID = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pName)
+        {
+            delete[] this->pAvailableDevices[i].pName;
+            this->pAvailableDevices[i].pName = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pDescription)
+        {
+            delete[] this->pAvailableDevices[i].pDescription;
+            this->pAvailableDevices[i].pDescription = nullptr;
+        }
+
+        if (this->pAvailableDevices[i].pGUID)
+        {
+            delete this->pAvailableDevices[i].pGUID;
+            this->pAvailableDevices[i].pGUID = nullptr;
+        }
   }
 
   delete[] this->pAvailableDevices;
--- a/Engine/Graphics/RenderStruct.h	Wed May 13 11:31:58 2015 +0200
+++ b/Engine/Graphics/RenderStruct.h	Thu May 14 10:34:40 2015 +0200
@@ -105,6 +105,12 @@
 #pragma pack(push, 1)
 struct RenderD3D__DevInfo
 {
+    inline RenderD3D__DevInfo():
+        bIsDeviceCompatible(false), pName(nullptr), pDescription(nullptr),
+        pGUID(nullptr), uCaps(0), pDriverName(nullptr), pDeviceDesc(nullptr),
+        pDDraw4DevDesc(nullptr), pDirectDrawGUID(nullptr), uVideoMem(0)
+    {}
+
   unsigned int bIsDeviceCompatible;
   char *pName;
   char *pDescription;