]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - console.c
366
[xonotic/darkplaces.git] / console.c
index c218a1defd848557fad8b7bc8a7204caf2c75e53..97c2bd224b0aa5d1a2cd1ea1c582521811e0a7a8 100644 (file)
--- a/console.c
+++ b/console.c
@@ -105,27 +105,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
@@ -346,50 +325,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<numlines ; i++)
+       for (i=0 ; i<numlines ; i++)
+       {
+               for (j=0 ; j<numchars ; j++)
                {
-                       for (j=0 ; j<numchars ; j++)
-                       {
-                               con_text[(con_totallines - 1 - i) * con_linewidth + j] =
-                                               tbuf[((con_current - i + oldtotallines) %
-                                                         oldtotallines) * oldwidth + j];
-                       }
+                       con_text[(con_totallines - 1 - i) * con_linewidth + j] =
+                                       tbuf[((con_current - i + oldtotallines) %
+                                                 oldtotallines) * oldwidth + j];
                }
-
-               Con_ClearNotify ();
        }
 
+       Con_ClearNotify ();
+
        con_backscroll = 0;
        con_current = con_totallines - 1;
 }
@@ -402,9 +371,24 @@ Con_Init
 void Con_Init (void)
 {
        memset (con_text, ' ', CON_TEXTSIZE);
-       con_linewidth = -1;
-       Con_CheckResize ();
+       con_linewidth = 80;
+       con_totallines = CON_TEXTSIZE / con_linewidth;
 
+       // 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");
+}
+
+void Con_Init_Commands (void)
+{
        // register our cvars
        Cvar_RegisterVariable (&con_notifytime);
        Cvar_RegisterVariable (&con_notify);
@@ -444,23 +428,11 @@ All console printing must go through this in order to be displayed
 If no console is visible, the notify window will pop up.
 ================
 */
-void Con_PrintToHistory(const char *txt)
+void Con_PrintToHistory(const char *txt, int mask)
 {
-       int y, c, l, mask;
+       int y, c, l;
        static int cr;
 
-       if (txt[0] == 1 || txt[0] == 2)
-       {
-               if (gamemode == GAME_NEXUIZ)
-                       mask = 0;
-               else
-                       mask = 128;             // go to colored text
-               txt++;
-       }
-       else
-               mask = 0;
-
-
        while ( (c = *txt) )
        {
        // count word length
@@ -517,11 +489,6 @@ void Con_PrintToHistory(const char *txt)
                }
 
        }
-
-       if( txt[0] == 1 ) {
-               // play talk wav
-               S_LocalSound ("sound/misc/talk.wav");
-       }
 }
 
 /* The translation table between the graphical font and plain ASCII  --KB */
@@ -573,6 +540,7 @@ extern cvar_t timeformat;
 extern qboolean sys_nostdout;
 void Con_Print(const char *msg)
 {
+       int mask = 0;
        static int index = 0;
        static char line[16384];
 
@@ -586,14 +554,22 @@ void Con_Print(const char *msg)
                        // for Con_PrintToHistory to work properly
                        if (*msg <= 2)
                        {
+                               if (*msg == 1)
+                               {
+                                       // play talk wav
+                                       S_LocalSound ("sound/misc/talk.wav");
+                               }
                                if (gamemode == GAME_NEXUIZ)
                                {
                                        line[index++] = '^';
                                        line[index++] = '3';
-                                       msg++;
                                }
                                else
-                                       line[index++] = *msg++;
+                               {
+                                       // go to colored text
+                                       mask = 128;
+                               }
+                               msg++;
                        }
                        // store timestamp
                        for (;*timestamp;index++, timestamp++)
@@ -609,9 +585,6 @@ void Con_Print(const char *msg)
                        line[index] = 0;
                        // send to log file
                        Log_ConPrint(line);
-                       // send to scrollable buffer
-                       if (con_initialized && cls.state != ca_dedicated)
-                               Con_PrintToHistory(line);
                        // send to terminal or dedicated server window
                        if (!sys_nostdout)
                        {
@@ -620,6 +593,9 @@ void Con_Print(const char *msg)
                                        *p = qfont_table[*p];
                                Sys_PrintToTerminal(line);
                        }
+                       // send to scrollable buffer
+                       if (con_initialized && cls.state != ca_dedicated)
+                               Con_PrintToHistory(line, mask);
                        // empty the line buffer
                        index = 0;
                }
@@ -863,7 +839,7 @@ void Con_DrawNotify (void)
                        int linewidth;
 
                        for (linewidth = con_linewidth; linewidth && text[linewidth-1] == ' '; linewidth--);
-                       x = (vid.conwidth - linewidth * 8) / 2;
+                       x = (vid_conwidth.integer - linewidth * 8) / 2;
                } else
                        x = 0;
 
@@ -915,10 +891,10 @@ void Con_DrawConsole (int lines)
 
 // 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;