*/
void Log_Init (void)
{
+ // Allocate a log queue
+ logq_size = 512;
+ logqueue = Mem_Alloc (tempmempool, logq_size);
+ logq_ind = 0;
+
Cvar_RegisterVariable (&log_file);
Cvar_RegisterVariable (&log_sync);
// support for the classic Quake option
+// COMMANDLINEOPTION: Console: -condebug logs console messages to qconsole.log with sync on (so it keeps every message up to a crash), see also log_file and log_sync
if (COM_CheckParm ("-condebug") != 0)
{
Cvar_SetQuick (&log_file, "qconsole.log");
Cvar_SetValueQuick (&log_sync, 1);
- unlink (va("%s/qconsole.log", fs_gamedir));
}
-
- // Allocate a log queue
- logq_size = 512;
- logqueue = Mem_Alloc (tempmempool, logq_size);
- logq_ind = 0;
}
*/
void Log_ConPrint (const char *msg)
{
+ static qboolean inprogress = false;
+ // don't allow feedback loops with memory error reports
+ if (inprogress)
+ return;
+ inprogress = true;
// Until the host is completely initialized, we maintain a log queue
// to store the messages, since the log can't be started before
if (logqueue != NULL)
memcpy (&logqueue[logq_ind], msg, len);
logq_ind += len;
+ inprogress = false;
return;
}
if (log_sync.integer)
FS_Flush (logfile);
}
+ inprogress = false;
}
con_linewidth = -1;
Con_CheckResize ();
- Con_Print("Console initialized.\n");
-
// register our cvars
Cvar_RegisterVariable (&con_notifytime);
Cvar_RegisterVariable (&con_notify);
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
Cmd_AddCommand ("clear", Con_Clear_f);
+
con_initialized = true;
+ Con_Print("Console initialized.\n");
}
if (txt[0] == 1)
{
mask = 128; // go to colored text
- S_LocalSound ("misc/talk.wav", true);
+ S_LocalSound ("sound/misc/talk.wav");
// play talk wav
txt++;
}
}
}
+/* The translation table between the graphical font and plain ASCII --KB */
+static char qfont_table[256] = {
+ '\0', '#', '#', '#', '#', '.', '#', '#',
+ '#', 9, 10, '#', ' ', 13, '.', '.',
+ '[', ']', '0', '1', '2', '3', '4', '5',
+ '6', '7', '8', '9', '.', '<', '=', '>',
+ ' ', '!', '"', '#', '$', '%', '&', '\'',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~', '<',
+
+ '<', '=', '>', '#', '#', '.', '#', '#',
+ '#', '#', ' ', '#', ' ', '>', '.', '.',
+ '[', ']', '0', '1', '2', '3', '4', '5',
+ '6', '7', '8', '9', '.', '<', '=', '>',
+ ' ', '!', '"', '#', '$', '%', '&', '\'',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~', '<'
+};
+
/*
================
Con_Print
-Prints to all appropriate console targets
+Prints to all appropriate console targets, and adds timestamps
================
*/
+extern cvar_t timestamps;
+extern cvar_t timeformat;
+extern qboolean sys_nostdout;
void Con_Print(const char *msg)
{
- // also echo to debugging console
- Sys_Print(msg);
-
- // log all messages to file
- Log_ConPrint (msg);
-
- if (!con_initialized)
- return;
-
- if (cls.state == ca_dedicated)
- return; // no graphics mode
+ static int index = 0;
+ static char line[16384];
- // write it to the scrollable buffer
- Con_PrintToHistory(msg);
+ for (;*msg;msg++)
+ {
+ if (index == 0)
+ {
+ // if this is the beginning of a new line, print timestamp
+ char *timestamp = timestamps.integer ? Sys_TimeString(timeformat.string) : "";
+ // special color codes for chat messages must always come first
+ // for Con_PrintToHistory to work properly
+ if (*msg <= 2)
+ line[index++] = *msg++;
+ // store timestamp
+ for (;*timestamp;index++, timestamp++)
+ if (index < sizeof(line) - 2)
+ line[index] = *timestamp;
+ }
+ // append the character
+ line[index++] = *msg;
+ // if this is a newline character, we have a complete line to print
+ if (*msg == '\n' || index >= 16000)
+ {
+ // terminate the line
+ 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)
+ {
+ unsigned char *p;
+ for (p = (unsigned char *) line;*p; p++)
+ *p = qfont_table[*p];
+ Sys_PrintToTerminal(line);
+ }
+ // empty the line buffer
+ index = 0;
+ }
+ }
}
char msg[MAXPRINTMSG];
va_start(argptr,fmt);
- vsprintf(msg,fmt,argptr);
+ vsnprintf(msg,sizeof(msg),fmt,argptr);
va_end(argptr);
Con_Print(msg);
return; // don't confuse non-developers with techie stuff...
va_start(argptr,fmt);
- vsprintf(msg,fmt,argptr);
- va_end(argptr);
-
- Con_Print(msg);
-}
-
-
-/*
-================
-Con_SafePrint
-
-Okay to call even when the screen can't be updated
-==================
-*/
-void Con_SafePrint(const char *msg)
-{
- Con_Print(msg);
-}
-
-/*
-==================
-Con_SafePrintf
-
-Okay to call even when the screen can't be updated
-==================
-*/
-void Con_SafePrintf(const char *fmt, ...)
-{
- va_list argptr;
- char msg[MAXPRINTMSG];
-
- va_start(argptr,fmt);
- vsprintf(msg,fmt,argptr);
+ vsnprintf(msg,sizeof(msg),fmt,argptr);
va_end(argptr);
Con_Print(msg);
continue;
text = con_text + (i % con_totallines)*con_linewidth;
- clearnotify = 0;
+ if (gamemode == GAME_NEXUIZ) {
+ int linewidth;
+
+ for (linewidth = con_linewidth; linewidth && text[linewidth-1] == ' '; linewidth--);
+ x = (vid.conwidth - linewidth * 8) / 2;
+ } else
+ x = 0;
- DrawQ_String(0, v, text, con_linewidth, 8, 8, 1, 1, 1, 1, 0);
+ DrawQ_String(x, v, text, con_linewidth, 8, 8, 1, 1, 1, 1, 0);
v += 8;
}
if (key_dest == key_message)
{
- clearnotify = 0;
-
x = 0;
// LordHavoc: speedup, and other improvements