changeset 1635:04cae215a13c

Слияние
author Ritor1
date Tue, 17 Sep 2013 16:30:43 +0600
parents 08ebd0fee604 (current diff) 384a6b9d1333 (diff)
children ff3d7af671ec
files
diffstat 9 files changed, 54 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/LOD.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/LOD.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -2151,10 +2151,10 @@
   v5->pLevelOfDetail0_prolly_alpha_mask = 0;
   if ( v6 )
   {
-    v7 = operator new(v6);
+    v7 = malloc(v6);
     v8 = v5->uTextureSize;
     v5->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v7;
-    pContainer = (const char *)operator new(v8);
+    pContainer = (const char *)malloc(v8);
     fread((void *)pContainer, 1u, (size_t)pDst, File);
     zlib::MemUnzip(v5->pLevelOfDetail0_prolly_alpha_mask, &v5->uDecompressedSize, pContainer, v5->uTextureSize);
     v9 = (void *)pContainer;
@@ -2163,7 +2163,7 @@
   }
   else
   {
-    v10 = (unsigned __int8 *)operator new(0);
+    v10 = (unsigned __int8 *)malloc(0);
     v11 = File;
     v5->pLevelOfDetail0_prolly_alpha_mask = v10;
     fread(v10, 1u, (size_t)pDst, v11);
@@ -2171,7 +2171,7 @@
   v5->pPalette24 = 0;
   if ( uTextureType == 1 )
   {
-    v12 = operator new(0x300u);
+    v12 = malloc(0x300u);
     v13 = File;
     v5->pPalette24 = (unsigned __int8 *)v12;
     fread(v12, 1u, 0x300u, v13);
@@ -2183,7 +2183,7 @@
     goto LABEL_10;
   v18 = 0;
   v5->pPalette16 = 0;
-  v5->pPalette16 = (unsigned __int16 *)operator new(0x400u);
+  v5->pPalette16 = (unsigned __int16 *)malloc(0x400u);
   do
   {
     fread((char *)&pContainer + 3, 1u, 1u, File);
@@ -2343,7 +2343,7 @@
         else
         {
           v4 = strlen(v3 - 2);
-          v5 = (char *)operator new(v4 + 2);
+          v5 = (char *)malloc(v4 + 2);
           *v5 = 'h';
           strcpy(v5 + 1, v3 - 2);
           pRenderer->LoadTexture(
@@ -2610,7 +2610,7 @@
     else
     {
       v11 = strlen(pContainer);
-      v12 = (enum TEXTURE_TYPE)(int)operator new(v11 + 2);
+      v12 = (enum TEXTURE_TYPE)(int)malloc(v11 + 2);
       eTextureType = v12;
       *(char *)v12 = 104;
       strcpy((char *)(v12 + 1), pContainer);
--- a/LOD.h	Tue Sep 17 16:30:36 2013 +0600
+++ b/LOD.h	Tue Sep 17 16:30:43 2013 +0600
@@ -2,11 +2,16 @@
 #include <stdio.h>
 #include <memory.h>
 
+#include "Log.h"
 #include "Texture.h"
 #include "ErrorHandling.h"
 
 class Sprite;
 
+
+#define MAX_LOD_TEXTURES 1000
+#define MAX_LOD_SPRITES  1500
+
 /*  354 */
 enum TEXTURE_TYPE
 {
@@ -164,12 +169,23 @@
   void _inlined_sub1();
   void _inlined_sub2();
 
-  inline struct Texture *GetTexture(int idx)
+  inline int LoadDummyTexture()
   {
-    Assert(idx < 1000, "Texture index out of bounds (%u)", idx);
+    for (unsigned int i = 0; i < uNumLoadedFiles; ++i)
+      if (!strcmp(pTextures[i].pName, "pending"))
+        return i;
+    return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE);
+  }
+
+  inline Texture *GetTexture(int idx)
+  {
+    Assert(idx < MAX_LOD_TEXTURES, "Texture index out of bounds (%u)", idx);
     if (idx == -1) 
-      return nullptr; // we need to return dummy texture here
-    return &pTextures[idx];
+    {
+      //Log::Warning(L"Texture id = %d missing", idx);
+      return pTextures + LoadDummyTexture();
+    }
+    return pTextures + idx;
   }
 
 
@@ -187,7 +203,7 @@
   struct LOD::Directory *pSubIndices;
   unsigned int uOffsetToSubIndex;
   FILE *pOutputFileHandle;*/
-  struct Texture pTextures[1000];
+  Texture pTextures[MAX_LOD_TEXTURES];
   unsigned int uNumLoadedFiles;
   int dword_11B80;
   int dword_11B84;
@@ -278,7 +294,7 @@
   struct LOD::Directory *pSubIndices;
   unsigned int uOffsetToSubIndex;
   FILE *pOutputFileHandle;*/
-  struct LODSprite pSpriteHeaders[1500];
+  struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES];
   signed int uNumLoadedSprites;
   int field_ECA0;
   int field_ECA4;
--- a/Mouse.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/Mouse.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -414,7 +414,7 @@
       {
         if ( this->pCursorBitmap3_sysmembits_16bit )
           free(this->pCursorBitmap3_sysmembits_16bit);
-        this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)operator new(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
+        this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
         this->field_40 = a2;
         this->field_48 = a2 + pTextureWidth;
         this->field_44 = v6;
--- a/Outdoor.h	Tue Sep 17 16:30:36 2013 +0600
+++ b/Outdoor.h	Tue Sep 17 16:30:43 2013 +0600
@@ -101,7 +101,7 @@
   signed __int16 pXInterceptDisplacements[20];
   signed __int16 pYInterceptDisplacements[20];
   signed __int16 pZInterceptDisplacements[20];
-  unsigned __int16 uTextureID;
+  __int16 uTextureID;
   __int16 sTextureDeltaU;
   __int16 sTextureDeltaV;
   struct BBox_short_ pBoundingBox;
--- a/Render.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/Render.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -811,7 +811,7 @@
     v10 = strlen(lpDeviceDesc);
     a6->pInfo[v8].pDescription = new char[v10 + 1];
     strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc);
-    a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u);
+    a6->pInfo[v8].pGUID = new GUID;
     memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u);
     v11 = strlen(a6->ptr_4->pDriverName);
     a6->pInfo[v8].pDriverName = new char[v11 + 1];
@@ -3310,7 +3310,7 @@
     {
       pTargetSurface = 0;
       ptr_400E8 = 0;
-      v20 = (int *)operator new(0x96020u);
+      v20 = (int *)malloc(0x96020u);
       ptr_400E8 = v20;
       if ( !v20
         || (memset(&pDesc, 0, 0x7Cu),
@@ -3384,7 +3384,7 @@
   CreateZBuffer();
   if ( bUserDirect3D )
   {
-    /*v3 = operator new(0x148u);
+    /*v3 = malloc(0x148u);
     thisa = (RenderD3D *)v3;
     v29 = 0;
     if ( v3 )
--- a/Texture.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/Texture.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -335,7 +335,7 @@
 }
 
 //----- (0044E19A) --------------------------------------------------------
-unsigned int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3)
+int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3)
 {
   int v3; // esi@1
   TextureFrame *v4; // edi@1
--- a/Texture.h	Tue Sep 17 16:30:36 2013 +0600
+++ b/Texture.h	Tue Sep 17 16:30:43 2013 +0600
@@ -111,7 +111,7 @@
   void ToFile();
   void FromFile(void *data_mm6, void *data_mm7, void *data_mm8);
   void LoadAnimationSequenceAndPalettes(signed int uIconID);
-  unsigned int GetFrameTexture(int uFrameID, signed int a3);
+  int GetFrameTexture(int uFrameID, int time);
   unsigned int FindTextureByName(const char *Str2);
 
 
--- a/UI/UIMainMenu.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/UI/UIMainMenu.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -297,7 +297,7 @@
         pTexture2._allocation_flags = 0;
         pColor1 = TargetColor(0x70u, 0x8Fu, 0xFEu);
         pColor2 = TargetColor(0xECu, 0xE6u, 0x9Cu);
-        pString = (char *)operator new(2 * pSize);
+        pString = (char *)malloc(2 * pSize);
         strncpy(pString, ptr, pSize);
         pString[pSize]=0;
         pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a2.uFrameHeight, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, 
--- a/mm7_3.cpp	Tue Sep 17 16:30:36 2013 +0600
+++ b/mm7_3.cpp	Tue Sep 17 16:30:43 2013 +0600
@@ -4292,16 +4292,16 @@
   BSPModel *v2; // ebx@4
   int v3; // eax@6
   ODMFace *pFace; // esi@6
-  Vec3_int_ *v5; // ecx@8
+  //Vec3_int_ *v5; // ecx@8
   int v6; // eax@8
   struct Polygon *v7; // ebx@8
-  LightmapBuilder *v8; // eax@8
+  //LightmapBuilder *v8; // eax@8
   int v9; // ecx@8
-  char v10; // zf@8
+  //char v10; // zf@8
   Texture *pFaceTexture; // eax@10
   signed int v12; // ecx@10
-  unsigned int v13; // eax@14
-  unsigned int v14; // eax@18
+  //unsigned int v13; // eax@14
+  //unsigned int v14; // eax@18
   unsigned int v15; // eax@22
   unsigned int v16; // edi@22
   int v17; // eax@24
@@ -4338,7 +4338,7 @@
   float v45; // [sp+1Ch] [bp-3Ch]@10
   ODMFace *v46; // [sp+20h] [bp-38h]@6
   //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
-  unsigned int v48; // [sp+28h] [bp-30h]@8
+  //unsigned int v48; // [sp+28h] [bp-30h]@8
   int v49; // [sp+2Ch] [bp-2Ch]@10
   int v50; // [sp+30h] [bp-28h]@34
   int v51; // [sp+34h] [bp-24h]@35
@@ -4390,53 +4390,44 @@
       if (pFace->Invisible())
         goto LABEL_85;
       //v5 = (int)*(v2 - 1);
-	  v5 = v2->pVertices.pVertices;
       v6 = pFace->pVertexIDs[0];
       v53 = 0;
       v7 = &array_77EC08[pOutdoorCamera->uNumPolygons];
-	  //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8);
-      v8 = (LightmapBuilder *)v5[v6].z;
       v7->flags = 0;
       v7->field_32 = 0;
-      pLightmapBuilder = v8;
+      pLightmapBuilder = (LightmapBuilder *)v2->pVertices.pVertices[v6].z;
       v9 = pFace->uTextureID;
-      v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
-      v48 = pFace->uTextureID;
-      if ( !v10 )
+      if (pFace->uAttributes & FACE_TEXTURE_FRAME)
       {
-        v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
-        v9 = v48;
+        v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
       }
       pFaceTexture = pBitmaps_LOD->GetTexture(v9);
       v7->pTexture = pFaceTexture;
       v12 = pFaceTexture->uTextureWidth;
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
-      v10 = (pFace->uAttributes & 0x10) == 0;
       v45 = 1.0 / (double)v12;
       v44 = 1.0 / (double)v49;
-      if ( !v10 )
+      if (pFace->uAttributes & FACE_FLUID)
         *(int *)&v7->flags |= 2u;
-      if ( BYTE2(pFace->uAttributes) & 0x40 )
+      if (pFace->uAttributes & FACE_DO_NOT_LIGHT )
         HIBYTE(v7->flags) |= 4u;
-      v13 = pFace->uAttributes;
-      if ( v13 & 4 )
+      if ( pFace->uAttributes & 4 )
       {
         HIBYTE(v7->flags) |= 4u;
       }
       else
       {
-        if ( v13 & 0x20 )
+        if ( pFace->uAttributes & 0x20 )
           HIBYTE(v7->flags) |= 8u;
       }
-      v14 = pFace->uAttributes;
-      if ( BYTE1(v14) & 8 )
+      if (pFace->uAttributes & 0x0800)
       {
         *(int *)&v7->flags |= 0x2000u;
       }
       else
       {
-        if ( v14 & 0x40 )
+        if (pFace->uAttributes & FACE_DONT_CACHE_TEXTURE)
           HIBYTE(v7->flags) |= 0x10u;
       }
       v15 = GetTickCount();
@@ -4520,12 +4511,11 @@
           ++v20;
 		  ++v20b;
 		  ++v20c;
-          v10 = v51-- == 1;
           v52 = v22;
           //*((float *)v19 - 4) = (double)v22 * v44;
 		  (v19-1)->v = (double)v22 * v44;
         }
-        while ( !v10 );
+        while ( !(v51-- == 1) );
         //v23 = (char *)&array_73D150[0].vWorldViewPosition;
 		v23 = array_73D150;
         v51 = uNumVertices;
@@ -4671,7 +4661,7 @@
           }
           else
           {
-            v40 = (int)pBitmaps_LOD->pHardwareTextures[v48];
+            v40 = (int)pBitmaps_LOD->pHardwareTextures[v9];
           }
           pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40);
         }