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

Function getVariableObjectField

Engine/source/console/console.cpp:715–758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713//---------------------------------------------------------------------------
714
715bool getVariableObjectField(const char *name, SimObject **object, const char **field)
716{
717 // get the field info from the object..
718 const char *dot = dStrchr(name, '.');
719 if(name[0] != '$' && dot)
720 {
721 S32 len = dStrlen(name);
722 AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - name too long");
723 dMemcpy(scratchBuffer, name, len+1);
724
725 char * token = dStrtok(scratchBuffer, ".");
726 SimObject * obj = Sim::findObject(token);
727 if(!obj)
728 return false;
729
730 token = dStrtok(0, ".\0");
731 if(!token)
732 return false;
733
734 while(token != NULL)
735 {
736 const char * val = obj->getDataField(StringTable->insert(token), 0);
737 if(!val)
738 return false;
739
740 char *fieldToken = token;
741 token = dStrtok(0, ".\0");
742 if(token)
743 {
744 obj = Sim::findObject(token);
745 if(!obj)
746 return false;
747 }
748 else
749 {
750 *object = obj;
751 *field = fieldToken;
752 return true;
753 }
754 }
755 }
756
757 return false;
758}
759
760Dictionary::Entry *getLocalVariableEntry(const char *name)
761{

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