13 int text_console_enabled = 1;
14 cvar_t *cvar_vars = NULL;
16 /* Console specific cvars */
17 /* How discriminating we are about which messages are displayed */
18 cvar_t con_threshold = {"con_threshold", "0",};
20 /* Private console stuff */
21 #define CON_NUM_LINES 40
22 #define CON_LINE_LEN 40
23 static char con_display[40][40];
24 static int con_line; /* Current display line */
27 * con_init - Initialise the console.
32 /* Make sure the output is unbuffered */
33 if (text_console_enabled) {
34 setbuf (stdout, NULL);
35 setbuf (stderr, NULL);
38 memset(con_display, ' ', sizeof(con_display));
41 /* Initialise the cvars */
42 cvar_registervariable (&con_threshold);
47 * con_printf - Print a message to the console.
50 void con_printf(int priority, char *fmt, ...)
55 if (priority <= ((int)con_threshold.value))
57 va_start (arglist, fmt);
58 vsnprintf (buffer, 2048, fmt, arglist);
59 if (text_console_enabled) vprintf(fmt, arglist);
62 /* for (i=0; i<l; i+=CON_LINE_LEN,con_line++)
64 memcpy(con_display, &buffer[i], min(80, l-i));
70 * con_update - Check for new console input. If it's there, use it.
75 // char buffer[CMD_MAX_LENGTH], *t;
77 /* Check for new input */
78 /* t = fgets(buffer, sizeof(buffer), stdin);
79 if (t == NULL) return;
86 * cvar_registervariable - Register a CVar
89 void cvar_registervariable (cvar_t *cvar)
96 cvar->value = strtod(cvar->string, (char **) NULL);
98 if (cvar_vars == NULL)
103 for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ;
109 * cvar_set - Set a CVar's value
112 void cvar_set (char *cvar_name, char *value)
116 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
117 if (!strcmp(cvar_name, ptr->name)) break;
119 if (ptr == NULL) return; // If we didn't find the cvar, give up
121 ptr->value = strtod(value, (char **) NULL);
125 * cvar() - Get a CVar's value
128 float cvar (char *cvar_name)
132 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
133 if (!strcmp(cvar_name, ptr->name)) break;
135 if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up
141 /* ==========================================================================
143 * ==========================================================================
147 /* char buffer[CON_LINE_LEN+1];
149 /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++)
151 memcpy(buffer, con_display[i], CON_LINE_LEN);
152 buffer[CON_LINE_LEN] = 0;
153 gr_string(1,j*10,buffer);