diff Texture.cpp @ 1583:75fafd8ced59

Allocator (CMemory) bye-bye
author Nomad
date Tue, 10 Sep 2013 21:07:07 +0200
parents c4ab816fcc5e
children 69ab7593e7af
line wrap: on
line diff
--- a/Texture.cpp	Tue Sep 10 18:43:52 2013 +0200
+++ b/Texture.cpp	Tue Sep 10 21:07:07 2013 +0200
@@ -6,7 +6,6 @@
 
 #include "Texture.h"
 #include "FrameTableInc.h"
-#include "Allocator.h"
 #include "LOD.h"
 #include "PaletteManager.h"
 #include "Render.h"
@@ -274,7 +273,7 @@
   Assert(sNumTextures);
   Assert(!num_mm8_frames);
 
-  pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, sNumTextures * sizeof(TextureFrame), "Txt Frames");
+  pTextures = (TextureFrame *)malloc(sNumTextures * sizeof(TextureFrame));
 
   memcpy(pTextures,                                   (char *)data_mm7 + 4, num_mm7_frames * sizeof(TextureFrame));
   memcpy(pTextures + num_mm7_frames,                  (char *)data_mm6 + 4, num_mm6_frames * sizeof(TextureFrame));
@@ -402,9 +401,9 @@
 		__debugbreak();
 	}
 	
-	  pAllocator->FreeChunk(pLevelOfDetail0_prolly_alpha_mask);
-      pAllocator->FreeChunk(pPalette16);
-      pAllocator->FreeChunk(pPalette24);
+	  free(pLevelOfDetail0_prolly_alpha_mask);
+      free(pPalette16);
+      free(pPalette24);
     
 
     pLevelOfDetail0_prolly_alpha_mask = nullptr;
@@ -460,11 +459,11 @@
   if ( DstBuf.uDecompressedSize )
   {
     v5 = malloc(DstBuf.uDecompressedSize);
-    uSourceLena = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName);
+    uSourceLena = malloc(DstBuf.uTextureSize);
     fread(uSourceLena, 1u, Count, File);
     zlib::MemUnzip(v5, &DstBuf.uDecompressedSize, uSourceLena, DstBuf.uTextureSize);
     DstBuf.uTextureSize = DstBuf.uDecompressedSize;
-    pAllocator->FreeChunk(uSourceLena);
+    free(uSourceLena);
   }
   else
   {
@@ -548,11 +547,11 @@
   if ( DstBuf.uDecompressedSize )
   {
     Str1a = (char *)malloc(DstBuf.uDecompressedSize);
-    v6 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName);
+    v6 = malloc(DstBuf.uTextureSize);
     fread(v6, 1u, Count, File);
     zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize);
     DstBuf.uTextureSize = DstBuf.uDecompressedSize;
-    pAllocator->FreeChunk(v6);
+    free(v6);
   }
   else
   {
@@ -575,18 +574,18 @@
   {
     if ( mode )
       goto LABEL_14;
-    pAllocator->FreeChunk(v10);
+    free(v10);
   }
   if ( !mode )
   {
-    v11 = pAllocator->AllocNamedChunk(v3->pPixels, 2 * v3->uNumPixels + 4, "16bit PCX");
+    v11 = malloc(2 * v3->uNumPixels + 4);
     goto LABEL_16;
   }
 LABEL_14:
   if ( mode != 2 )
     goto LABEL_17;
   v11 = malloc(2 * v3->uNumPixels + 4);
-  *(unsigned int *)&v3->field_20 |= 1u;
+  v3->_allocation_flags |= 1u;
 LABEL_16:
   v3->pPixels = (unsigned __int16 *)v11;
 LABEL_17:
@@ -1147,20 +1146,17 @@
       {
         if ( pPixels )
         {
-          pAllocator->FreeChunk(pPixels);
+          free(pPixels);
           pPixels = 0;
         }
-        pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
-                                            pPixels,
-                                            2 * uNumPixels + 4,
-                                            pName);
+        pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4);
       }
       else
       {
         if ( mode != 1 && mode == 2 )
         {
           pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16));
-          field_20 |= 1;
+          _allocation_flags |= 1;
         }
       }
 
@@ -1310,14 +1306,14 @@
   void *v3; // [sp-4h] [bp-Ch]@1
 
   v1 = this;
-  v2 = (this->field_20 & 1) == 0;
+  v2 = (this->_allocation_flags & 1) == 0;
   v3 = this->pPixels;
   this->pName[0] = 0;
   if ( v2 )
-    pAllocator->FreeChunk(v3);
+    free(v3);
   else
     free(v3);
-  *(unsigned int *)&v1->field_20 = 0;
+  v1->_allocation_flags = 0;
   v1->pPixels = 0;
   v1->uNumPixels = 0;
   v1->uHeight = 0;
@@ -1394,14 +1390,14 @@
   if ( v12 )
   {
     if ( v3->pPixels )
-      pAllocator->FreeChunk(v3->pPixels);
-    v13 = pAllocator->AllocNamedChunk(v3->pPixels, 2 * v3->uNumPixels + 4, v3->pName);
+      free(v3->pPixels);
+    v13 = malloc(2 * v3->uNumPixels + 4);
     goto LABEL_16;
   }
   if ( a3 != 1 && a3 == 2 )
   {
-    v13 = operator new(4 * v11 + 8);
-    *(unsigned int *)&v3->field_20 |= 1u;
+    v13 = malloc(4 * v11 + 8);
+    v3->_allocation_flags |= 1u;
 LABEL_16:
     v3->pPixels = (unsigned __int16 *)v13;
   }
@@ -1641,8 +1637,7 @@
   uWidth = 0;
   field_1A = 0;
   field_18 = 0;
-  field_20 = 0;
-  field_22 = 0;
+  _allocation_flags = 0;
 }
 //----- (0044E1EC) --------------------------------------------------------
 int TextureFrameTable::FromFileTxt(const char *Args)
@@ -1702,7 +1697,7 @@
   }
   v5 = v2->pTextures;
   v2->sNumTextures = v4;
-  v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames");
+  v6 = malloc(20 * v4);
   v2->pTextures = (TextureFrame *)v6;
   if ( !v6 )
     Error("CTextureFrameTable::load - Out of Memory!");