changeset 699:0c6510a626e2

Merge
author Gloval
date Sun, 17 Mar 2013 18:32:09 +0400
parents b097497f07e2 (current diff) 2dfb67633b01 (diff)
children 1d05543f522d
files
diffstat 8 files changed, 97 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/Allocator.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/Allocator.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -75,7 +75,7 @@
 			  AbortWithError();
 		  }
 
-	  pMemoryBuffers[uNumBuffersUsed] = (char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer;
+	  pMemoryBuffers[uNumBuffersUsed] = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;//(char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer;
 	  uMemoryBuffersSizes[uNumBuffersUsed] =aligned_size;
 
 	  if (pName)
@@ -201,8 +201,8 @@
 	  for (indx = 0; indx <=uNumBuffersUsed; ++indx)
 		  if (pMemoryBuffers[indx] == ptr)	
 			  break;
-	//  if ((indx>uNumBuffersUsed)&& !aborting_app )
-//		  AbortWithError(); to detect memory problems - uncomment
+	  if ((indx>uNumBuffersUsed)&& !aborting_app )
+		  AbortWithError(); //to detect memory problems - uncomment
 	  if (!bUseBigBuffer)
 		  free(pMemoryBuffers[indx]);
 	  pMemoryBuffers[indx] = NULL;
--- a/GUIButton.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/GUIButton.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -113,12 +113,14 @@
 
 
 //----- (0041D0D8) --------------------------------------------------------
-void GUIButton::_41D0D8(GUIButton *ptr)
+void GUIButton::Release()
 {
   GUIWindow *v1; // eax@2
   GUIButton *v2; // edx@2
   GUIButton *v3; // eax@6
+  GUIButton *ptr;
 
+  ptr=this;
   if ( ptr )
   {
     v1 = ptr->pParent;
--- a/GUIButton.h	Sun Mar 17 18:31:54 2013 +0400
+++ b/GUIButton.h	Sun Mar 17 18:32:09 2013 +0400
@@ -7,7 +7,7 @@
 {
   char DrawLabel(const char *edx0, struct GUIFont *pFont, int a5, int *a9);
 
-  static void _41D0D8(GUIButton *ptr);
+  void Release();
 
 
   unsigned int uX;
--- a/GUIWindow.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/GUIWindow.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -294,11 +294,6 @@
 void GUIWindow::Release()
 {
   GUIWindow *v1; // esi@1
-  unsigned int v2; // eax@2
-  int v3; // eax@5
-  int v4; // eax@6
-  int v5; // eax@14
-  int v6; // eax@15
   int i; // edi@20
   GUIButton *v8; // eax@26
   GUIButton *v9; // edi@27
@@ -309,82 +304,78 @@
   v1 = this;
   if ( !this )
     return;
-  v2 = this->eWindowType;
-  if ( (signed int)v2 > 18 )
+  
+  switch( this->eWindowType )
   {
-    v5 = v2 - 19;
-    if ( !v5 )
-    {
-      pIcons_LOD->_40F9C5();
-      pCurrentScreen = pMainScreenNum;
-      pKeyActionMap->_459ED1(3);
-      goto LABEL_26;
-    }
-    v6 = v5 - 6;
-    if ( !v6 )
-    {
-      for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
-        pDialogueNPCPortraits[i]->Release();
-      uNumDialogueNPCPortraits = 0;
-      pTexture_Dialogue_Background->Release();
+	case WINDOW_GreetingNPC:
+		{
+		pIcons_LOD->_40F9C5();
+		pCurrentScreen = pMainScreenNum;
+		pKeyActionMap->_459ED1(3);
+		break;
+		}
+	case WINDOW_HouseInterior:
+		{
+		for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
+			pDialogueNPCPortraits[i]->Release();
+		uNumDialogueNPCPortraits = 0;
+		pTexture_Dialogue_Background->Release();
 
-      pIcons_LOD->_40F9C5();
-      pIcons_LOD->_4114F2();
-      dword_5C35D4 = 0;
-      if ( bFlipOnExit )
-      {
-        pIndoorCamera->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (stru_5C6E00->uIntegerPi
-                                                                       + pIndoorCamera->sRotationY);
-        pParty->sRotationY = pIndoorCamera->sRotationY;
-      }
-      pParty->uFlags |= 2u;
-      goto LABEL_26;
-    }
-    if ( v6 == 1 )
-    {
-      pVideoPlayer->Unload();
-      goto LABEL_18;
-    }
-  }
-  else
-  {
-    if ( v2 == 18 )
-    {
-      sub_41140B();
-      sub_411473();
-    }
-    else
-    {
-      if ( !v2 )
-        return;
-      v3 = v2 - 9;
-      if ( v3 )
-      {
-        v4 = v3 - 1;
-        if ( !v4 )
-        {
-          if ( !dword_591084 )
-            pDialogueNPCPortraits[0]->Release();
-          uNumDialogueNPCPortraits = 0;
-          pTexture_Dialogue_Background->Release();
-
-          pIcons_LOD->_40F9C5();
-          goto LABEL_19;
-        }
-        if ( v4 != 7 )
-          goto LABEL_26;
-LABEL_18:
+		pIcons_LOD->_40F9C5();
+		pIcons_LOD->_4114F2();
+		dword_5C35D4 = 0;
+		if ( bFlipOnExit )
+		{
+			pIndoorCamera->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (stru_5C6E00->uIntegerPi
+																			+ pIndoorCamera->sRotationY);
+			pParty->sRotationY = pIndoorCamera->sRotationY;
+		}
+		pParty->uFlags |= 2u;
+		break;
+		}
+	case WINDOW_Transition:
+		{
+		pVideoPlayer->Unload();
+		pTexture_outside->Release();
+		pTexture_Dialogue_Background->Release();
+		pIcons_LOD->_40F9C5();
+		pCurrentScreen = pMainScreenNum;
+		break;
+		}
+	case WINDOW_SpellBook:
+		{
+		sub_41140B();
+		sub_411473();
+		break;
+		}
+	case WINDOW_Book:
+		{
+		OnCloseSpellook();
+		break;
+		}
+	case WINDOW_ChangeLocation:
+		{
         pTexture_outside->Release();
         pTexture_Dialogue_Background->Release();
         pIcons_LOD->_40F9C5();
-LABEL_19:
         pCurrentScreen = pMainScreenNum;
-        goto LABEL_26;
-      }
-      OnCloseSpellook();
-    }
+        break;
+		}
+	case WINDOW_Dialogue:
+		{
+        if ( !dword_591084 )
+	        pDialogueNPCPortraits[0]->Release();
+        uNumDialogueNPCPortraits = 0;
+        pTexture_Dialogue_Background->Release();
+
+        pIcons_LOD->_40F9C5();
+        pCurrentScreen = pMainScreenNum;
+		}
+	default:
+		{
+		break;
+		}
   }
-LABEL_26:
   v8 = v1->pControlsHead;
   if ( v8 )
   {
--- a/mm7_1.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/mm7_1.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -87,7 +87,7 @@
     for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
     {
       if ( BYTE1(i->field_1C) & 0x80 )
-        GUIButton::_41D0D8(i);
+        i->Release();
     }
     for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext )
     {
--- a/mm7_3.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/mm7_3.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -13381,11 +13381,9 @@
   int v1; // ebx@3
   int v2; // edi@3
   int v3; // eax@3
-  int v4; // esi@5
   int v5; // edi@6
   int v6; // eax@6
   int v7; // eax@6
-  BSPModel **v8; // ecx@6
   unsigned __int8 v9; // zf@7
   unsigned __int8 v10; // sf@7
   ODMFace *v11; // eax@9
@@ -13397,7 +13395,7 @@
   const char *v17; // [sp+4h] [bp-1Ch]@3
   unsigned int pY; // [sp+8h] [bp-18h]@3
   float v19; // [sp+Ch] [bp-14h]@1
-  int v20; // [sp+10h] [bp-10h]@1
+  int v20;
   int v21; // [sp+14h] [bp-Ch]@1
   unsigned int v22; // [sp+18h] [bp-8h]@8
   int pX; // [sp+1Ch] [bp-4h]@3
@@ -13418,29 +13416,25 @@
   LODWORD(v19) = (signed __int64)((double)v21 - (double)(signed int)(pY - 181) * v0);
   v2 = abs(v1 + 22528) / 512;
   v3 = abs((signed)LODWORD(v19) - 22528);
+  result = 0;
   if ( pOutdoor->_47F04C(v2, v3 / 512)
     && uCurrentlyLoadedLevelType == LEVEL_Outdoor
-    && (v4 = 0, v20 = 0, (signed int)v16 > 0) )
-  {
-    while ( 1 )
-    {
-      pX = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.x) - v1;
-      pY = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.y) - LODWORD(v19);
+    && (signed int)v16 > 0 )
+  {
+	for(int i = 0; i < pOutdoor->uNumBModels && !v17; i++)
+    {
+      pX = pOutdoor->pBModels[i].vBoundingCenter.x - v1;
+      pY = pOutdoor->pBModels[i].vBoundingCenter.y - LODWORD(v19);
       v5 = abs((signed)pY);
       v6 = abs((signed)pX);
       v7 = int_get_vector_length(v6, v5, 0);
-      v8 = &pOutdoor->pBModels;
-      if ( v7 < *(int *)((char *)&pOutdoor->pBModels[v4].sBoundingRadius) )
-      {
-        v9 = pOutdoor->pBModels[v4].uNumFaces == 0;
-        v10 = pOutdoor->pBModels[v4].uNumFaces < 0;
-        v21 = 0;
-        if ( !(v10 | v9) )
-        {
-          v22 = 0;
-          do
-          {
-            v11 = &v8[v4]->pFaces[v22 / 0x134];
+      if ( v7 < pOutdoor->pBModels[i].sBoundingRadius )
+      {
+        if ( pOutdoor->pBModels[i].uNumFaces > 0 )
+        {
+		  for(int j = 0; j < pOutdoor->pBModels[i].uNumFaces; j++)
+          {
+			v11 = &pOutdoor->pBModels[i].pFaces[j];//&v8[v4]->pFaces[v22 / 0x134];
             v12 = v11->sCogTriggeredID;
             if ( v12 )
             {
@@ -13455,26 +13449,11 @@
                 }
               }
             }
-            ++v21;
-            v8 = &pOutdoor->pBModels;
-            v22 += 308;
-          }
-          while ( v21 < pOutdoor->pBModels[v4].uNumFaces );
+          }
         }
         result = v17;
-        if ( v17 )
-          break;
-      }
-      ++v20;
-      v4 += 188;
-      if ( v20 >= (signed int)v16 )
-        goto LABEL_17;
-    }
-  }
-  else
-  {
-LABEL_17:
-    result = 0;
+      }
+    }
   }
   return result;
 }
--- a/mm7_4.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/mm7_4.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -10703,7 +10703,7 @@
     else
     {
       for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
-        GUIButton::_41D0D8((GUIButton *)HouseNPCData[i + 7]);
+        ((GUIButton *)HouseNPCData[i + 7])->Release();
     }
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, 0x71u,  0,  0,
--- a/mm7_5.cpp	Sun Mar 17 18:31:54 2013 +0400
+++ b/mm7_5.cpp	Sun Mar 17 18:32:09 2013 +0400
@@ -3049,8 +3049,8 @@
           continue;
         case UIMSG_55:
           bRingsShownInCharScreen ^= v0;
-          GUIButton::_41D0D8(pCharacterScreen_DetalizBtn);
-          GUIButton::_41D0D8(pCharacterScreen_DollBtn);
+		  pCharacterScreen_DetalizBtn->Release();
+          pCharacterScreen_DollBtn->Release();
           if ( bRingsShownInCharScreen )
           {
             v128 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureHeight : 26);
@@ -17447,9 +17447,9 @@
   if ( dword_507CBC )
   {
     dword_507CBC = 0;
-    GUIButton::_41D0D8(ptr_507BA4);
-    GUIButton::_41D0D8(pBtn_Up);
-    GUIButton::_41D0D8(pBtn_Down);
+	ptr_507BA4->Release();
+    pBtn_Up->Release();
+    pBtn_Down->Release();
     pBtn_Down = 0;
     pBtn_Up = 0;
     for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )