Game Development Community

Strange Core Code

by Michael Woerister · in Torque Game Builder · 01/05/2006 (3:12 am) · 2 replies

This seems like a kind of bug here:

static const char *getDataTypeSimObjectPtr(void *dptr, EnumTable *, BitSet32)
{
   SimObject **obj = (SimObject**)dptr;
   char* returnBuffer = Con::getReturnBuffer(256);
   dSprintf(returnBuffer, 256, "%s", *obj ? (*obj)->getName() : "");
   return returnBuffer;
}

The function as it is restricts TypeSimObjectPtr-fields just to objects with a name. However, most objects don't have a name while every objects must have a ID. I can't imagine that this restriction is intended or of any use. I've change the function to

static const char *getDataTypeSimObjectPtr(void *dptr, EnumTable *, BitSet32)
{
   SimObject **obj = (SimObject**)dptr;
   char* returnBuffer = Con::getReturnBuffer(32);
   dSprintf(returnBuffer, 32, "%u", *obj ? (*obj)->getId() : 0);
   return returnBuffer;
}

Maybe I'm too late and this is already fixed in TGE 1.4, but for people like me who wondered why TypeSimObjectPtr-fields don't work properly, this is the reason.

- Michael

#1
01/05/2006 (9:44 am)
Michael,

Thanks for this great find. This has not been changed in 1.4 even with the new DynamicTypes system I created, I must have missed it. I'll forward this fix on to the proper people to get it in the next 1.4 release.

Best Regards,
-Justin
#2
01/05/2006 (11:40 am)
No problem. DynamicTypes sounds great!