void Q3_DeclareVariable( int type, const char *name ) { //Cannot declare the same variable twice if ( Q3_VariableDeclared( name ) != VTYPE_NONE ) return; if ( numVariables > MAX_VARIABLES ) { Q3_DebugPrint( WL_ERROR, "too many variables already declared, maximum is %d\n", MAX_VARIABLES ); return; } switch( type ) { case TK_FLOAT: varFloats[ name ] = 0.0f; break; case TK_STRING: varStrings[ name ] = "NULL"; break; case TK_VECTOR: varVectors[ name ] = "0.0 0.0 0.0"; break; default: Q3_DebugPrint( WL_ERROR, "unknown 'type' for declare() function!\n" ); return; break; } numVariables++; }
/* ============ Q3_SetVar Description : Return type : static void Argument : int taskID Argument : int entID Argument : const char *type_name Argument : const char *data ============ */ void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data ) { int vret = Q3_VariableDeclared( type_name ) ; float float_data; float val = 0.0f; if ( vret != VTYPE_NONE ) { switch ( vret ) { case VTYPE_FLOAT: //Check to see if increment command if ( (val = Q3_CheckStringCounterIncrement( data )) ) { Q3_GetFloatVariable( type_name, &float_data ); float_data += val; } else { float_data = atof((char *) data); } Q3_SetFloatVariable( type_name, float_data ); break; case VTYPE_STRING: Q3_SetStringVariable( type_name, data ); break; case VTYPE_VECTOR: Q3_SetVectorVariable( type_name, (char *) data ); break; } return; } Q3_DebugPrint( WL_ERROR, "%s variable or field not found!\n", type_name ); }