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

Function getVariableObjectField

Engine/source/console/console.cpp:773–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

771//---------------------------------------------------------------------------
772
773bool getVariableObjectField(const char *name, SimObject **object, const char **field)
774{
775 // get the field info from the object..
776 const char *dot = dStrchr(name, '.');
777 if(name[0] != '$' && dot)
778 {
779 S32 len = dStrlen(name);
780 AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - name too long");
781 dMemcpy(scratchBuffer, name, len+1);
782
783 char * token = dStrtok(scratchBuffer, ".");
784 SimObject * obj = Sim::findObject(token);
785 if(!obj)
786 return false;
787
788 token = dStrtok(0, ".\0");
789 if(!token)
790 return false;
791
792 while(token != NULL)
793 {
794 const char * val = obj->getDataField(StringTable->insert(token), 0);
795 if(!val)
796 return false;
797
798 char *fieldToken = token;
799 token = dStrtok(0, ".\0");
800 if(token)
801 {
802 obj = Sim::findObject(token);
803 if(!obj)
804 return false;
805 }
806 else
807 {
808 *object = obj;
809 *field = fieldToken;
810 return true;
811 }
812 }
813 }
814
815 return false;
816}
817
818Dictionary::Entry *getLocalVariableEntry(const char *name)
819{

Callers 4

setVariableFunction · 0.85
setBoolVariableFunction · 0.85
setIntVariableFunction · 0.85
setFloatVariableFunction · 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