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 :
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.
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.
About the author
Associate James Urquhart
In interiorRender.cpp :
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. :