changeset 2212:e18200fcfb50

LoadTextureFromLOD
author Ritor1
date Thu, 13 Feb 2014 01:02:04 +0600
parents b4bb8296ecfa
children 05e74b19991d
files Actor.cpp DecalBuilder.cpp Game.cpp LOD.cpp UI/Books/UISpellBook.cpp UI/UICharacter.cpp mm7_2.cpp
diffstat 7 files changed, 57 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/Actor.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -2041,7 +2041,7 @@
   v7 = stru_5C6E00->Atan2(actor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, actor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
   v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
 
-  if ( BYTE1(v9) & 7 )      // turned away - just stand
+  if ( v9 & 0x700 )      // turned away - just stand
     Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4);
   else                      // facing player - play bored anim
   {
--- a/DecalBuilder.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/DecalBuilder.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -614,7 +614,7 @@
 			if ( v14 <= v10->radius )
 			{
 				v15 = a2->flags;
-				if ( v15 & 2 || BYTE1(v15) & 1 )
+				if ( a2->flags & 2 || a2->flags & 0x100 )
 				{
 					v16 = v10->field_1C;
 					if ( !(v16 & 1) )
--- a/Game.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/Game.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -583,21 +583,21 @@
   //double v2; // st7@2
   float depth; // ST00_4@9
   //bool result; // eax@9
-  unsigned int v5; // eax@14
+  //unsigned int v5; // eax@14
   __int64 v6; // kr00_8@21
-  unsigned int y; // [sp+4h] [bp-24h]@2
-  unsigned int x; // [sp+8h] [bp-20h]@2
+  //unsigned int y; // [sp+4h] [bp-24h]@2
+  //unsigned int x; // [sp+8h] [bp-20h]@2
   Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2
   Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2
-  POINT a2; // [sp+20h] [bp-8h]@1
+  POINT cursor; // [sp+20h] [bp-8h]@1
 
   //v1 = this;
   ++qword_5C6DF0;
   pParticleEngine->UpdateParticles();
-  pMouseInstance->GetCursorPos(&a2);
+  pMouseInstance->GetCursorPos(&cursor);
 
-  x = a2.y;
-  y = a2.x;
+  //x = cursor.y;
+  //y = cursor.x;
   if ( sub_4637E0_is_there_popup_onscreen() )
   {
     v11 = &vis_face_filter;
@@ -620,7 +620,7 @@
   }
   //depth = v2;
 
-  PickMouse(depth, y, x, false, v10, v11);
+  PickMouse(depth, cursor.x, cursor.y, false, v10, v11);
   pLightmapBuilder->std__vector_000004_size = 0;
   pLightmapBuilder->std__vector_183808_size = 0;
   pDecalBuilder->std__vector_pDecals_size = 0;
@@ -631,10 +631,7 @@
     if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
       pStru10Instance->bDoNotDrawPortalFrustum = false;
     if ( /*pRenderer->pRenderD3D &&*/ uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-    {
-      v5 = GetLevelFogColor();
-      pRenderer->uFogColor = v5 & 0xFFFFFF;
-    }
+      pRenderer->uFogColor = GetLevelFogColor() & 0xFFFFFF;
     if (uFlags & 0x0400)
       uFlags2 |= 0x01;
     /*if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
@@ -2247,8 +2244,7 @@
 
                           memset(&uTextureID_Optkb, 0, 0x14u);
                           pIcons_LOD->SyncLoadedFilesCount();
-                          uAction = 0;
-                          do
+                          for ( uAction = 0; uAction < 28; ++uAction )
                           {
                             v33 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
                             if ( v33 != pPrevVirtualCidesMapping[uAction] )
@@ -2270,9 +2266,7 @@
                             else
                               pKeyToggleType = TOGGLE_Continuously;
                             pKeyActionMap->SetKeyMapping(uAction, pPrevVirtualCidesMapping[uAction], pKeyToggleType);
-                            ++uAction;
                           }
-                          while ( uAction < 28 );
                           pKeyActionMap->StoreMappings();
                           stru_506E40.Release();
                           break;
--- a/LOD.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/LOD.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -2576,8 +2576,8 @@
     return -1;
   v8 = pOutTex;
   fread(pOutTex, 1, 0x30, pFile);
-  strcpy(v8->pName, pContainer);
-  if (/*pRenderer->pRenderD3D &&*/ v8->pBits & 2)
+  strcpy(pOutTex->pName, pContainer);
+  if (/*pRenderer->pRenderD3D &&*/ pOutTex->pBits & 2)
   {
     if (!pHardwareSurfaces || !pHardwareTextures)
     {
@@ -2593,15 +2593,13 @@
     if (_strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' )
     {
       if (_strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' )
-      {
         v14 = uNumLoadedFiles;
-      }
       else
       {
         pRenderer->hd_water_tile_id = uNumLoadedFiles;
         v14 = uNumLoadedFiles;
       }
-      v13 = pRenderer->LoadTexture(pContainer, v8->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]);
+      v13 = pRenderer->LoadTexture(pContainer, pOutTex->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]);
     }
     else
     {
@@ -2610,30 +2608,30 @@
       eTextureType = v12;
       *(char *)v12 = 104;
       strcpy((char *)(v12 + 1), pContainer);
-      v13 = pRenderer->LoadTexture((const char *)eTextureType, v8->palette_id1,
+      v13 = pRenderer->LoadTexture((const char *)eTextureType, pOutTex->palette_id1,
               (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], &pHardwareTextures[uNumLoadedFiles]);
       free((void *)eTextureType);
     }
     return v13;
   }
-  v15 = v8->uTextureSize;
-  v16 = &v8->uDecompressedSize;
-  pOutTex = (Texture *)v8->uTextureSize;
+  //v15 = v8->uTextureSize;
+  //v16 = &v8->uDecompressedSize;
+  //pOutTex = (Texture *)v8->uTextureSize;
   if ( !v8->uDecompressedSize || dword_011BA4 )
   {
-    v32 = malloc(v15);
+    v32 = malloc(v8->uTextureSize);
     v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v32;
-    fread(v32, 1, (size_t)pOutTex, pFile);
+    fread(v32, 1, (size_t)v8->uTextureSize, pFile);
   }
   else
   {
-    v17 = malloc(v8->uDecompressedSize);
-    v18 = v8->uTextureSize;
-    pContainer = (const char *)v17;
-    v19 = malloc(v18);
-    fread(v19, 1u, (size_t)pOutTex, pFile);
+    //v17 = malloc(v8->uDecompressedSize);
+    //v18 = v8->uTextureSize;
+    pContainer = (const char *)malloc(v8->uDecompressedSize);
+    v19 = malloc(v8->uTextureSize);
+    fread(v19, 1, (size_t)v8->uTextureSize, pFile);
     zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize);
-    v8->uTextureSize = *v16;
+    v8->uTextureSize = v8->uDecompressedSize;
     free(v19);
     if ( /*bUseLoResSprites*/false && v8->pBits & 2 )
     {
@@ -2648,24 +2646,24 @@
       v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2;
       //v24 = v8->uTextureWidth;
       v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2;
-      v25 = v8->uTextureHeight;
+      //v25 = v8->uTextureHeight;
       --v8->uWidthLn2;
       --v8->uHeightLn2;
       v8->uWidthMinus1 = v8->uTextureWidth - 1;
-      v26 = v25 - 1;
-      v27 = (signed __int16)v8->uTextureWidth * (signed __int16)v25;
-      v28 = pOutTex;
-      v8->uHeightMinus1 = v26;
-      v8->uSizeOfMaxLevelOfDetail = v27;
-      v8->uTextureSize = (unsigned int)v28;
+      //v26 = v25 - 1;
+      //v27 = (signed __int16)v8->uTextureWidth * (signed __int16)v25;
+      //v28 = pOutTex;
+      v8->uHeightMinus1 = v8->uTextureHeight - 1;
+      v8->uSizeOfMaxLevelOfDetail = (signed __int16)v8->uTextureWidth * (signed __int16)v8->uTextureHeight;
+      v8->uTextureSize = (unsigned int)pOutTex;
     }
     else
     {
-      v29 = *v16;
-      v30 = malloc(v29);
-      v31 = v8->uDecompressedSize;
+      //v29 = v8->uDecompressedSize;
+      v30 = malloc(v8->uDecompressedSize);
+      //v31 = v8->uDecompressedSize;
       v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v30;
-      memcpy(v30, pContainer, v31);
+      memcpy(v30, pContainer, v8->uDecompressedSize);
     }
     free((void *)pContainer);
   }
@@ -2675,7 +2673,7 @@
   {
     v33 = malloc(0x300);
     v8->pPalette24 = (unsigned __int8 *)v33;
-    fread(v33, 1u, 0x300u, pFile);
+    fread(v33, 1, 0x300u, pFile);
   }
   else
   {
@@ -2683,20 +2681,17 @@
     if ( eTextureType == TEXTURE_16BIT_PALETTE )
     {
       v8->pPalette16 = (unsigned __int16 *)malloc(0x200);
-      v38 = 0;
-      do
+      for ( v38 = 0; v38 < 256; ++v38 )
       {
-        fread((char *)&eTextureType + 3, 1u, 1u, pFile);
-        fread((char *)&pContainer + 3, 1u, 1u, pFile);
-        v39 = fread((char *)&pOutTex + 3, 1u, 1u, pFile);
+        fread((char *)&eTextureType + 3, 1, 1, pFile);
+        fread((char *)&pContainer + 3, 1, 1, pFile);
+        v39 = fread((char *)&pOutTex + 3, 1, 1, pFile);
         LOWORD(v39) = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(uTextureRedBits)));
         v8->pPalette16[v38] = v39 << (LOBYTE(uTextureBlueBits) + LOBYTE(uTextureGreenBits));
         LOWORD(v40) = (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(uTextureGreenBits)));
         v8->pPalette16[v38] += v40 << uTextureBlueBits;
         v8->pPalette16[v38] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(uTextureBlueBits)));
-        ++v38;
       }
-      while ( v38 < 256 );
       goto LABEL_36;
     }
   }
@@ -2718,24 +2713,17 @@
     v8->pLevelOfDetail1 = 0;
   }
   v8->pLevelOfDetail3 = v37;
-  v41 = 1;
-  while ( 1 << v41 != v8->uTextureWidth )
+  for ( v41 = 1; v41 < 15; ++v41 )
   {
-    ++v41;
-    if ( v41 >= 15 )
-      goto LABEL_48;
+    if ( 1 << v41 == v8->uTextureWidth )
+      v8->uWidthLn2 = v41;
   }
-  v8->uWidthLn2 = v41;
-LABEL_48:
-  v42 = 1;
-  while ( 1 << v42 != v8->uTextureHeight )
+  for ( v42 = 1; v42 < 15; ++v42 )
   {
-    ++v42;
-    if ( v42 >= 15 )
-      goto LABEL_53;
+    if ( 1 << v42 == v8->uTextureHeight )
+      v8->uHeightLn2 = v42;
   }
-  v8->uHeightLn2 = v42;
-LABEL_53:
+
   switch ( v8->uWidthLn2 )
   {
     case 2:
--- a/UI/Books/UISpellBook.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/UI/Books/UISpellBook.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -103,7 +103,7 @@
           {
             pX_coord = pViewport->uViewportTL_X +  pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos;
             pY_coord = pViewport->uViewportTL_Y +  pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos;
-            if ( BYTE1(pTexture->pBits) & 2 )
+            if ( pTexture->pBits & 0x200 )
               pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture);
             else
               pRenderer->DrawTextureIndexed(pX_coord, pY_coord, pTexture);
@@ -123,7 +123,7 @@
     {
       pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Xpos;
       pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Ypos;
-      if ( BYTE1(SBPageCSpellsTextureList[v10]->pBits) & 2 )
+      if ( SBPageCSpellsTextureList[v10]->pBits & 0x200 )
         pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
       else
         pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
--- a/UI/UICharacter.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/UI/UICharacter.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -2731,7 +2731,7 @@
     for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j )
     {
       j = i->pNext;
-      if ( BYTE1(i->field_1C) & 0x80 )
+      if ( i->field_1C & 0x8000 )
       {
         i->Release();
         free(i);
--- a/mm7_2.cpp	Wed Feb 12 20:51:37 2014 +0600
+++ b/mm7_2.cpp	Thu Feb 13 01:02:04 2014 +0600
@@ -916,11 +916,11 @@
 
   result = (int)pDst;
   v193 = pDst;
-  v231 = 0;
   if ( dstHeight <= 0 )
     return result;
   
-  do
+  //do
+  for ( v231 = 0; v231 < dstHeight; v231++ )
   {
     for (int counter = 0; counter < dstWidth; counter++)
     {
@@ -976,10 +976,10 @@
       v193 = (unsigned __int16 *)((char *)v193 + field_20_bits);
     }
     v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth));
-    ++v231;
+    //++v231;
     result = v231;
   }
-  while(v231 < dstHeight);
+  //while(v231 < dstHeight);
   return result;
 }