X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=console.c;h=b99f7c4b02b0f8a6dde2dba2959d7d873ec668fe;hp=72dfd9e0a64aca901375ba0f155a3da55a6cb307;hb=d48093d3ac481d32bd6eabd6c36e3a026779ecde;hpb=d970e242407f5e89111f6fd90911f5b60aec52b0 diff --git a/console.c b/console.c index 72dfd9e0..b99f7c4b 100644 --- a/console.c +++ b/console.c @@ -39,7 +39,7 @@ int con_backscroll; int con_current; // offset in current line for next print int con_x; -char *con_text = 0; +char con_text[CON_TEXTSIZE]; //seconds cvar_t con_notifytime = {CVAR_SAVE, "con_notifytime","3"}; @@ -51,17 +51,8 @@ float con_times[MAX_NOTIFYLINES]; int con_vislines; -#define MAXCMDLINE 256 -extern char key_lines[32][MAXCMDLINE]; -extern int edit_line; -extern int key_linepos; -extern int key_insert; - - qboolean con_initialized; -mempool_t *console_mempool; - /* ============================================================================== @@ -107,27 +98,6 @@ const char* Log_Timestamp (const char *desc) } -/* -==================== -Log_Init -==================== -*/ -void Log_Init (void) -{ - // Allocate a log queue - logq_size = 512; - logqueue = Mem_Alloc (tempmempool, logq_size); - logq_ind = 0; - - Cvar_RegisterVariable (&log_file); - - // support for the classic Quake option -// COMMANDLINEOPTION: Console: -condebug logs console messages to qconsole.log, see also log_file - if (COM_CheckParm ("-condebug") != 0) - Cvar_SetQuick (&log_file, "qconsole.log"); -} - - /* ==================== Log_Open @@ -138,7 +108,7 @@ void Log_Open (void) if (logfile != NULL || log_file.string[0] == '\0') return; - logfile = FS_Open (log_file.string, "ab", false); + logfile = FS_Open (log_file.string, "ab", false, false); if (logfile != NULL) { strlcpy (crt_log_file, log_file.string, sizeof (crt_log_file)); @@ -212,7 +182,7 @@ void Log_ConPrint (const char *msg) // If we need to enlarge the log queue if (len > remain) { - unsigned int factor = ((logq_ind + len) / logq_size) + 1; + size_t factor = ((logq_ind + len) / logq_size) + 1; qbyte* newqueue; logq_size *= factor; @@ -252,7 +222,7 @@ void Log_Printf (const char *logfilename, const char *fmt, ...) { qfile_t *file; - file = FS_Open (logfilename, "ab", true); + file = FS_Open (logfilename, "ab", true, false); if (file != NULL) { va_list argptr; @@ -348,50 +318,40 @@ void Con_CheckResize (void) int i, j, width, oldwidth, oldtotallines, numlines, numchars; char tbuf[CON_TEXTSIZE]; - width = (vid.conwidth >> 3); + width = (vid_conwidth.integer >> 3); if (width == con_linewidth) return; - if (width < 1) // video hasn't been initialized yet - { - width = 80; - con_linewidth = width; - con_totallines = CON_TEXTSIZE / con_linewidth; - memset (con_text, ' ', CON_TEXTSIZE); - } - else - { - oldwidth = con_linewidth; - con_linewidth = width; - oldtotallines = con_totallines; - con_totallines = CON_TEXTSIZE / con_linewidth; - numlines = oldtotallines; + oldwidth = con_linewidth; + con_linewidth = width; + oldtotallines = con_totallines; + con_totallines = CON_TEXTSIZE / con_linewidth; + numlines = oldtotallines; - if (con_totallines < numlines) - numlines = con_totallines; + if (con_totallines < numlines) + numlines = con_totallines; - numchars = oldwidth; + numchars = oldwidth; - if (con_linewidth < numchars) - numchars = con_linewidth; + if (con_linewidth < numchars) + numchars = con_linewidth; - memcpy (tbuf, con_text, CON_TEXTSIZE); - memset (con_text, ' ', CON_TEXTSIZE); + memcpy (tbuf, con_text, CON_TEXTSIZE); + memset (con_text, ' ', CON_TEXTSIZE); - for (i=0 ; i= (size_t) con_linewidth) + while ((int)strlen(temptext) >= con_linewidth) { - _Con_DrawString (0, v, temptext, con_linewidth, 8, 8, 0); + DrawQ_ColoredString( 0, v, temptext, con_linewidth, 8, 8, 1.0, 1.0, 1.0, 1.0, 0, &colorindex ); strcpy(temptext, &temptext[con_linewidth]); v += 8; } if (strlen(temptext) > 0) { - _Con_DrawString (0, v, temptext, 0, 8, 8, 0); + DrawQ_ColoredString( 0, v, temptext, 0, 8, 8, 1.0, 1.0, 1.0, 1.0, 0, &colorindex ); v += 8; } } @@ -891,29 +807,30 @@ void Con_DrawConsole (int lines) { int i, y, rows, j; char *text; + int colorindex = -1; if (lines <= 0) return; // draw the background if (scr_conbrightness.value >= 0.01f) - DrawQ_Pic(0, lines - vid.conheight, "gfx/conback", vid.conwidth, vid.conheight, scr_conbrightness.value, scr_conbrightness.value, scr_conbrightness.value, scr_conalpha.value, 0); + DrawQ_Pic(0, lines - vid_conheight.integer, "gfx/conback", vid_conwidth.integer, vid_conheight.integer, scr_conbrightness.value, scr_conbrightness.value, scr_conbrightness.value, scr_conalpha.value, 0); else - DrawQ_Fill(0, lines - vid.conheight, vid.conwidth, vid.conheight, 0, 0, 0, scr_conalpha.value, 0); - DrawQ_String(vid.conwidth - strlen(engineversion) * 8 - 8, lines - 8, engineversion, 0, 8, 8, 1, 0, 0, 1, 0); + DrawQ_Fill(0, lines - vid_conheight.integer, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, scr_conalpha.value, 0); + DrawQ_String(vid_conwidth.integer - strlen(engineversion) * 8 - 8, lines - 8, engineversion, 0, 8, 8, 1, 0, 0, 1, 0); // draw the text con_vislines = lines; rows = (lines-16)>>3; // rows of text to draw y = lines - 16 - (rows<<3); // may start slightly negative - + for (i = con_current - rows + 1;i <= con_current;i++, y += 8) { j = max(i - con_backscroll, 0); text = con_text + (j % con_totallines)*con_linewidth; - _Con_DrawString(0, y, text, con_linewidth, 8, 8, 0); + DrawQ_ColoredString( 0, y, text, con_linewidth, 8, 8, 1.0, 1.0, 1.0, 1.0, 0, &colorindex ); } // draw the input prompt, user text, and cursor if desired @@ -934,7 +851,7 @@ void Con_DisplayList(const char **list) const char **walk = list; while (*walk) { - len = strlen(*walk); + len = (int)strlen(*walk); if (len > maxlen) maxlen = len; walk++; @@ -942,7 +859,7 @@ void Con_DisplayList(const char **list) maxlen += 1; while (*list) { - len = strlen(*list); + len = (int)strlen(*list); if (pos + maxlen >= width) { Con_Print("\n"); pos = 0; @@ -992,7 +909,7 @@ void Con_CompleteCommandLine (void) else list[0] = Cmd_CompleteAliasBuildList(s); cmd = *list[0]; - cmd_len = strlen (cmd); + cmd_len = (int)strlen (cmd); } else { if (c) cmd = *(list[0] = Cmd_CompleteBuildList(s)); @@ -1001,7 +918,7 @@ void Con_CompleteCommandLine (void) if (a) cmd = *(list[2] = Cmd_CompleteAliasBuildList(s)); - cmd_len = strlen (s); + cmd_len = (int)strlen (s); do { for (i = 0; i < 3; i++) { char ch = cmd[cmd_len];