MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getObjectTokenField

Function getObjectTokenField

Engine/source/console/console.cpp:976–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

974
975//
976const char *getObjectTokenField(const char *name)
977{
978 const char *dot = dStrchr(name, '.');
979 if(name[0] != '$' && dot)
980 {
981 S32 len = dStrlen(name);
982 AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - object name too long");
983 dMemcpy(scratchBuffer, name, len+1);
984
985 char * token = dStrtok(scratchBuffer, ".");
986 SimObject * obj = Sim::findObject(token);
987 if(!obj)
988 return("");
989
990 token = dStrtok(0, ".\0");
991 if(!token)
992 return("");
993
994 while(token != NULL)
995 {
996 const char * val = obj->getDataField(StringTable->insert(token), 0);
997 if(!val)
998 return("");
999
1000 token = dStrtok(0, ".\0");
1001 if(token)
1002 {
1003 obj = Sim::findObject(token);
1004 if(!obj)
1005 return("");
1006 }
1007 else
1008 return(val);
1009 }
1010 }
1011
1012 return NULL;
1013}
1014
1015const char *getVariable(const char *name, const char* def)
1016{

Callers 4

getVariableFunction · 0.85
getBoolVariableFunction · 0.85
getIntVariableFunction · 0.85
getFloatVariableFunction · 0.85

Calls 7

dStrtokFunction · 0.85
getDataFieldMethod · 0.80
findObjectFunction · 0.70
dStrchrFunction · 0.50
dStrlenFunction · 0.50
dMemcpyFunction · 0.50
insertMethod · 0.45

Tested by

no test coverage detected