Game Development Community

1.7.1 - Engine won't compile with out disabling TMM

by Jeremiah Fulbright · in Torque Game Engine Advanced · 06/22/2008 (4:01 pm) · 1 replies

I saw somewhere that somebody had asked about whether TGEA was going to always disable the Torque Memory Manager (TMM), and the response was that it is only enabled in "Shipping" Versions.

With 1.7.1, trying to use TMM fails in a few places, so it has to be disabled.

#1
07/02/2008 (1:16 pm)
Yep, confirmed. And it was my changes that broke it :(

Here's the fix:

Index: engine/source/platform/platform.h
===================================================================
--- engine/source/platform/platform.h
+++ engine/source/platform/platform.h
@@ -561,9 +561,29 @@
 {
    return new(p) T;
 }
+template< class T, typename A >
+inline T* constructInPlace( T* p, A a )
+{
+   return new ( p ) T( a );
+}
+template< class T, typename A, typename B >
+inline T* constructInPlace( T* p, A a, B b )
+{
+   return new ( p ) T( a, b );
+}
+template< class T, typename A, typename B, typename C >
+inline T* constructInPlace( T* p, A a, B b, C c )
+{
+   return new ( p ) T( a, b, c );
+}
+template< class T, typename A, typename B, typename C, typename D >
+inline T* constructInPlace( T* p, A a, B b, C c, D d )
+{
+   return new ( p ) T( a, b, c, d );
+}
 
 template <class T>
-inline T* constructInPlace(T* p, const T* copy)
+inline T* constructCopyInPlace(T* p, const T* copy)
 {
    return new(p) T(*copy);
 }
@@ -582,7 +602,6 @@
    #define new new(__FILE__, __LINE__)
 #endif
 
-#define placenew(x) new(x)
 #define dMalloc(x) dMalloc_r(x, __FILE__, __LINE__)
 #define dRealloc(x, y) dRealloc_r(x, y, __FILE__, __LINE__)


Index: engine/source/atlas/resource/atlasTexChunk.cpp
===================================================================
--- engine/source/atlas/resource/atlasTexChunk.cpp
+++ engine/source/atlas/resource/atlasTexChunk.cpp
@@ -244,7 +244,7 @@
                bitmap[layer].swizzle(GFX->getDeviceSwizzle24());
          }
 
-         constructInPlace< GBitmap >( &atc->bitmap[layer], &bitmap[ layer ] );
+         constructCopyInPlace< GBitmap >( &atc->bitmap[layer], &bitmap[ layer ] );
       }
    }

Index: engine/source/atlas/editor/atlasImportLargeImage.cpp
===================================================================
--- engine/source/atlas/editor/atlasImportLargeImage.cpp
+++ engine/source/atlas/editor/atlasImportLargeImage.cpp
@@ -281,10 +281,10 @@
          atc->mFormat = AtlasTexChunk::FormatPNG;
 
          // Copy from the JPEG working space to the bitmap.
-		 atc->bitmap = new GBitmap[ 1 ];
-		 atc->layerCount = 1;
+		   atc->bitmap = new GBitmap[ 1 ];
+		   atc->layerCount = 1;
          GBitmap *gb = &atc->bitmap[ 0 ];
-		 new ( gb ) GBitmap( tileSize, tileSize );
+         constructInPlace< GBitmap >( gb, tileSize, tileSize );
          for(S32 k=0; k<tileSize; k++)
             dMemcpy(gb->getAddress(0, k), rows[k] + j*tileSize*3, 3*tileSize);

Index: engine/source/core/tVector.h
===================================================================
--- engine/source/core/tVector.h
+++ engine/source/core/tVector.h
@@ -255,7 +255,7 @@
    AssertFatal(start <= mElementCount && end <= mElementCount, "Vector<T>::construct - out of bounds start/end.");
    while(start < end)
    {
-      constructInPlace(&mArray[start], &array[start]);
+      constructCopyInPlace(&mArray[start], &array[start]);
       start++;
    }
 }

Index: engine/source/gfx/D3D9/gfxD3D9EffectMgr.h
===================================================================
--- engine/source/gfx/D3D9/gfxD3D9EffectMgr.h
+++ engine/source/gfx/D3D9/gfxD3D9EffectMgr.h
@@ -5,8 +5,8 @@
 #ifndef _GFXD3D9EFFECTMGR_H_
 #define _GFXD3D9EFFECTMGR_H_
 
+#include "gfx/D3D9/gfxD3D9Effect.h"
 #include "gfx/gfxEffectMgr.h"
-#include "gfx/D3D9/gfxD3D9Effect.h"
 
 //**************************************************************************
 // Effect Manager