Author Topic: CODERS ONLY: Code question  (Read 1480 times)

0 Members and 1 Guest are viewing this topic.

Offline RandomTiger

  • Senior Member
  • 211
CODERS ONLY: Code question
Really need some insight on this people.

Whats all this about then?
Im investigating the z-buffer problem and ran into this

Code: [Select]

float z_mult = 30000.0f;
DCF(zmult, "")
{
dc_get_arg(ARG_FLOAT);
[b]z_mult = Dc_arg_float[/b];
}


z_mult is the variable that determines the depth of each vertex.

Code: [Select]

#define DCF(function_name,help_text) \
void dcf_##function_name(); \
debug_command dc_##function_name(#function_name,help_text,dcf_##function_name); \
void dcf_##function_name()



And what the hell is all this about?

Code: [Select]

void dc_get_arg(uint type)
{
scanner_get_token();

Dc_command_line = scanner_bufferp;
Dc_arg_org = scanner_token_string;
Dc_arg = scanner_word_string;

if (Dc_debug_on) {
dc_printf( "next arg is '%s', was originally '%s'\n", Dc_arg, Dc_arg_org );
dc_printf( "Rest of the command line is '%s'\n", Dc_command_line );
}

if ( scanner_token == NO_TOKEN ) {
Dc_arg_type = ARG_NONE;
} else if ( scanner_token == IDENTIFIER ) {
Dc_arg_type = ARG_STRING;
} else if ( scanner_token == STRING ) {
Dc_arg_type = ARG_QUOTE;
} else {
Dc_arg_type = ARG_STRING;
}

if ( Dc_arg_type & ARG_STRING ) {
int i, num_digits, len;

len = strlen(Dc_arg);
num_digits = 0;

for (i=0; i if ( scanner_char_table[Dc_arg[i]] == DIGIT ) num_digits++;

if ( num_digits==len ) {
Dc_arg_type |= ARG_FLOAT;
[b]Dc_arg_float = (float)atof(Dc_arg);[/b]
if ( !strchr( Dc_arg, '.' )) {
Dc_arg_type |= ARG_INT;
Dc_arg_int = atoi(Dc_arg);
}
} else {
if ( (Dc_arg[0] == '0') && (Dc_arg[1] == 'x') ) {
char *p;
int n;
n = strtol(Dc_arg,&p,0);
if ( *p == 0 ) {
Dc_arg_type |= ARG_INT|ARG_HEX;
Dc_arg_int = n;
}
}
}

if (Dc_debug_on) {
if ( Dc_arg_type & ARG_FLOAT )
dc_printf( "Found float number! %f\n", Dc_arg_float );

if ( Dc_arg_type & ARG_INT )
dc_printf( "Found int number! %d\n", Dc_arg_int );

if ( Dc_arg_type & ARG_HEX )
dc_printf( "Found hex number! 0x%x\n", Dc_arg_int );
}

if ( !stricmp( Dc_arg, "on" ))
Dc_arg_type |= ARG_TRUE;
if ( !stricmp( Dc_arg, "true" ))
Dc_arg_type |= ARG_TRUE;
if ( !stricmp( Dc_arg, "off" ))
Dc_arg_type |= ARG_FALSE;
if ( !stricmp( Dc_arg, "false" ))
Dc_arg_type |= ARG_FALSE;

if ( !stricmp( Dc_arg, "+" ))
Dc_arg_type |= ARG_PLUS;

if ( !stricmp( Dc_arg, "-" ))
Dc_arg_type |= ARG_MINUS;

if ( !stricmp( Dc_arg, "," ))
Dc_arg_type |= ARG_COMMA;
}

if ( Dc_arg_type & ARG_INT) {
if ( Dc_arg_int )
Dc_arg_type |= ARG_TRUE;
else
Dc_arg_type |= ARG_FALSE;
}

if ( !(Dc_arg_type&type) ) {
if ( (Dc_arg_type & ARG_NONE) && !(type & ARG_NONE))
dc_printf( "Error: Not enough parameters.\n" );
else
dc_printf( "Error: '%s' invalid type\n", Dc_arg );
longjmp(dc_bad_arg,1);
}

}
« Last Edit: October 06, 2002, 11:10:52 am by 848 »

  

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
CODERS ONLY: Code question
well first
;

void dc_get_arg(uint flags);      // Gets the next argument.   If it doesn't match the flags, this function will print an error and not return.

I think this for the debug console, a square box that outputs debug messages.

something you can view when you run the debug version of fs2 in a window, or ALT + tab to if you are running fullscreen or glide.

why it isnt boxed by #ifdefs I dont know.

maybe it has something to do with the commandline paramerter -pofspew.

this shouldnt be of concern. as it is simply returning usefull information to the debug console.

but that is what it looks like to me, and ofcourse, i' m no professional.

i think all those dc are short for DEBUG CONSOLE
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.