]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - console.c
Remove Con_Warnf and Errorf. Use macros to change color and identify the message
[xonotic/darkplaces.git] / console.c
index 6b3545e854c99d2065ee39eebc1226a0d88d45e4..5bbf112cf1f9b03dda66377204fa0543b1cec4db 100644 (file)
--- a/console.c
+++ b/console.c
@@ -809,7 +809,7 @@ static void Con_ConDump_f(cmd_state_t *cmd)
        file = FS_OpenRealFile(Cmd_Argv(cmd, 1), "w", false);
        if (!file)
        {
-               Con_Errorf("condump: unable to write file \"%s\"\n", Cmd_Argv(cmd, 1));
+               Con_Printf(CON_ERROR "condump: unable to write file \"%s\"\n", Cmd_Argv(cmd, 1));
                return;
        }
        if (con_mutex) Thread_LockMutex(con_mutex);
@@ -842,8 +842,23 @@ void Con_Clear_f(cmd_state_t *cmd)
        if (con_mutex) Thread_UnlockMutex(con_mutex);
 }
 
-void Con_Init_Commands(void)
+/*
+================
+Con_Init
+================
+*/
+void Con_Init (void)
 {
+       con_linewidth = 80;
+       ConBuffer_Init(&con, CON_TEXTSIZE, CON_MAXLINES, zonemempool);
+       if (Thread_HasThreads())
+               con_mutex = Thread_CreateMutex();
+
+       // Allocate a log queue, this will be freed after configs are parsed
+       logq_size = MAX_INPUTLINE;
+       logqueue = (unsigned char *)Mem_Alloc (tempmempool, logq_size);
+       logq_ind = 0;
+
        Cvar_RegisterVariable (&sys_colortranslation);
        Cvar_RegisterVariable (&sys_specialcharactertranslation);
 
@@ -894,26 +909,10 @@ void Con_Init_Commands(void)
        Cmd_AddCommand(CMD_SHARED, "maps", Con_Maps_f, "list information about available maps");
        Cmd_AddCommand(CMD_SHARED, "condump", Con_ConDump_f, "output console history to a file (see also log_file)");
 
-}
-
-/*
-================
-Con_Init
-================
-*/
-void Con_Init (void)
-{
-       con_linewidth = 80;
-       ConBuffer_Init(&con, CON_TEXTSIZE, CON_MAXLINES, zonemempool);
-       if (Thread_HasThreads())
-               con_mutex = Thread_CreateMutex();
-
-       // Allocate a log queue, this will be freed after configs are parsed
-       logq_size = MAX_INPUTLINE;
-       logqueue = (unsigned char *)Mem_Alloc (tempmempool, logq_size);
-       logq_ind = 0;
-
        con_initialized = true;
+       // initialize console window (only used by sys_win.c)
+       Sys_InitConsole();
+       
        Con_DPrint("Console initialized.\n");
 }
 
@@ -1453,61 +1452,6 @@ void Con_Printf(const char *fmt, ...)
        Con_MaskPrint(CON_MASK_PRINT, msg);
 }
 
-/*
-================
-Con_Warn
-================
-*/
-void Con_Warn(const char *msg)
-{
-       Con_Printf("^3%s",msg);
-}
-
-/*
-================
-Con_Warnf
-================
-*/
-void Con_Warnf(const char *fmt, ...)
-{
-       va_list argptr;
-       char msg[MAX_INPUTLINE];
-
-       va_start(argptr,fmt);
-       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
-       va_end(argptr);
-
-       Con_Printf("^3%s",msg);
-}
-
-/*
-================
-Con_Error
-================
-*/
-void Con_Error(const char *msg)
-{
-       Con_Printf("^1%s",msg);
-}
-
-/*
-================
-Con_Errorf
-================
-*/
-void Con_Errorf(const char *fmt, ...)
-{
-       va_list argptr;
-       char msg[MAX_INPUTLINE];
-
-       va_start(argptr,fmt);
-       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
-       va_end(argptr);
-
-       Con_Printf("^1%s",msg);
-
-}
-
 /*
 ================
 Con_DPrint
@@ -2428,7 +2372,7 @@ static int Nicks_strncasecmp(char *a, char *b, unsigned int a_len)
  */
 static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qboolean isCon)
 {
-       char name[128];
+       char name[MAX_SCOREBOARDNAME];
        int i, p;
        int match;
        int spos;
@@ -2759,7 +2703,7 @@ int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos)
                msg = Nicks_list[0];
                len = min(size - Nicks_matchpos - 3, strlen(msg));
                memcpy(&buffer[Nicks_matchpos], msg, len);
-               if( len < (size - 7) ) // space for color (^[0-9] or ^xrgb) and space and \0
+               if(len < size - 7) // space for color code (^[0-9] or ^xrgb), space and \0
                        len = (int)Nicks_AddLastColor(buffer, Nicks_matchpos+(int)len);
                buffer[len++] = ' ';
                buffer[len] = 0;
@@ -3073,7 +3017,7 @@ done:
 
                                memcpy(&key_line[key_linepos] , Nicks_list[0], cmd_len);
                                key_linepos += cmd_len;
-                               if(key_linepos < (int)(sizeof(key_line)-4)) // space for ^, X and space and \0
+                               if(key_linepos < (int)(sizeof(key_line) - 7)) // space for color code (^[0-9] or ^xrgb), space and \0
                                        key_linepos = Nicks_AddLastColor(key_line, key_linepos);
                        }
                        key_line[key_linepos++] = ' ';