Game Development Community

Silly Typo in interior code

by James Urquhart · in Torque Game Engine · 12/02/2004 (1:53 pm) · 1 replies

Hi there,

I was recently manually applying the Pathed Interior resource code to my copy of torque, when i came across these 3, rather strange lines of code :

sgActivePolyList  = (U16*)FrameAllocator::alloc(mSurfaces.size() * sizeof(16));
   sgEnvironPolyList = (U16*)FrameAllocator::alloc(mSurfaces.size() * sizeof(16));
   sgFogPolyList     = (U16*)FrameAllocator::alloc(mSurfaces.size() * sizeof(16));

I'd dread to think what "sizeof(16)" could be. Likely its really meant to be "sizeof(U16)", but someone was too dozy and forgot to put the "U" on.

Whilst this compiles, we will likely get a bigger size than the intended "U16" type, depending on the compiler. This will potentially waste memory, especially when the interior has a large amount of polygons. (e.g. if "16" is an int, it'll be 4*size bytes long instead of 2*size bytes).

If i come across any other oddities, i will post them back here.

#1
12/03/2004 (6:28 am)
Now for the next thing...
In interiorRender.cpp :

//!!!!!!!TBD -- there should be a platform fn called memMove!
#include <string.h>
Evidently this was indeed discussed, as there is a "dMemcpy" function which will do the equivalent "memMove" function.

However, someone seems to have forgotten to remove that warning, aswell as modify the various calls to "memcpy", e.g. :
memcpy(texGen0,  &mTexGenEQs[rSurface.texGenIndex], sizeof(F32)*8);