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

Method setDataField

Engine/source/console/simObject.cpp:904–975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902//-----------------------------------------------------------------------------
903
904void SimObject::setDataField(StringTableEntry slotName, const char *array, const char *value)
905{
906 // first search the static fields if enabled
907 if(mFlags.test(ModStaticFields))
908 {
909 const AbstractClassRep::Field *fld = findField(slotName);
910 if(fld)
911 {
912 // Skip the special field types as they are not data.
913 if ( fld->type >= AbstractClassRep::ARCFirstCustomField )
914 return;
915
916 S32 array1 = array ? dAtoi(array) : 0;
917
918 if(array1 >= 0 && array1 < fld->elementCount && fld->elementCount >= 1)
919 {
920 // If the set data notify callback returns true, then go ahead and
921 // set the data, otherwise, assume the set notify callback has either
922 // already set the data, or has deemed that the data should not
923 // be set at all.
924 FrameTemp<char> buffer(2048);
925 FrameTemp<char> bufferSecure(2048); // This buffer is used to make a copy of the data
926 // so that if the prep functions or any other functions use the string stack, the data
927 // is not corrupted.
928
929 ConsoleBaseType *cbt = ConsoleBaseType::getType( fld->type );
930 AssertFatal( cbt != NULL, "Could not resolve Type Id." );
931
932 const char* szBuffer = cbt->prepData( value, buffer, 2048 );
933 dMemset( bufferSecure, 0, 2048 );
934 dMemcpy( bufferSecure, szBuffer, dStrlen( szBuffer ) );
935
936 if( (*fld->setDataFn)( this, array, bufferSecure ) )
937 Con::setData(fld->type, (void *) (((const char *)this) + fld->offset), array1, 1, &value, fld->table);
938
939 if(fld->validator)
940 fld->validator->validateType(this, (void *) (((const char *)this) + fld->offset));
941
942 onStaticModified( slotName, value );
943
944 return;
945 }
946
947 if(fld->validator)
948 fld->validator->validateType(this, (void *) (((const char *)this) + fld->offset));
949
950 onStaticModified( slotName, value );
951 return;
952 }
953 }
954
955 if(mFlags.test(ModDynamicFields))
956 {
957 if(!mFieldDictionary)
958 mFieldDictionary = new SimFieldDictionary;
959
960 if(!array)
961 {

Callers 14

simObject.cppFile · 0.45
setFieldComponentFunction · 0.45
execMethod · 0.45
pasteFieldsMethod · 0.45
setVariableFunction · 0.45
setBoolVariableFunction · 0.45
setIntVariableFunction · 0.45
setFloatVariableFunction · 0.45
SimObject_SetDataFieldFunction · 0.45

Calls 13

getTypeFunction · 0.85
setDataFunction · 0.85
dStrcpyFunction · 0.85
dStrcatFunction · 0.85
prepDataMethod · 0.80
validateTypeMethod · 0.80
dAtoiFunction · 0.70
dMemsetFunction · 0.50
dMemcpyFunction · 0.50
dStrlenFunction · 0.50
testMethod · 0.45
setFieldValueMethod · 0.45

Tested by

no test coverage detected