MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / GetVariable

Method GetVariable

neo/d3xp/script/Script_Program.cpp:1080–1116  ·  view source on GitHub ↗

============ idScriptObject::GetVariable ============ */

Source from the content-addressed store, hash-verified

1078============
1079*/
1080byte *idScriptObject::GetVariable( const char *name, etype_t etype ) const {
1081 int i;
1082 int pos;
1083 const idTypeDef *t;
1084 const idTypeDef *parm;
1085
1086 if ( type == &type_object ) {
1087 return NULL;
1088 }
1089
1090 t = type;
1091 do {
1092 if ( t->SuperClass() != &type_object ) {
1093 pos = t->SuperClass()->Size();
1094 } else {
1095 pos = 0;
1096 }
1097 for( i = 0; i < t->NumParameters(); i++ ) {
1098 parm = t->GetParmType( i );
1099 if ( !strcmp( t->GetParmName( i ), name ) ) {
1100 if ( etype != parm->FieldType()->Type() ) {
1101 return NULL;
1102 }
1103 return &data[ pos ];
1104 }
1105
1106 if ( parm->FieldType()->Inherits( &type_object ) ) {
1107 pos += type_object.Size();
1108 } else {
1109 pos += parm->FieldType()->Size();
1110 }
1111 }
1112 t = t->SuperClass();
1113 } while( t && ( t != &type_object ) );
1114
1115 return NULL;
1116}
1117
1118/***********************************************************************
1119

Callers 1

LinkToMethod · 0.45

Calls 8

SuperClassMethod · 0.45
SizeMethod · 0.45
NumParametersMethod · 0.45
GetParmTypeMethod · 0.45
GetParmNameMethod · 0.45
TypeMethod · 0.45
FieldTypeMethod · 0.45
InheritsMethod · 0.45

Tested by

no test coverage detected