DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
console.h File Reference
#include <stddef.h>
#include "qtypes.h"
#include "cmd.h"
#include "lhnet.h"
+ Include dependency graph for console.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  con_lineinfo_t
 
struct  conbuffer_t
 

Functions

void Con_CenterPrint (const char *str)
 Prints a center-aligned message to the console.
 
void Con_CenterPrintf (int maxLineLength, const char *fmt,...) DP_FUNC_PRINTF(2)
 Left-pad a string with spaces to make it appear centered.
 
void Con_CheckResize (void)
 If the line width has changed, reformat the buffer.
 
void Con_Clear_f (cmd_state_t *cmd)
 
void Con_ClearNotify (void)
 Clear all notify lines.
 
int Con_CompleteCommandLine (cmd_state_t *cmd, qbool is_console)
 wrapper function to attempt to either complete the command line or to list possible matches grouped by type (i.e.
 
void Con_DisplayList (const char **list)
 Generic libs/util/console.c function to display a list formatted in columns on the console.
 
void Con_DPrint (const char *msg)
 A Con_Print that only shows up if the "developer" cvar is set.
 
void Con_DPrintf (const char *fmt,...) DP_FUNC_PRINTF(1)
 A Con_Printf that only shows up if the "developer" cvar is set.
 
void Con_DrawConsole (int lines, qbool forcedfullscreen)
 
void Con_DrawNotify (void)
 
void Con_Init (void)
 
void Con_Init_Commands (void)
 
void Con_MaskPrint (unsigned additionalmask, const char *msg)
 Prints to a chosen console target.
 
void Con_MaskPrintf (unsigned mask, const char *fmt,...) DP_FUNC_PRINTF(2)
 
void Con_Print (const char *txt)
 Prints to all appropriate console targets, and adds timestamps.
 
void Con_Printf (const char *fmt,...) DP_FUNC_PRINTF(1)
 Prints to all appropriate console targets.
 
const char * Con_Quakebar (int len, char *bar, size_t bufsize)
 Returns a horizontal line.
 
void Con_Rcon_Redirect_Abort (void)
 
void Con_Rcon_Redirect_End (void)
 
void Con_Rcon_Redirect_Init (lhnetsocket_t *sock, lhnetaddress_t *dest, qbool proquakeprotocol)
 
void Con_Shutdown (void)
 
void Con_ToggleConsole_f (cmd_state_t *cmd)
 
qbool GetMapList (const char *s, char *completedname, int completednamebufferlength)
 

Variables

int con_backscroll
 
qbool con_initialized
 
int con_totallines
 

log

#define CON_ERROR   "^1"
 
#define CON_MASK_CHAT   1
 
#define CON_MASK_DEVELOPER   4
 
#define CON_MASK_HIDENOTIFY   128
 
#define CON_MASK_INPUT   2
 
#define CON_MASK_PRINT   8
 
#define CON_WARN   "^3"
 
void ConBuffer_AddLine (conbuffer_t *buf, const char *line, int len, unsigned mask)
 Appends a given string as a new line to the console.
 
void ConBuffer_Clear (conbuffer_t *buf)
 
void ConBuffer_DeleteLastLine (conbuffer_t *buf)
 Deletes the last line from the console history.
 
void ConBuffer_DeleteLine (conbuffer_t *buf)
 Deletes the first line from the console history.
 
int ConBuffer_FindNextLine (conbuffer_t *buf, unsigned mask_must, unsigned mask_mustnot, int start)
 
int ConBuffer_FindPrevLine (conbuffer_t *buf, unsigned mask_must, unsigned mask_mustnot, int start)
 
void ConBuffer_FixTimes (conbuffer_t *buf)
 
const char * ConBuffer_GetLine (conbuffer_t *buf, int i)
 
void ConBuffer_Init (conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool)
 
#define CONBUFFER_LINES(buf, i)
 
#define CONBUFFER_LINES_COUNT(buf)
 
#define CONBUFFER_LINES_LAST(buf)
 
void ConBuffer_Shutdown (conbuffer_t *buf)
 
void Log_Close (void)
 
void Log_DestBuffer_Flush (void)
 call this once per frame to send out replies to rcon streaming clients
 
void Log_Init (void)
 
void Log_Printf (const char *logfilename, const char *fmt,...) DP_FUNC_PRINTF(2)
 
void Log_Start (void)
 

Macro Definition Documentation

◆ CON_ERROR

#define CON_ERROR   "^1"

Definition at line 102 of file console.h.

Referenced by CL_EstablishConnection(), CL_OpenVideo(), CL_ParseServerInfo(), CL_PlayDemo(), CL_Record_f(), CL_VM_Init(), Cmd_GetCvarValue(), Con_ConDump_f(), Crypto_KeyGen_Finished(), Curl_Select(), Font_GetKerningForMap(), Font_LoadFile(), Font_LoadFont(), Font_LoadMap(), Font_LoadSize(), Font_SearchSize(), font_start(), FS_AddPack_Fullpath(), FS_GameDir_f(), FS_SetGameDirs(), FS_SysOpenFiledesc(), GL_DebugOutputCallback(), hmac_mdfour_challenge_matching(), hmac_mdfour_time_matching(), Host_Error(), Host_SaveConfig(), Key_History_Shutdown(), LHNET_OpenSocket_Connectionless(), LibAV_LoadLibrary(), libavw_decodeframe(), libavw_message(), LibAvW_OpenLibrary(), loadimagepixelsbgra(), LoadSky_f(), Mod_IDS2_Load(), Mod_LoadModel(), Mod_Q3BSP_LoadFaces(), Mod_Q3BSP_LoadLightGrid(), MVM_error_cmd(), NetConn_ClientFrame(), NetConn_ClientParsePacket(), NetConn_Init(), NetConn_OpenClientPort(), NetConn_OpenServerPort(), OpenStream(), plaintext_matching(), PNG_error_fn(), R_GLSL_DumpShader_f(), R_Mesh_CreateFramebufferObject(), RCon_Execute(), S_LoadSound(), SCR_CaptureVideo_Avi_BeginVideo(), SCR_CaptureVideo_Ogg_BeginVideo(), SCR_ScreenShot_f(), SndSys_Init(), SV_Impact(), SV_Loadgame_f(), SV_Savegame_f(), SV_Savegame_to(), SV_SpawnServer(), SV_StartDemoRecording(), Sys_Error(), Sys_SDL_HandleEvents(), VID_ApplyDisplayMode(), VID_EnableJoystick(), VID_Init(), VID_InitModeGL(), VID_Restart_f(), VID_SetVsync_c(), VM_CL_effect(), VM_error(), VM_objerror(), and W_LoadTextureWadFile().

◆ CON_MASK_CHAT

#define CON_MASK_CHAT   1

Definition at line 107 of file console.h.

Referenced by Con_ClearNotify(), Con_DrawNotify(), Con_DrawNotifyRect(), and Con_MaskPrint().

◆ CON_MASK_DEVELOPER

#define CON_MASK_DEVELOPER   4

Definition at line 109 of file console.h.

Referenced by Con_DPrint(), Con_DPrintf(), Con_DrawConsole(), Con_DrawNotify(), and Con_MaskPrint().

◆ CON_MASK_HIDENOTIFY

#define CON_MASK_HIDENOTIFY   128

Definition at line 106 of file console.h.

Referenced by Con_CenterPrint(), Con_CenterPrintf(), Con_ClearNotify(), and Con_DrawNotify().

◆ CON_MASK_INPUT

#define CON_MASK_INPUT   2

Definition at line 108 of file console.h.

Referenced by Con_DrawNotify().

◆ CON_MASK_PRINT

#define CON_MASK_PRINT   8

Definition at line 110 of file console.h.

Referenced by Con_Print(), and Con_Printf().

◆ CON_WARN

◆ CONBUFFER_LINES

#define CONBUFFER_LINES ( buf,
i )
Value:
(buf)->lines[((buf)->lines_first + (i)) % (buf)->maxlines]
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
int i

Definition at line 136 of file console.h.

Referenced by ConBuffer_FindPrevLine(), ConBuffer_FixTimes(), and ConBuffer_GetLine().

◆ CONBUFFER_LINES_COUNT

◆ CONBUFFER_LINES_LAST

#define CONBUFFER_LINES_LAST ( buf)
Value:
#define CONBUFFER_LINES(buf, i)
Definition console.h:136
#define CONBUFFER_LINES_COUNT(buf)
Definition console.h:137

Definition at line 138 of file console.h.

Referenced by ConBuffer_AddLine(), ConBuffer_BytesLeft(), and ConBuffer_FixTimes().

Function Documentation

◆ Con_CenterPrint()

void Con_CenterPrint ( const char * str)

Prints a center-aligned message to the console.

Note
Authored by johnfitz
Parameters
[in]strA multiline string to print

Definition at line 1655 of file console.c.

1656{
1657 char bar[42];
1658
1659 Con_MaskPrintf(CON_MASK_HIDENOTIFY, "%s", Con_Quakebar(40, bar, sizeof(bar)));
1660 Con_CenterPrintf(40, "%s\n", str);
1662}
void Con_MaskPrintf(unsigned mask, const char *fmt,...)
Definition console.c:1487
void Con_CenterPrintf(int maxLineLength, const char *fmt,...)
Left-pad a string with spaces to make it appear centered.
Definition console.c:1600
const char * Con_Quakebar(int len, char *bar, size_t barsize)
Returns a horizontal line.
Definition console.c:1570
#define CON_MASK_HIDENOTIFY
Definition console.h:106

References Con_CenterPrintf(), CON_MASK_HIDENOTIFY, Con_MaskPrintf(), and Con_Quakebar().

Referenced by SCR_CenterPrint().

◆ Con_CenterPrintf()

void Con_CenterPrintf ( int maxLineLength,
const char * fmt,
... )

Left-pad a string with spaces to make it appear centered.

Note
Authored by johnfitz
Parameters
[in]maxLineLengthCenter-align
[in]fmtA printf format string
[in]<unnamed>Zero or more values used by fmt

Definition at line 1600 of file console.c.

1601{
1602 va_list argptr;
1603 char msg[MAX_INPUTLINE]; // the original message
1604 char spaces[21]; // buffer for spaces
1605 char *msgCursor, *lineEnding;
1606 int lineLength, msgLength;
1607 size_t indentSize;
1608
1609 va_start(argptr, fmt);
1610 msgLength = dpvsnprintf(msg, sizeof (msg), fmt, argptr);
1611 va_end(argptr);
1612
1613 if (msgLength < 0)
1614 {
1615 Con_Printf(CON_WARN "The message given to Con_CenterPrintf was too long\n");
1616 return;
1617 }
1618
1619 maxLineLength = min(maxLineLength, con_linewidth);
1620
1621 for (msgCursor = msg; *msgCursor;)
1622 {
1623 lineEnding = strchr(msgCursor, '\n');
1624 if (lineEnding)
1625 {
1626 lineLength = lineEnding - msgCursor; // print just the line
1627 lineEnding++; // set cursor to next character after new line
1628 }
1629 else // last line
1630 {
1631 lineLength = msgLength; // print entire message
1632 lineEnding = msgCursor + lineLength; // set next line cursor to terminator
1633 }
1634
1635 if (lineLength < maxLineLength)
1636 {
1637 indentSize = min(sizeof(spaces) - 1, (size_t)(maxLineLength - lineLength) / 2);
1638 memset(spaces, ' ', indentSize);
1639 spaces[indentSize] = 0;
1640 Con_MaskPrintf(CON_MASK_HIDENOTIFY, "%s%.*s\n", spaces, lineLength, msgCursor);
1641 }
1642 else
1643 Con_MaskPrintf(CON_MASK_HIDENOTIFY, "%.*s\n", lineLength, msgCursor);
1644 msgLength -= lineEnding - msgCursor; // Consume all characters until end of line
1645 msgCursor = lineEnding; // Update message cursor
1646 }
1647}
int dpvsnprintf(char *buffer, size_t buffersize, const char *format, va_list args)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:1010
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
int con_linewidth
Definition console.c:94
#define CON_WARN
Definition console.h:101
#define min(A, B)
Definition mathlib.h:37
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
Definition qdefs.h:94

References con_linewidth, CON_MASK_HIDENOTIFY, Con_MaskPrintf(), Con_Printf(), CON_WARN, dpvsnprintf(), MAX_INPUTLINE, and min.

Referenced by Con_CenterPrint().

◆ Con_CheckResize()

void Con_CheckResize ( void )

If the line width has changed, reformat the buffer.

Definition at line 763 of file console.c.

764{
765 int i, width;
766 float f;
767
768 f = bound(1, con_textsize.value, 128);
769 if(f != con_textsize.value)
772 width = bound(1, width, con.textsize/4);
773 // FIXME uses con in a non abstracted way
774
775 if (width == con_linewidth)
776 return;
777
779
780 for(i = 0; i < CON_LINES_COUNT; ++i)
781 CON_LINES(i).height = -1; // recalculate when next needed
782
784 con_backscroll = 0;
785}
cvar_t vid_conwidth
Definition cl_screen.c:56
conbuffer_t con
Definition console.c:39
#define CON_LINES_COUNT
Definition console.c:44
void Con_ClearNotify(void)
Clear all notify lines.
Definition console.c:702
#define CON_LINES(i)
Definition console.c:42
cvar_t con_textsize
Definition console.c:57
int con_backscroll
Definition console.c:37
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
static int(ZEXPORT *qz_inflate)(z_stream *strm
GLenum GLsizei width
Definition glquake.h:622
#define bound(min, num, max)
Definition mathlib.h:34
float floor(float f)
float f
int textsize
Definition console.h:127
float value
Definition cvar.h:74

References bound, con, con_backscroll, Con_ClearNotify(), CON_LINES, CON_LINES_COUNT, con_linewidth, con_textsize, Cvar_SetValueQuick(), f, floor(), i, int(), conbuffer_t::textsize, cvar_t::value, vid_conwidth, and width.

Referenced by SCR_SetUpToDrawConsole().

◆ Con_Clear_f()

void Con_Clear_f ( cmd_state_t * cmd)

Definition at line 840 of file console.c.

841{
845}
void * con_mutex
Definition console.c:40
void ConBuffer_Clear(conbuffer_t *buf)
Definition console.c:212
#define Thread_LockMutex(m)
Definition thread.h:17
#define Thread_UnlockMutex(m)
Definition thread.h:18

References con, con_mutex, ConBuffer_Clear(), Thread_LockMutex, and Thread_UnlockMutex.

Referenced by Con_Init().

◆ Con_ClearNotify()

void Con_ClearNotify ( void )

Clear all notify lines.

Definition at line 702 of file console.c.

703{
704 int i;
705 for(i = 0; i < CON_LINES_COUNT; ++i)
706 if(!(CON_LINES(i).mask & CON_MASK_CHAT))
708}
#define CON_MASK_CHAT
Definition console.h:107
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
Definition glquake.h:609

References CON_LINES, CON_LINES_COUNT, CON_MASK_CHAT, CON_MASK_HIDENOTIFY, i, and mask.

Referenced by CL_SignonReply(), Con_CheckResize(), and Con_ToggleConsole_f().

◆ Con_CompleteCommandLine()

int Con_CompleteCommandLine ( cmd_state_t * cmd,
qbool is_console )

wrapper function to attempt to either complete the command line or to list possible matches grouped by type (i.e.

will display possible variables, aliases, commands that match what they've typed so far)

Definition at line 2898 of file console.c.

2899{
2900 const char *text = "";
2901 char *s;
2902 const char **list[4] = {0, 0, 0, 0};
2903 char s2[512];
2904 char command[512];
2905 int c, v, a, i, cmd_len, pos, k;
2906 int n; // nicks --blub
2907 const char *space, *patterns;
2908 char vabuf[1024];
2909
2910 char *line;
2911 int linestart, linepos;
2912 unsigned int linesize;
2913 if (is_console)
2914 {
2915 line = key_line;
2916 linepos = key_linepos;
2917 linesize = sizeof(key_line);
2918 linestart = 1;
2919 }
2920 else
2921 {
2922 line = chat_buffer;
2923 linepos = chat_bufferpos;
2924 linesize = sizeof(chat_buffer);
2925 linestart = 0;
2926 }
2927
2928 //find what we want to complete
2929 pos = linepos;
2930 while(--pos >= linestart)
2931 {
2932 k = line[pos];
2933 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
2934 break;
2935 }
2936 pos++;
2937
2938 s = line + pos;
2939 dp_strlcpy(s2, line + linepos, sizeof(s2)); //save chars after cursor
2940 line[linepos] = 0; //hide them
2941
2942 c = v = a = n = cmd_len = 0;
2943 if (!is_console)
2944 goto nicks;
2945
2946 space = strchr(line + 1, ' ');
2947 if(space && pos == (space - line) + 1)
2948 {
2949 // adding 1 to line drops the leading ]
2950 dp_ustr2stp(command, sizeof(command), line + 1, space - (line + 1));
2951
2952 patterns = Cvar_VariableString(cmd->cvars, va(vabuf, sizeof(vabuf), "con_completion_%s", command), CF_CLIENT | CF_SERVER); // TODO maybe use a better place for this?
2953 if(patterns && !*patterns)
2954 patterns = NULL; // get rid of the empty string
2955
2956 if(!strcmp(command, "map") || !strcmp(command, "changelevel") || (patterns && !strcmp(patterns, "map")))
2957 {
2958 //maps search
2959 char t[MAX_QPATH];
2960 if (GetMapList(s, t, sizeof(t)))
2961 {
2962 // first move the cursor
2963 linepos += (int)strlen(t) - (int)strlen(s);
2964
2965 // and now do the actual work
2966 *s = 0;
2967 dp_strlcat(line, t, MAX_INPUTLINE);
2968 dp_strlcat(line, s2, MAX_INPUTLINE); //add back chars after cursor
2969
2970 // and fix the cursor
2971 if(linepos > (int) strlen(line))
2972 linepos = (int) strlen(line);
2973 }
2974 return linepos;
2975 }
2976 else
2977 {
2978 if(patterns)
2979 {
2980 char t[MAX_QPATH];
2981 stringlist_t resultbuf, dirbuf;
2982
2983 // Usage:
2984 // // store completion patterns (space separated) for command foo in con_completion_foo
2985 // set con_completion_foo "foodata/*.foodefault *.foo"
2986 // foo <TAB>
2987 //
2988 // Note: patterns with slash are always treated as absolute
2989 // patterns; patterns without slash search in the innermost
2990 // directory the user specified. There is no way to "complete into"
2991 // a directory as of now, as directories seem to be unknown to the
2992 // FS subsystem.
2993 //
2994 // Examples:
2995 // set con_completion_playermodel "models/player/*.zym models/player/*.md3 models/player/*.psk models/player/*.dpm"
2996 // set con_completion_playdemo "*.dem"
2997 // set con_completion_play "*.wav *.ogg"
2998 //
2999 // TODO somehow add support for directories; these shall complete
3000 // to their name + an appended slash.
3001
3002 stringlistinit(&resultbuf);
3003 stringlistinit(&dirbuf);
3004 while(COM_ParseToken_Simple(&patterns, false, false, true))
3005 {
3006 fssearch_t *search;
3007 if(strchr(com_token, '/'))
3008 {
3009 search = FS_Search(com_token, true, true, NULL);
3010 }
3011 else
3012 {
3013 const char *slash = strrchr(s, '/');
3014 if(slash)
3015 {
3016 dp_strlcpy(t, s, min(sizeof(t), (unsigned int)(slash - s + 2))); // + 2, because I want to include the slash
3017 dp_strlcat(t, com_token, sizeof(t));
3018 search = FS_Search(t, true, true, NULL);
3019 }
3020 else
3021 search = FS_Search(com_token, true, true, NULL);
3022 }
3023 if(search)
3024 {
3025 for(i = 0; i < search->numfilenames; ++i)
3026 if(!strncmp(search->filenames[i], s, strlen(s)))
3027 if(FS_FileType(search->filenames[i]) == FS_FILETYPE_FILE)
3028 stringlistappend(&resultbuf, search->filenames[i]);
3029 FS_FreeSearch(search);
3030 }
3031 }
3032
3033 // In any case, add directory names
3034 {
3035 fssearch_t *search;
3036 const char *slash = strrchr(s, '/');
3037 if(slash)
3038 {
3039 dp_strlcpy(t, s, min(sizeof(t), (unsigned int)(slash - s + 2))); // + 2, because I want to include the slash
3040 dp_strlcat(t, "*", sizeof(t));
3041 search = FS_Search(t, true, true, NULL);
3042 }
3043 else
3044 search = FS_Search("*", true, true, NULL);
3045 if(search)
3046 {
3047 for(i = 0; i < search->numfilenames; ++i)
3048 if(!strncmp(search->filenames[i], s, strlen(s)))
3050 stringlistappend(&dirbuf, search->filenames[i]);
3051 FS_FreeSearch(search);
3052 }
3053 }
3054
3055 if(resultbuf.numstrings > 0 || dirbuf.numstrings > 0)
3056 {
3057 const char *p, *q;
3058 unsigned int matchchars;
3059 if(resultbuf.numstrings == 0 && dirbuf.numstrings == 1)
3060 {
3061 dpsnprintf(t, sizeof(t), "%s/", dirbuf.strings[0]);
3062 }
3063 else
3064 if(resultbuf.numstrings == 1 && dirbuf.numstrings == 0)
3065 {
3066 dpsnprintf(t, sizeof(t), "%s ", resultbuf.strings[0]);
3067 }
3068 else
3069 {
3070 stringlistsort(&resultbuf, true); // dirbuf is already sorted
3071 Con_Printf("\n%i possible filenames\n", resultbuf.numstrings + dirbuf.numstrings);
3072 for(i = 0; i < dirbuf.numstrings; ++i)
3073 {
3074 Con_Printf("^4%s^7/\n", dirbuf.strings[i]);
3075 }
3076 for(i = 0; i < resultbuf.numstrings; ++i)
3077 {
3078 Con_Printf("%s\n", resultbuf.strings[i]);
3079 }
3080 matchchars = sizeof(t) - 1;
3081 if(resultbuf.numstrings > 0)
3082 {
3083 p = resultbuf.strings[0];
3084 q = resultbuf.strings[resultbuf.numstrings - 1];
3085 for(; *p && *p == *q; ++p, ++q);
3086 matchchars = (unsigned int)(p - resultbuf.strings[0]);
3087 }
3088 if(dirbuf.numstrings > 0)
3089 {
3090 p = dirbuf.strings[0];
3091 q = dirbuf.strings[dirbuf.numstrings - 1];
3092 for(; *p && *p == *q; ++p, ++q);
3093 matchchars = min(matchchars, (unsigned int)(p - dirbuf.strings[0]));
3094 }
3095 // now p points to the first non-equal character, or to the end
3096 // of resultbuf.strings[0]. We want to append the characters
3097 // from resultbuf.strings[0] to (not including) p as these are
3098 // the unique prefix
3099 dp_strlcpy(t, (resultbuf.numstrings > 0 ? resultbuf : dirbuf).strings[0], min(matchchars + 1, sizeof(t)));
3100 }
3101
3102 // first move the cursor
3103 linepos += (int)strlen(t) - (int)strlen(s);
3104
3105 // and now do the actual work
3106 *s = 0;
3107 dp_strlcat(line, t, MAX_INPUTLINE);
3108 dp_strlcat(line, s2, MAX_INPUTLINE); //add back chars after cursor
3109
3110 // and fix the cursor
3111 if(linepos > (int) strlen(line))
3112 linepos = (int) strlen(line);
3113 }
3114 stringlistfreecontents(&resultbuf);
3115 stringlistfreecontents(&dirbuf);
3116
3117 return linepos; // bail out, when we complete for a command that wants a file name
3118 }
3119 }
3120 }
3121
3122 // Count number of possible matches and print them
3124 if (c)
3125 {
3126 Con_Printf("\n%i possible command%s\n", c, (c > 1) ? "s: " : ":");
3128 }
3130 if (v)
3131 {
3132 Con_Printf("\n%i possible variable%s\n", v, (v > 1) ? "s: " : ":");
3134 }
3136 if (a)
3137 {
3138 Con_Printf("\n%i possible alias%s\n", a, (a > 1) ? "es: " : ":");
3140 }
3141
3142nicks:
3143 n = Nicks_CompleteCountPossible(line, linepos, s, is_console);
3144 if (n)
3145 {
3146 Con_Printf("\n%i possible nick%s\n", n, (n > 1) ? "s: " : ":");
3148 }
3149
3150 if (!(c + v + a + n)) // No possible matches
3151 {
3152 if(s2[0])
3153 dp_strlcpy(&line[linepos], s2, linesize - linepos);
3154 return linepos;
3155 }
3156
3157 if (c)
3158 text = *(list[0] = Cmd_CompleteBuildList(cmd, s));
3159 if (v)
3160 text = *(list[1] = Cvar_CompleteBuildList(cmd->cvars, s, cmd->cvars_flagsmask));
3161 if (a)
3162 text = *(list[2] = Cmd_CompleteAliasBuildList(cmd, s));
3163 if (n)
3164 {
3165 if (is_console)
3166 text = *(list[3] = Nicks_CompleteBuildList(n));
3167 else
3168 text = *(Nicks_CompleteBuildList(n));
3169 }
3170
3171 for (cmd_len = (int)strlen(s);;cmd_len++)
3172 {
3173 const char **l;
3174 for (i = 0; i < 3; i++)
3175 if (list[i])
3176 for (l = list[i];*l;l++)
3177 if ((*l)[cmd_len] != text[cmd_len])
3178 goto done;
3179 // all possible matches share this character, so we continue...
3180 if (!text[cmd_len])
3181 {
3182 // if all matches ended at the same position, stop
3183 // (this means there is only one match)
3184 break;
3185 }
3186 }
3187done:
3188
3189 // prevent a buffer overrun by limiting cmd_len according to remaining space
3190 cmd_len = min(cmd_len, (int)linesize - 1 - pos);
3191 if (text)
3192 {
3193 linepos = pos;
3194 memcpy(&line[linepos], text, cmd_len);
3195 linepos += cmd_len;
3196 // if there is only one match, add a space after it
3197 if (c + v + a + n == 1 && linepos < (int)linesize - 1)
3198 {
3199 if(n)
3200 { // was a nick, might have an offset, and needs colors ;) --blub
3201 linepos = pos - Nicks_offset[0];
3202 cmd_len = (int)strlen(Nicks_list[0]);
3203 cmd_len = min(cmd_len, (int)linesize - 3 - pos);
3204
3205 memcpy(&line[linepos] , Nicks_list[0], cmd_len);
3206 linepos += cmd_len;
3207 if(linepos < (int)(linesize - 7)) // space for color code (^[0-9] or ^xrgb), space and \0
3208 linepos = Nicks_AddLastColor(line, linepos);
3209 }
3210 line[linepos++] = ' ';
3211 }
3212 }
3213
3214 // use strlcat to avoid a buffer overrun
3215 line[linepos] = 0;
3216 dp_strlcat(line, s2, linesize);
3217
3218 if (!is_console)
3219 return linepos;
3220
3221 // free the command, cvar, and alias lists
3222 for (i = 0; i < 4; i++)
3223 if (list[i])
3224 Mem_Free((void *)list[i]);
3225
3226 return linepos;
3227}
void Cmd_CompleteCommandPrint(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1870
const char ** Cmd_CompleteBuildList(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1847
int Cmd_CompleteCountPossible(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1814
void Cmd_CompleteAliasPrint(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1911
int Cmd_CompleteAliasCountPossible(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1931
const char ** Cmd_CompleteAliasBuildList(cmd_state_t *cmd, const char *partial)
Definition cmd.c:1961
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
char * dp_ustr2stp(char *dst, size_t dsize, const char *src, size_t slen)
Copies a measured byte sequence (unterminated string) to a null-terminated string.
Definition common.c:1388
char com_token[MAX_INPUTLINE]
Definition common.c:39
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
qbool COM_ParseToken_Simple(const char **datapointer, qbool returnnewline, qbool parsebackslash, qbool parsecomments)
Definition common.c:463
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
qbool GetMapList(const char *s, char *completedname, int completednamebufferlength)
Definition console.c:2275
static int Nicks_AddLastColor(char *buffer, int pos)
Definition console.c:2826
static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon)
Definition console.c:2570
static void Cmd_CompleteNicksPrint(int count)
Definition console.c:2636
static const char ** Nicks_CompleteBuildList(int count)
Definition console.c:2806
static int Nicks_offset[MAX_SCOREBOARD]
Definition console.c:2489
static char Nicks_list[MAX_SCOREBOARD][MAX_SCOREBOARDNAME]
Definition console.c:2486
const char * Cvar_VariableString(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
Definition cvar.c:149
const char ** Cvar_CompleteBuildList(cvar_state_t *cvars, const char *partial, unsigned neededflags)
Definition cvar.c:250
void Cvar_CompleteCvarPrint(cvar_state_t *cvars, const char *partial, unsigned neededflags)
Definition cvar.c:288
int Cvar_CompleteCountPossible(cvar_state_t *cvars, const char *partial, unsigned neededflags)
Definition cvar.c:217
void stringlistfreecontents(stringlist_t *list)
Definition filematch.c:87
void stringlistinit(stringlist_t *list)
Definition filematch.c:82
void stringlistsort(stringlist_t *list, qbool uniq)
Definition filematch.c:129
void stringlistappend(stringlist_t *list, const char *text)
Definition filematch.c:103
#define n(x, y)
void FS_FreeSearch(fssearch_t *search)
Definition fs.c:3963
fssearch_t * FS_Search(const char *pattern, int caseinsensitive, int quiet, const char *packfile)
Definition fs.c:3756
int FS_FileType(const char *filename)
Look for a file in the packages and in the filesystem.
Definition fs.c:3667
#define FS_FILETYPE_DIRECTORY
Definition fs.h:139
#define FS_FILETYPE_FILE
Definition fs.h:138
const GLdouble * v
Definition glquake.h:762
int chat_bufferpos
Definition keys.c:701
int key_linepos
Definition keys.c:35
char chat_buffer[MAX_INPUTLINE]
Definition keys.c:700
char key_line[MAX_INPUTLINE]
Definition keys.c:34
float strlen(string s)
void cmd(string command,...)
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
#define NULL
Definition qtypes.h:12
ret a
char ** filenames
Definition fs.h:117
int numfilenames
Definition fs.h:116
char ** strings
Definition filematch.h:31
#define Mem_Free(mem)
Definition zone.h:96

References a, CF_CLIENT, CF_SERVER, chat_buffer, chat_bufferpos, cmd(), Cmd_CompleteAliasBuildList(), Cmd_CompleteAliasCountPossible(), Cmd_CompleteAliasPrint(), Cmd_CompleteBuildList(), Cmd_CompleteCommandPrint(), Cmd_CompleteCountPossible(), Cmd_CompleteNicksPrint(), COM_ParseToken_Simple(), com_token, Con_Printf(), Cvar_CompleteBuildList(), Cvar_CompleteCountPossible(), Cvar_CompleteCvarPrint(), Cvar_VariableString(), dp_strlcat, dp_strlcpy, dp_ustr2stp(), dpsnprintf(), fssearch_t::filenames, FS_FileType(), FS_FILETYPE_DIRECTORY, FS_FILETYPE_FILE, FS_FreeSearch(), FS_Search(), GetMapList(), i, int(), key_line, key_linepos, MAX_INPUTLINE, MAX_QPATH, Mem_Free, min, n, Nicks_AddLastColor(), Nicks_CompleteBuildList(), Nicks_CompleteCountPossible(), Nicks_list, Nicks_offset, NULL, fssearch_t::numfilenames, stringlist_t::numstrings, stringlistappend(), stringlistfreecontents(), stringlistinit(), stringlistsort(), stringlist_t::strings, strlen(), v, and va().

Referenced by Key_Parse_CommonKeys().

◆ Con_DisplayList()

void Con_DisplayList ( const char ** list)

Generic libs/util/console.c function to display a list formatted in columns on the console.

Definition at line 2452 of file console.c.

2453{
2454 int i = 0, pos = 0, len = 0, maxlen = 0, width = (con_linewidth - 4);
2455 const char **walk = list;
2456
2457 while (*walk) {
2458 len = (int)strlen(*walk);
2459 if (len > maxlen)
2460 maxlen = len;
2461 walk++;
2462 }
2463 maxlen += 1;
2464
2465 while (*list) {
2466 len = (int)strlen(*list);
2467 if (pos + maxlen >= width) {
2468 Con_Print("\n");
2469 pos = 0;
2470 }
2471
2472 Con_Print(*list);
2473 for (i = 0; i < (maxlen - len); i++)
2474 Con_Print(" ");
2475
2476 pos += maxlen;
2477 list++;
2478 }
2479
2480 if (pos)
2481 Con_Print("\n\n");
2482}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504

References con_linewidth, Con_Print(), i, int(), strlen(), and width.

◆ Con_DPrint()

void Con_DPrint ( const char * msg)

A Con_Print that only shows up if the "developer" cvar is set.

Definition at line 1531 of file console.c.

1532{
1533 if(developer.integer < 0) // at 0, we still add to the buffer but hide
1534 return;
1535
1537}
void Con_MaskPrint(unsigned additionalmask, const char *msg)
Prints to a chosen console target.
Definition console.c:1161
#define CON_MASK_DEVELOPER
Definition console.h:109
cvar_t developer
Definition host.c:48
int integer
Definition cvar.h:73

References CON_MASK_DEVELOPER, Con_MaskPrint(), developer, and cvar_t::integer.

Referenced by CL_DisconnectEx(), CL_NewBeam(), CL_ParseServerInfo(), CL_SetSignonStage_WithMsg(), CL_VM_ShutDown(), Collision_NewBrushFromPlanes(), Cvar_Command(), Cvar_RestoreInitState(), Cvar_Set_f(), Cvar_SetA_f(), Font_LoadMap(), GL_CheckExtension(), GL_Setup(), Host_Init(), M_Menu_Main_f(), Mod_LoadQ3Shaders(), NetConn_ReceivedMessage(), Palette_Load(), PRVM_ED_CallSpawnFunction(), S_PaintAndSubmit(), SndSys_Init(), SV_Color_f(), SV_Prepare_CSQC(), SV_Spawn_f(), and VID_InitModeGL().

◆ Con_DPrintf()

void Con_DPrintf ( const char * fmt,
... )

A Con_Printf that only shows up if the "developer" cvar is set.

Definition at line 1544 of file console.c.

1545{
1546 va_list argptr;
1547 char msg[MAX_INPUTLINE];
1548
1549 if(developer.integer < 0) // at 0, we still add to the buffer but hide
1550 return;
1551
1552 va_start(argptr,fmt);
1553 dpvsnprintf(msg,sizeof(msg),fmt,argptr);
1554 va_end(argptr);
1555
1557}

References CON_MASK_DEVELOPER, Con_MaskPrint(), developer, dpvsnprintf(), cvar_t::integer, and MAX_INPUTLINE.

Referenced by _Mem_Alloc(), _Mem_Free(), _Mem_FreeBlock(), alert_legacy_font_api(), Buffer_Callback(), CDAudio_Play_byName(), CheckPendingDownloads(), CL_DisconnectEx(), CL_ExaminePrintString(), CL_IPLog_Add(), CL_LinkEdict(), CL_NetworkTimeReceived(), CL_NewParticlesFromEffectinfo(), CL_OpenVideo(), CL_ParseServerMessage(), CL_ParseStatic(), CL_ParticleEffect_Fallback(), CL_SignonReply(), CL_Startdemos_f(), CL_StopDownload(), CL_ValidateState(), CL_VM_Init(), CLVM_ExecuteProgram(), Cmd_AddCommand(), Cmd_RestoreInitState(), Collision_CalcPlanesForTriangleBrushFloat(), Collision_NewBrushFromPlanes(), Crypto_ServerError(), Crypto_SoftClientError(), Crypto_SoftServerError(), Curl_Begin(), Curl_CheckCommandWhenDone(), curl_default_callback(), Cvar_Get(), Cvar_RegisterCallback(), Cvar_RegisterVariable(), Cvar_RegisterVirtual(), Cvar_RestoreInitState(), Cvar_SetQuick(), Draw_CachePic_Flags(), Draw_Frame(), Draw_FreePic(), Draw_GetPicTexture(), Draw_IsPicLoaded(), Draw_NewPic(), EntityFrame5_WriteFrame(), EntityFrameCSQC_LostFrame(), EntityFrameQW_CL_ReadFrame(), EntityState5_Priority(), Font_LoadFile(), Font_LoadMap(), FS_FindFile(), FS_Init_Dir(), FS_LoadPackPAK(), FS_LoadPackPK3FromFD(), FS_LoadPackVirtual(), FS_OpenReadFile(), FS_UnloadPacks_dlcache(), FS_WriteFileInBlocks(), GetMapList(), GL_Backend_CompileProgram(), GL_CheckExtension(), GL_InitFunctions(), gl_main_start(), GL_Setup(), JPEG_SaveImage_to_Buffer(), Key_Event(), LHNET_OpenSocket_Connectionless(), LHNET_Read(), LHNET_Write(), LoadFont(), LoadFont_f(), loadimagepixelsbgra(), LoadSubtitles(), Mod_BuildAliasSkinsFromSkinFiles(), Mod_LoadCustomMaterial(), Mod_LoadModel(), Mod_LoadQ3Shaders(), Mod_LoadQ3Shaders_EnumerateWaveFunc(), Mod_LoadTextureFromQ3Shader(), Mod_Mesh_Validate(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q1BSP_LoadTextures(), Mod_Q2BSP_Load(), Mod_Q2BSP_LoadBrushes(), Mod_Q3BSP_Load(), Mod_Q3BSP_LoadFaces(), Mod_Q3BSP_LoadLightmaps(), NetConn_ClientParsePacket(), NetConn_ServerParsePacket(), PRVM_ED_LoadFromFile(), PRVM_ED_ParseEdict(), PRVM_ED_ParseEpair(), PRVM_ED_ParseGlobals(), PRVM_GarbageCollection(), PRVM_Init(), PRVM_MarkReferencedEdicts(), PRVM_Prog_Load(), PRVM_SetEngineString(), PRVM_SetTempString(), Q3Shader_AddToHash(), QW_CL_NextUpload_f(), QW_CL_ServerInfo(), QW_CL_StartUpload(), R_BuildFogTexture(), R_GLSL_CompilePermutation(), R_LoadCubemap(), R_LoadTextureDDSFile(), R_Mesh_Draw(), R_Mesh_VertexPointer(), R_Modules_Shutdown(), R_Modules_Start(), R_Q1BSP_CallRecursiveGetLightInfo(), R_RTLight_Compile(), R_SetupShader_SetPermutationGLSL(), R_UpdateTexture(), S_PaintAndSubmit(), S_PlaySfxOnChannel(), Sbar_DeathmatchOverlay(), SCR_CaptureVideo_Ogg_BeginVideo(), SCR_CaptureVideo_RIFF_Finish(), SCR_DrawInfobar(), SCR_PopLoadingScreen(), ShaderModeInfo_GetShaderText(), SV_ConnectClient(), SV_Download_f(), SV_DropClient(), SV_LinkEdict(), SV_Prepare_CSQC(), SV_ReadClientMessage(), SV_ReadClientMove(), SV_SendServerinfo(), SV_Shutdown(), SV_ThreadFunc(), SV_UnstickEntity(), SV_VM_Setup(), SVVM_ExecuteProgram(), Sys_LoadDependency(), Sys_LoadDependencyFunctions(), Sys_SDL_HandleEvents(), VID_ApplyDisplayMode(), VID_ApplyDisplayMode_c(), VID_EnableJoystick(), VID_ListModes(), VID_SetMouse(), VID_SetVsync_c(), VM_CL_gettagindex(), VM_CL_gettaginfo(), VM_CL_R_AddDynamicLight(), VM_CL_setattachment(), VM_dprint(), VM_fclose(), VM_fgets(), VM_fopen(), VM_fputs(), VM_FrameBlendFromFrameGroupBlend(), VM_SV_gettagindex(), VM_SV_gettaginfo(), VM_SV_setattachment(), VM_SV_sound(), and World_SetSize().

◆ Con_DrawConsole()

void Con_DrawConsole ( int lines,
qbool forcedfullscreen )

Definition at line 2138 of file console.c.

2139{
2140 float alpha, alpha0;
2141 double sx, sy;
2142 int mask_must = 0;
2143 int mask_mustnot = (developer.integer>0) ? 0 : CON_MASK_DEVELOPER;
2144 cachepic_t *conbackpic;
2145 unsigned int conbackflags;
2146
2147 if (lines <= 0)
2148 return;
2149
2151
2152 if (con_backscroll < 0)
2153 con_backscroll = 0;
2154
2155 con_vislines = lines;
2156
2157 r_draw2d_force = true;
2158
2159// draw the background
2160 alpha0 = forcedfullscreen ? 1.0f : scr_conalpha.value; // always full alpha when not forced fullscreen
2161 if((alpha = alpha0 * scr_conalphafactor.value) > 0)
2162 {
2165 conbackflags = CACHEPICFLAG_FAILONMISSING; // So console is readable when game content is missing
2166 if (sx != 0 || sy != 0)
2167 conbackflags &= CACHEPICFLAG_NOCLAMP;
2168 conbackpic = scr_conbrightness.value >= 0.01f ? Draw_CachePic_Flags("gfx/conback", conbackflags) : NULL;
2169 sx *= host.realtime; sy *= host.realtime;
2170 sx -= floor(sx); sy -= floor(sy);
2171 if (Draw_IsPicLoaded(conbackpic))
2177 0);
2178 else
2179 DrawQ_Fill(0, lines - vid_conheight.integer, vid_conwidth.integer, vid_conheight.integer, 0.0f, 0.0f, 0.0f, alpha, 0);
2180 }
2181 if((alpha = alpha0 * scr_conalpha2factor.value) > 0)
2182 {
2185 conbackpic = Draw_CachePic_Flags("gfx/conback2", (sx != 0 || sy != 0) ? CACHEPICFLAG_NOCLAMP : 0);
2186 sx *= host.realtime; sy *= host.realtime;
2187 sx -= floor(sx); sy -= floor(sy);
2188 if(Draw_IsPicLoaded(conbackpic))
2194 0);
2195 }
2196 if((alpha = alpha0 * scr_conalpha3factor.value) > 0)
2197 {
2200 conbackpic = Draw_CachePic_Flags("gfx/conback3", (sx != 0 || sy != 0) ? CACHEPICFLAG_NOCLAMP : 0);
2201 sx *= host.realtime; sy *= host.realtime;
2202 sx -= floor(sx); sy -= floor(sy);
2203 if(Draw_IsPicLoaded(conbackpic))
2209 0);
2210 }
2212
2213// draw the text
2214#if 0
2215 {
2216 int i;
2217 int count = CON_LINES_COUNT;
2218 float ymax = con_vislines - 2 * con_textsize.value;
2219 float y = ymax + con_textsize.value * con_backscroll;
2220 for (i = 0;i < count && y >= 0;i++)
2221 y -= Con_DrawConsoleLine(mask_must, mask_mustnot, y - con_textsize.value, CON_LINES_COUNT - 1 - i, 0, ymax) * con_textsize.value;
2222 // fix any excessive scrollback for the next frame
2223 if (i >= count && y >= 0)
2224 {
2226 if (con_backscroll < 0)
2227 con_backscroll = 0;
2228 }
2229 }
2230#else
2231 if(CON_LINES_COUNT > 0)
2232 {
2233 int i, last, limitlast;
2234 float y;
2235 float ymax = con_vislines - 2 * con_textsize.value;
2236 Con_LastVisibleLine(mask_must, mask_mustnot, &last, &limitlast);
2237 //Con_LastVisibleLine(mask_must, mask_mustnot, &last, &limitlast);
2238 y = ymax - con_textsize.value;
2239
2240 if(limitlast)
2241 y += (CON_LINES(last).height - limitlast) * con_textsize.value;
2242 i = last;
2243
2244 for(;;)
2245 {
2246 y -= Con_DrawConsoleLine(mask_must, mask_mustnot, y, i, 0, ymax) * con_textsize.value;
2247 if(i == 0)
2248 break; // top of console buffer
2249 if(y < 0)
2250 break; // top of console window
2251 limitlast = 0;
2252 --i;
2253 }
2254 }
2255#endif
2256
2257// draw the input prompt, user text, and cursor if desired
2259
2260 r_draw2d_force = false;
2262}
cvar_t scr_conscroll2_y
Definition cl_screen.c:31
cvar_t scr_conbrightness
Definition cl_screen.c:25
cvar_t scr_conscroll2_x
Definition cl_screen.c:30
cvar_t scr_conscroll3_y
Definition cl_screen.c:33
cvar_t scr_conalphafactor
Definition cl_screen.c:22
cvar_t scr_conalpha
Definition cl_screen.c:21
cvar_t scr_conscroll_x
Definition cl_screen.c:28
cvar_t scr_conscroll3_x
Definition cl_screen.c:32
cvar_t scr_conalpha2factor
Definition cl_screen.c:23
cvar_t scr_conscroll_y
Definition cl_screen.c:29
cvar_t scr_conalpha3factor
Definition cl_screen.c:24
cvar_t vid_conheight
Definition cl_screen.c:57
static void Con_DrawInput(qbool is_console, float x, float v, float inputsize)
Definition console.c:1684
static int Con_DrawConsoleLine(unsigned mask_must, unsigned mask_mustnot, float y, int lineno, float ymin, float ymax)
Definition console.c:2064
static void Con_LastVisibleLine(unsigned mask_must, unsigned mask_mustnot, int *last, int *limitlast)
Definition console.c:2096
int con_vislines
Definition console.c:95
char engineversion[128]
version string for the corner of the console, crash messages, status command, etc
Definition host.c:304
float alpha
@ CACHEPICFLAG_FAILONMISSING
Definition draw.h:44
@ CACHEPICFLAG_NOCLAMP
Definition draw.h:39
void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
Definition gl_draw.c:847
void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height, float s1, float t1, float r1, float g1, float b1, float a1, float s2, float t2, float r2, float g2, float b2, float a2, float s3, float t3, float r3, float g3, float b3, float a3, float s4, float t4, float r4, float g4, float b4, float a4, int flags)
Definition gl_draw.c:1380
#define FONT_CONSOLE
Definition draw.h:129
float DrawQ_String(float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1320
cachepic_t * Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
Definition gl_draw.c:86
float DrawQ_TextWidth(const char *text, size_t maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1330
qbool Draw_IsPicLoaded(cachepic_t *pic)
Definition gl_draw.c:211
qbool r_draw2d_force
Definition gl_draw.c:795
GLenum GLenum GLsizei count
Definition glquake.h:656
GLint GLenum GLint GLint y
Definition glquake.h:651
host_static_t host
Definition host.c:41
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46

References alpha, CACHEPICFLAG_FAILONMISSING, CACHEPICFLAG_NOCLAMP, con_backscroll, Con_DrawConsoleLine(), Con_DrawInput(), Con_LastVisibleLine(), CON_LINES, CON_LINES_COUNT, CON_MASK_DEVELOPER, con_mutex, con_textsize, con_vislines, count, developer, Draw_CachePic_Flags(), Draw_IsPicLoaded(), DrawQ_Fill(), DrawQ_String(), DrawQ_SuperPic(), DrawQ_TextWidth(), engineversion, floor(), FONT_CONSOLE, host, i, int(), cvar_t::integer, NULL, r_draw2d_force, host_static_t::realtime, scr_conalpha, scr_conalpha2factor, scr_conalpha3factor, scr_conalphafactor, scr_conbrightness, scr_conscroll2_x, scr_conscroll2_y, scr_conscroll3_x, scr_conscroll3_y, scr_conscroll_x, scr_conscroll_y, Thread_LockMutex, Thread_UnlockMutex, cvar_t::value, vid_conheight, vid_conwidth, and y.

Referenced by SCR_DrawConsole().

◆ Con_DrawNotify()

void Con_DrawNotify ( void )

Definition at line 1945 of file console.c.

1946{
1947 float x, v;
1948 float chatstart, notifystart, inputsize, height;
1949 float align;
1950 int numChatlines;
1951 int chatpos;
1952
1955
1956 numChatlines = con_chat.integer;
1957
1958 chatpos = con_chatpos.integer;
1959
1960 if (con_notify.integer < 0)
1963 v = 8; // vertical offset
1964 else
1965 v = 0;
1966
1967 // GAME_NEXUIZ: center, otherwise left justify
1968 align = con_notifyalign.value;
1969 if(!*con_notifyalign.string) // empty string, evaluated to 0 above
1970 {
1972 align = 0.5;
1973 }
1974
1975 if(numChatlines || !con_chatrect.integer)
1976 {
1977 if(chatpos == 0)
1978 {
1979 // first chat, input line, then notify
1980 chatstart = v;
1981 notifystart = v + (numChatlines + 1) * con_chatsize.value;
1982 }
1983 else if(chatpos > 0)
1984 {
1985 // first notify, then (chatpos-1) empty lines, then chat, then input
1986 notifystart = v;
1987 chatstart = v + (con_notify.value + (chatpos - 1)) * con_notifysize.value;
1988 }
1989 else // if(chatpos < 0)
1990 {
1991 // first notify, then much space, then chat, then input, then -chatpos-1 empty lines
1992 notifystart = v;
1993 chatstart = vid_conheight.value - (-chatpos-1 + numChatlines + 1) * con_chatsize.value;
1994 }
1995 }
1996 else
1997 {
1998 // just notify and input
1999 notifystart = v;
2000 chatstart = 0; // shut off gcc warning
2001 }
2002
2004
2006 {
2009 }
2010 else
2011 {
2012 x = 0;
2013 if(numChatlines) // only do this if chat area is enabled, or this would move the input line wrong
2014 v = chatstart;
2015 }
2016 height = numChatlines * con_chatsize.value;
2017
2018 if(numChatlines)
2019 {
2021 v += height;
2022 }
2023 if (key_dest == key_message)
2024 {
2025 inputsize = (numChatlines ? con_chatsize : con_notifysize).value;
2026 Con_DrawInput(false, x, v, inputsize);
2027 }
2028 else
2029 chat_bufferpos = 0;
2030
2032}
gamemode_t gamemode
Definition com_game.c:26
#define IS_OLDNEXUIZ_DERIVED(g)
Definition com_game.h:73
@ GAME_TRANSFUSION
Definition com_game.h:35
cvar_t con_notifysize
Definition console.c:58
cvar_t con_chattime
Definition console.c:50
void ConBuffer_FixTimes(conbuffer_t *buf)
Definition console.c:242
cvar_t con_notifytime
Definition console.c:46
cvar_t con_chatrect_x
Definition console.c:54
cvar_t con_chatrect_y
Definition console.c:55
cvar_t con_chat
Definition console.c:51
cvar_t con_notify
Definition console.c:47
cvar_t con_chatsize
Definition console.c:59
cvar_t con_notifyalign
Definition console.c:48
static int Con_DrawNotifyRect(unsigned mask_must, unsigned mask_mustnot, float maxage, float x, float y, float width, float height, float fontsize, float alignment_x, float alignment_y, const char *continuationString)
Definition console.c:1863
cvar_t con_chatwidth
Definition console.c:56
cvar_t con_chatpos
Definition console.c:52
cvar_t con_chatrect
Definition console.c:53
#define CON_MASK_INPUT
Definition console.h:108
GLenum GLsizei GLsizei height
Definition glquake.h:622
GLsizei const GLfloat * value
Definition glquake.h:740
GLint GLenum GLint x
Definition glquake.h:651
keydest_t key_dest
Definition keys.c:37
@ key_message
Definition keys.h:372
const char * string
Definition cvar.h:71

References chat_bufferpos, con, con_chat, con_chatpos, con_chatrect, con_chatrect_x, con_chatrect_y, con_chatsize, con_chattime, con_chatwidth, Con_DrawInput(), Con_DrawNotifyRect(), CON_MASK_CHAT, CON_MASK_DEVELOPER, CON_MASK_HIDENOTIFY, CON_MASK_INPUT, con_mutex, con_notify, con_notifyalign, con_notifysize, con_notifytime, ConBuffer_FixTimes(), Cvar_SetValueQuick(), GAME_TRANSFUSION, gamemode, height, cvar_t::integer, IS_OLDNEXUIZ_DERIVED, key_dest, key_message, cvar_t::string, Thread_LockMutex, Thread_UnlockMutex, v, cvar_t::value, value, vid_conheight, vid_conwidth, and x.

Referenced by SCR_DrawScreen().

◆ Con_Init()

void Con_Init ( void )

Definition at line 861 of file console.c.

862{
863 con_linewidth = 80;
865 if (Thread_HasThreads())
867
868 // Allocate a log queue, this will be freed after configs are parsed
870 logqueue = (unsigned char *)Mem_Alloc (tempmempool, logq_size);
871 logq_ind = 0;
872
875#if defined(__linux__)
876 // Linux terminals natively support RGB 8bpc codes or convert them to a palette.
878#elif defined(WIN32)
879 // Windows 10 default PowerShell and cmd.exe have no RGB or ANSI support by default.
880 // TODO: it can be enabled on current versions using a platform-specific call,
881 // issue: https://gitlab.com/xonotic/darkplaces/-/issues/426
883#endif
884
888
889 // support for the classic Quake option
890// COMMANDLINEOPTION: Console: -condebug logs console messages to qconsole.log, see also log_file
891 if (Sys_CheckParm ("-condebug") != 0)
892 Cvar_SetQuick (&log_file, "qconsole.log");
893
894 // register our cvars
912
913 // --blub
916
920
922
928
929 // register our commands
930 Cmd_AddCommand(CF_CLIENT, "toggleconsole", Con_ToggleConsole_f, "opens or closes the console");
931 Cmd_AddCommand(CF_CLIENT, "messagemode", Con_MessageMode_f, "input a chat message to say to everyone");
932 Cmd_AddCommand(CF_CLIENT, "messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team");
933 Cmd_AddCommand(CF_CLIENT, "commandmode", Con_CommandMode_f, "input a console command");
934 Cmd_AddCommand(CF_SHARED, "clear", Con_Clear_f, "clear console history");
935 Cmd_AddCommand(CF_SHARED, "maps", Con_Maps_f, "list information about available maps");
936 Cmd_AddCommand(CF_SHARED, "condump", Con_ConDump_f, "output console history to a file (see also log_file)");
937
938 con_initialized = true;
939}
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_SHARED
Definition cmd.h:67
void Con_Clear_f(cmd_state_t *cmd)
Definition console.c:840
cvar_t con_chatsound_team_file
Definition console.c:62
cvar_t rcon_password
Definition console.c:89
static void Con_MessageMode_f(cmd_state_t *cmd)
Definition console.c:731
cvar_t sys_specialcharactertranslation
Definition console.c:65
static void Con_CommandMode_f(cmd_state_t *cmd)
Definition console.c:753
unsigned char * logqueue
Definition console.c:414
static void Con_ConDump_f(cmd_state_t *cmd)
Definition console.c:802
cvar_t log_dest_udp
Definition console.c:407
static void Con_MessageMode2_f(cmd_state_t *cmd)
Definition console.c:743
cvar_t con_completion_exec
Definition console.c:85
cvar_t con_chatsound
Definition console.c:60
cvar_t condump_stripcolors
Definition console.c:87
static void Con_Maps_f(cmd_state_t *cmd)
Definition console.c:789
cvar_t con_nickcompletion_flags
Definition console.c:70
qbool con_initialized
Definition console.c:97
static void Con_RCon_ClearPassword_c(cvar_t *var)
Definition console.c:847
size_t logq_ind
Definition console.c:415
cvar_t rcon_secure_challengetimeout
Definition console.c:91
cvar_t rcon_secure
Definition console.c:90
cvar_t con_completion_playdemo
Definition console.c:83
cvar_t log_file_stripcolors
Definition console.c:406
cvar_t con_nickcompletion
Definition console.c:69
cvar_t log_file
Definition console.c:405
cvar_t rcon_address
Definition console.c:92
cvar_t con_chatsound_team_mask
Definition console.c:63
size_t logq_size
Definition console.c:416
cvar_t con_completion_timedemo
Definition console.c:84
void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool)
Definition console.c:108
cvar_t sys_colortranslation
Definition console.c:66
cvar_t con_chatsound_file
Definition console.c:61
void Con_ToggleConsole_f(cmd_state_t *cmd)
Definition console.c:686
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
void Cvar_RegisterCallback(cvar_t *variable, void(*callback)(cvar_t *))
Definition cvar.c:495
#define CON_TEXTSIZE
max scrollback buffer characters in console
Definition qdefs.h:95
#define CON_MAXLINES
max scrollback buffer lines in console
Definition qdefs.h:96
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327
qbool Thread_HasThreads(void)
Definition thread_null.c:13
#define Thread_CreateMutex()
Definition thread.h:15
mempool_t * tempmempool
Definition zone.c:794
mempool_t * zonemempool
Definition zone.c:796
#define Mem_Alloc(pool, size)
Definition zone.h:92

References CF_CLIENT, CF_SHARED, Cmd_AddCommand(), con, con_chat, con_chatpos, con_chatrect, con_chatrect_x, con_chatrect_y, con_chatsize, con_chatsound, con_chatsound_file, con_chatsound_team_file, con_chatsound_team_mask, con_chattime, con_chatwidth, Con_Clear_f(), Con_CommandMode_f(), con_completion_exec, con_completion_playdemo, con_completion_timedemo, Con_ConDump_f(), con_initialized, con_linewidth, Con_Maps_f(), CON_MAXLINES, Con_MessageMode2_f(), Con_MessageMode_f(), con_mutex, con_nickcompletion, con_nickcompletion_flags, con_notify, con_notifyalign, con_notifysize, con_notifytime, Con_RCon_ClearPassword_c(), CON_TEXTSIZE, con_textsize, Con_ToggleConsole_f(), ConBuffer_Init(), condump_stripcolors, Cvar_RegisterCallback(), Cvar_RegisterVariable(), Cvar_SetQuick(), log_dest_udp, log_file, log_file_stripcolors, logq_ind, logq_size, logqueue, MAX_INPUTLINE, Mem_Alloc, rcon_address, rcon_password, rcon_secure, rcon_secure_challengetimeout, Sys_CheckParm(), sys_colortranslation, sys_specialcharactertranslation, tempmempool, Thread_CreateMutex, Thread_HasThreads(), and zonemempool.

Referenced by Host_Init().

◆ Con_Init_Commands()

void Con_Init_Commands ( void )

◆ Con_MaskPrint()

void Con_MaskPrint ( unsigned additionalmask,
const char * msg )

Prints to a chosen console target.

Definition at line 1161 of file console.c.

1162{
1163 static unsigned mask = 0;
1164 static unsigned index = 0;
1165 static char line[MAX_INPUTLINE];
1166
1167 if (con_mutex)
1169
1170 for (;*msg;msg++)
1171 {
1172 Con_Rcon_AddChar(*msg);
1173 // if this is the beginning of a new line, print timestamp
1174 if (index == 0)
1175 {
1176 // reset the color
1177 // FIXME: 1. perhaps we should use a terminal system 2. use a constant instead of 7!
1178 line[index++] = STRING_COLOR_TAG;
1179 // assert( STRING_COLOR_DEFAULT < 10 )
1180 line[index++] = STRING_COLOR_DEFAULT + '0';
1181 // special color codes for chat messages must always come first
1182 // for Con_PrintToHistory to work properly
1183 if (*msg == 1 || *msg == 2 || *msg == 3)
1184 {
1185 // play talk wav
1186 if (*msg == 1)
1187 {
1188 if (con_chatsound.value)
1189 {
1192 else
1194 }
1195 }
1196 // Send to chatbox for say/tell (1) and messages (3)
1197 // 3 is just so that a message can be sent to the chatbox without a sound.
1198 if (*msg == 1 || *msg == 3)
1200
1201 line[index++] = STRING_COLOR_TAG;
1202 line[index++] = '3';
1203 msg++;
1204 Con_Rcon_AddChar(*msg);
1205 }
1206 // store timestamp
1207 if (timestamps.integer)
1208 index += Sys_TimeString(&line[index], sizeof(line) - index, timeformat.string);
1209 // add the mask
1210 mask |= additionalmask;
1211 }
1212 // append the character
1213 line[index++] = *msg;
1214 // if this is a newline character, we have a complete line to print
1215 // bones_was_here: why do we only use half the line buffer?
1216 if (*msg == '\n' || index >= (int)sizeof(line) / 2)
1217 {
1218 // terminate the line
1219 line[index] = 0;
1220 // send to log file
1221 Log_ConPrint(line);
1222 // send to scrollable buffer
1224 {
1225 Con_PrintToHistory(line, mask);
1226 }
1227 // send to terminal or dedicated server window
1228 if (sys.outfd >= 0)
1230 {
1232 {
1233 char *p;
1234 const char *q;
1235 p = line;
1236 while(*p)
1237 {
1238 int ch = u8_getchar(p, &q);
1239 if(ch >= 0xE000 && ch <= 0xE0FF && ((unsigned char) qfont_table[ch - 0xE000]) >= 0x20)
1240 {
1241 *p = qfont_table[ch - 0xE000];
1242 if(q > p+1)
1243 memmove(p+1, q, strlen(q)+1);
1244 p = p + 1;
1245 }
1246 else
1247 p = p + (q - p);
1248 }
1249 }
1250
1251 if(sys_colortranslation.integer > 0) // ANSI, RGB, or both
1252 {
1253 // ANSI translation:
1254 // 2 can become 7 bytes, rounding that up to 8, and 3 bytes are added at the end
1255 // a newline can transform into four bytes, but then prevents the three extra bytes from appearing
1256 // 8bpc RGB brings new worst-cases:
1257 // 5 can become 21 bytes, rounding that up to * 5, plenty of space for extra bytes at the end.
1258 // sys_colortranslation 3: 2 can become 21 bytes, rounding that up to * 11
1259 char printline[sizeof(line) * 11];
1260 int lastcolor = 0;
1261 const char *in;
1262 char *out;
1263 int color;
1264 u8 rgb[3];
1265 for(in = line, out = printline; *in; ++in)
1266 {
1267 switch(*in)
1268 {
1269 case STRING_COLOR_TAG:
1270 if( in[1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
1271 {
1272 VectorCopy(in + 2, rgb);
1273 // it's a hex digit already, so the else part needs no check --blub
1274 for (int i = 0; i < 3; ++i)
1275 {
1276 if (isdigit(rgb[i])) rgb[i] -= '0';
1277 else rgb[i] = tolower(rgb[i]) - 87;
1278 rgb[i] *= 17;
1279 }
1280
1281 if (sys_colortranslation.integer > 1) // 8bpc RGB
1282 {
1283 char *p;
1284 float B;
1285
1286 in += 4;
1287 rgbout:
1288 color = rgb[0]<<16 | rgb[1]<<8 | rgb[2] | /* disambiguates from quake colours */ 0x40000000;
1289 if (lastcolor == color)
1290 break;
1291 else
1292 lastcolor = color;
1293
1294 B = r_textbrightness.value * 255;
1295 for (int i = 0; i < 3; ++i)
1296 rgb[i] = bound(0, rgb[i] * r_textcontrast.value + B, 255);
1297
1298 // format must be decimal 0-255, max length is 21 bytes
1300 memcpy(out, "\x1B[1;38;2", 8);
1301 else
1302 memcpy(out, "\x1B[0;38;2", 8);
1303 out += 8;
1304 for (int i = 0; i < 3; ++i)
1305 {
1306 *out++ = ';';
1307 p = out += ((rgb[i] > 99) ? 3 : (rgb[i] > 9) ? 2 : 1);
1308 do { *--p = (rgb[i] % 10) + '0';
1309 } while ((rgb[i] /= 10) > 0);
1310 }
1311 *out++ = 'm';
1312
1313 break;
1314 }
1315
1316 color = Sys_Con_NearestColor(rgb[0], rgb[1], rgb[2]);
1317 in += 3; // 3 only, the switch down there does the fourth
1318 }
1319 else
1320 {
1321 color = in[1];
1322
1323 if (sys_colortranslation.integer == 3 && isdigit(color)) // Quake to RGB
1324 {
1325 color -= '0';
1327 ++in;
1328 goto rgbout;
1329 }
1330 }
1331
1332 switch(color)
1333 {
1334 case STRING_COLOR_TAG:
1335 ++in;
1336 *out++ = STRING_COLOR_TAG;
1337 break;
1338 case '0':
1339 case '7':
1340 // normal color
1341 ++in;
1342 if(lastcolor == 0) break; else lastcolor = 0;
1343 *out++ = 0x1B; *out++ = '['; *out++ = 'm';
1344 break;
1345 case '1':
1346 // light red
1347 ++in;
1348 if(lastcolor == 1) break; else lastcolor = 1;
1349 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '1'; *out++ = 'm';
1350 break;
1351 case '2':
1352 // light green
1353 ++in;
1354 if(lastcolor == 2) break; else lastcolor = 2;
1355 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '2'; *out++ = 'm';
1356 break;
1357 case '3':
1358 // yellow
1359 ++in;
1360 if(lastcolor == 3) break; else lastcolor = 3;
1361 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '3'; *out++ = 'm';
1362 break;
1363 case '4':
1364 // light blue
1365 ++in;
1366 if(lastcolor == 4) break; else lastcolor = 4;
1367 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '4'; *out++ = 'm';
1368 break;
1369 case '5':
1370 // light cyan
1371 ++in;
1372 if(lastcolor == 5) break; else lastcolor = 5;
1373 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '6'; *out++ = 'm';
1374 break;
1375 case '6':
1376 // light magenta
1377 ++in;
1378 if(lastcolor == 6) break; else lastcolor = 6;
1379 *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '5'; *out++ = 'm';
1380 break;
1381 // 7 handled above
1382 case '8':
1383 case '9':
1384 // bold normal color
1385 ++in;
1386 if(lastcolor == 8) break; else lastcolor = 8;
1387 *out++ = 0x1B; *out++ = '['; *out++ = '0'; *out++ = ';'; *out++ = '1'; *out++ = 'm';
1388 break;
1389 default:
1390 *out++ = STRING_COLOR_TAG;
1391 break;
1392 }
1393 break;
1394 case '\n':
1395 if(lastcolor != 0)
1396 {
1397 *out++ = 0x1B; *out++ = '['; *out++ = 'm';
1398 lastcolor = 0;
1399 }
1400 *out++ = *in;
1401 break;
1402 default:
1403 *out++ = *in;
1404 break;
1405 }
1406 }
1407 if(lastcolor != 0)
1408 {
1409 *out++ = 0x1B;
1410 *out++ = '[';
1411 *out++ = 'm';
1412 }
1413 *out = '\0';
1414 Sys_Print(printline, out - printline);
1415 }
1416 else if(sys_colortranslation.integer == -1) // print as text
1417 {
1418 Sys_Print(line, index);
1419 }
1420 else // strip
1421 {
1422 char printline[MAX_INPUTLINE]; // it can only get shorter here
1423 const char *in;
1424 char *out;
1425 for(in = line, out = printline; *in; ++in)
1426 {
1427 switch(*in)
1428 {
1429 case STRING_COLOR_TAG:
1430 switch(in[1])
1431 {
1433 if ( isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
1434 {
1435 in+=4;
1436 break;
1437 }
1438 *out++ = STRING_COLOR_TAG;
1440 ++in;
1441 break;
1442 case STRING_COLOR_TAG:
1443 ++in;
1444 *out++ = STRING_COLOR_TAG;
1445 break;
1446 case '0':
1447 case '1':
1448 case '2':
1449 case '3':
1450 case '4':
1451 case '5':
1452 case '6':
1453 case '7':
1454 case '8':
1455 case '9':
1456 ++in;
1457 break;
1458 default:
1459 *out++ = STRING_COLOR_TAG;
1460 break;
1461 }
1462 break;
1463 default:
1464 *out++ = *in;
1465 break;
1466 }
1467 }
1468 *out = '\0';
1469 Sys_Print(printline, out - printline);
1470 }
1471 }
1472 // empty the line buffer
1473 index = 0;
1474 mask = 0;
1475 }
1476 }
1477
1478 if (con_mutex)
1480}
client_state_t cl
Definition cl_main.c:117
client_static_t cls
Definition cl_main.c:116
@ ca_dedicated
Definition client.h:530
cvar_t timeformat
Definition host.c:56
cvar_t r_textbrightness
Definition gl_draw.c:55
static void Con_Rcon_AddChar(int c)
Adds a character to the rcon buffer.
Definition console.c:1060
static char Sys_Con_NearestColor(const unsigned char _r, const unsigned char _g, const unsigned char _b)
Convert an RGB color to its nearest quake color.
Definition console.c:1099
static void Con_PrintToHistory(const char *txt, int mask)
Definition console.c:959
cvar_t r_textcontrast
Definition gl_draw.c:56
static char qfont_table[256]
Definition console.c:120
cvar_t timestamps
Definition host.c:55
void Log_ConPrint(const char *msg)
Definition console.c:584
vector color
#define STRING_COLOR_RGB_TAG_CHAR
Definition draw.h:143
const vec4_t string_colors[]
color tag printing
Definition gl_draw.c:853
#define STRING_COLOR_DEFAULT
Definition draw.h:141
#define STRING_COLOR_TAG
Definition draw.h:140
GLuint index
Definition glquake.h:629
#define VectorCopy(in, out)
Definition mathlib.h:101
#define VectorScale(in, scale, out)
Definition mathlib.h:111
uint8_t u8
Definition qtypes.h:35
dp_FragColor rgb
qbool S_LocalSound(const char *sound)
Definition snd_main.c:2246
qbool foundteamchatsound
Definition client.h:929
cactive_t state
Definition client.h:568
int outfd
Definition sys.h:149
size_t Sys_TimeString(char buf[], size_t bufsize, const char *timeformat)
Definition sys_shared.c:45
void Sys_Print(const char *text, size_t textlen)
(may) output text to terminal which launched program is POSIX async-signal-safe textlen excludes any ...
Definition sys_shared.c:615
sys_t sys
Definition sys_shared.c:42
#define u8_getchar(c, e)
Definition utf8lib.h:71

References bound, ca_dedicated, cl, cls, color, con_chatsound, con_chatsound_file, con_chatsound_team_file, con_chatsound_team_mask, con_initialized, CON_MASK_CHAT, CON_MASK_DEVELOPER, con_mutex, Con_PrintToHistory(), Con_Rcon_AddChar(), developer, client_state_t::foundteamchatsound, i, index, cvar_t::integer, Log_ConPrint(), mask, MAX_INPUTLINE, sys_t::outfd, qfont_table, r_textbrightness, r_textcontrast, rgb, S_LocalSound(), client_static_t::state, cvar_t::string, STRING_COLOR_DEFAULT, STRING_COLOR_RGB_TAG_CHAR, STRING_COLOR_TAG, string_colors, strlen(), sys, sys_colortranslation, Sys_Con_NearestColor(), Sys_Print(), sys_specialcharactertranslation, Sys_TimeString(), Thread_LockMutex, Thread_UnlockMutex, timeformat, timestamps, u8_getchar, cvar_t::value, VectorCopy, and VectorScale.

Referenced by Con_DPrint(), Con_DPrintf(), Con_MaskPrintf(), Con_Print(), and Con_Printf().

◆ Con_MaskPrintf()

void Con_MaskPrintf ( unsigned mask,
const char * fmt,
... )

Definition at line 1487 of file console.c.

1488{
1489 va_list argptr;
1490 char msg[MAX_INPUTLINE];
1491
1492 va_start(argptr,fmt);
1493 dpvsnprintf(msg,sizeof(msg),fmt,argptr);
1494 va_end(argptr);
1495
1496 Con_MaskPrint(mask, msg);
1497}

References Con_MaskPrint(), dpvsnprintf(), mask, and MAX_INPUTLINE.

Referenced by Con_CenterPrint(), and Con_CenterPrintf().

◆ Con_Print()

void Con_Print ( const char * txt)

Prints to all appropriate console targets, and adds timestamps.

Definition at line 1504 of file console.c.

1505{
1507}
#define CON_MASK_PRINT
Definition console.h:110

References CON_MASK_PRINT, and Con_MaskPrint().

Referenced by CDAudio_Startup(), CheckPendingDownloads(), CL_Color_f(), CL_Connect_f(), CL_DrawVideo(), CL_KeepaliveMessage(), CL_NextDemo(), CL_Parse_DumpPacket(), CL_ParseServerInfo(), CL_ParseServerMessage(), CL_PauseDemo_f(), CL_PlayDemo_f(), CL_PlayVideo_f(), CL_Reconnect_f(), CL_Record_f(), CL_Stop_f(), CL_TimeDemo_f(), CL_UpdateScreen(), Cmd_Alias_f(), Cmd_Echo_f(), Cmd_Exec_f(), Cmd_StuffCmds_f(), Cmd_Toggle_f(), Cmd_UnAlias_f(), Collision_ValidateBrush(), Com_HexDumpToConsole(), Con_DisplayList(), Crypto_DecryptPacket(), Crypto_EncryptPacket(), Crypto_HostKey_Clear_f(), Crypto_HostKeys_f(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), CSQC_AddPrintText(), Curl_Curl_f(), Curl_Info_f(), Cvar_Callback(), Cvar_PrintHelp(), Cvar_Readonly(), Cvar_RegisterCallback(), Cvar_SetQuick(), EntityFrame4_AckFrame(), EntityFrame4_CL_ReadFrame(), EntityFrame4_WriteFrame(), EntityFrame_AddFrame_Client(), EntityFrame_AddFrame_Server(), EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadEntityUpdate(), FindViewthing(), font_start(), FS_Inflate(), FS_ListDirectoryCmd(), FS_Path_f(), FS_Rescan(), GetMapList(), GetWavinfo(), GL_Backend_ResetState(), gl_backend_shutdown(), GL_Setup(), GL_TextureMode_f(), hmac_mdfour_challenge_matching(), hmac_mdfour_time_matching(), Image_Compress(), JPEG_SaveImage_preflipped(), JPEG_SaveImage_to_Buffer(), Key_Bind_f(), Key_History_Shutdown(), Key_In_Bind_f(), Key_In_Bindmap_f(), Key_In_Unbind_f(), Key_Unbind_f(), KeyDown(), LHNET_Init(), LHNET_OpenSocket_Connectionless(), LHNET_Read(), LoadConChars_BGRA(), LoadLMP_BGRA(), LoadPCX_BGRA(), LoadSky_f(), LoadTGA_BGRA(), LoadWAL_BGRA(), LoadWAL_GetMetadata(), Mem_PrintList(), MemList_f(), Mod_BSP_RecursiveNodePortals(), Mod_Decompile_f(), Mod_Precache_f(), Mod_Print_f(), Mod_Q1BSP_LoadLeafs(), Mod_Q1BSP_LoadLighting(), Mod_Q1BSP_RecursiveHullCheck(), Mod_Q1BSP_TraceBox(), Mod_Q1BSP_TraceLine(), Mod_Q2BSP_LoadLeafs(), Mod_Q3BSP_LoadFaces(), Mod_ShadowMesh_AddMesh(), Mod_ValidateElements(), MVM_error_cmd(), Net_Heartbeat_f(), Net_Stats_f(), NetConn_CL_UpdateSockets_Callback(), NetConn_SendUnreliableMessage(), NetConn_sv_netport_Callback(), plaintext_matching(), PNG_SaveImage_preflipped(), Portal_Visibility(), PRVM_CallProfile_f(), PRVM_ChildProfile_f(), PRVM_ED_CallSpawnFunction(), PRVM_ED_Count_f(), PRVM_ED_EdictGet_f(), PRVM_ED_EdictSet_f(), PRVM_ED_GlobalGet_f(), PRVM_ED_Print(), PRVM_ED_PrintEdict_f(), PRVM_ED_PrintEdicts_f(), PRVM_Fields_f(), PRVM_Globals_f(), PRVM_LeakTest(), PRVM_PrintStatement(), PRVM_Profile_f(), PRVM_StackTrace(), R_Envmap_f(), R_ListWorldTextures_f(), R_LoadCubemap(), R_Modules_Restart_f(), R_ReplaceWorldTexture_f(), R_Shadow_EditLights_CopyInfo_f(), R_Shadow_EditLights_Edit_f(), R_Shadow_EditLights_EditAll_f(), R_Shadow_EditLights_Help_f(), R_Shadow_EditLights_Lock_f(), R_Shadow_EditLights_PasteInfo_f(), R_Shadow_EditLights_Remove_f(), R_Shadow_EditLights_Spawn_f(), R_Shadow_EditLights_ToggleCorona_f(), R_Shadow_EditLights_ToggleShadow_f(), R_Shadow_LoadLightsFile(), R_Shadow_LoadWorldLights(), R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(), R_Shadow_SaveWorldLights(), R_TextureStats_Print(), S_PauseSound_f(), S_SoundInfo_f(), S_Startup(), S_StaticSound(), SCR_ScreenShot_f(), SndSys_Init(), SV_Begin_f(), SV_BroadcastPrint(), SV_Changelevel_f(), SV_Loadgame_f(), SV_Map_f(), SV_MaxPlayers_f(), SV_PreSpawn_f(), SV_ReadClientMessage(), SV_Restart_f(), SV_SaveEntFile_f(), SV_Savegame_f(), SV_Savegame_to(), SV_Say(), SV_Spawn_f(), SV_StartDemoRecording(), SV_Tell_f(), Sys_SDL_HandleEvents(), SZ_GetSpace(), VID_Restart_f(), VID_SetMouse(), VID_Start(), VM_print(), VM_SV_clientcommand(), VM_SV_setcolor(), VM_SV_setspawnparms(), VM_SV_sprint(), W_GetLumpName(), W_GetTextureBGRA(), and W_LoadTextureWadFile().

◆ Con_Printf()

void Con_Printf ( const char * fmt,
... )

Prints to all appropriate console targets.

Definition at line 1514 of file console.c.

1515{
1516 va_list argptr;
1517 char msg[MAX_INPUTLINE];
1518
1519 va_start(argptr,fmt);
1520 dpvsnprintf(msg,sizeof(msg),fmt,argptr);
1521 va_end(argptr);
1522
1524}

References CON_MASK_PRINT, Con_MaskPrint(), dpvsnprintf(), and MAX_INPUTLINE.

Referenced by AnglesFromVectors(), Cbuf_AddText(), Cbuf_Execute(), Cbuf_InsertText(), CD_f(), CheckPendingDownloads(), CL_BeginDownloads(), CL_BeginDownloads_f(), CL_Cache_TraceLineSurfaces(), CL_ClearTempEntities(), CL_Color_f(), CL_DisconnectEx(), CL_DownloadBegin_f(), CL_DownloadFinished_f(), CL_Effect(), CL_EstablishConnection(), CL_ExaminePrintString(), CL_FinishTimeDemo(), CL_Fog_f(), CL_Fog_HeightTexture_f(), CL_ForwardToServer(), CL_Frame(), CL_FullInfo_f(), CL_FullServerinfo_f(), CL_Init(), CL_IPLog_List_f(), CL_IPLog_Load(), CL_LinkEdict(), CL_Locs_Add_f(), CL_Locs_FreeNode(), CL_Locs_Reload_f(), CL_Locs_RemoveNearest_f(), CL_Locs_Save_f(), CL_ModelIndexList_f(), CL_Name_f(), CL_NewBeam(), CL_NewFrameReceived(), CL_OpenVideo(), CL_Packet_f(), CL_ParseBeam(), CL_ParseDownload(), CL_ParseServerInfo(), CL_ParseServerMessage(), CL_ParseStartSoundPacket(), CL_ParseStaticSound(), CL_ParticleRain(), CL_Particles_ParseEffectInfo(), CL_PlayDemo(), CL_PQRcon_f(), CL_PrintEntities_f(), CL_Rcon_f(), CL_ReadPointFile_f(), CL_Reconnect_f(), CL_Record_f(), CL_SendMove(), CL_SetInfo(), CL_SetInfo_f(), CL_SoundIndexList_f(), CL_Startdemos_f(), CL_StopDownload(), CL_StopDownload_f(), CL_TimeRefresh_f(), CL_TraceBox(), CL_TraceLine(), CL_TracePoint(), CL_User_f(), CL_Users_f(), CL_VM_Init(), CLVM_count_edicts(), Cmd_AddCommand(), Cmd_Alias_f(), Cmd_Apropos_f(), Cmd_Callback(), Cmd_CheckParm(), Cmd_CL_Callback(), Cmd_CompleteAliasPrint(), Cmd_CompleteCommandPrint(), Cmd_CompleteNicksPrint(), Cmd_Defer_f(), Cmd_Echo_f(), Cmd_Exec(), Cmd_Exec_f(), Cmd_ExecuteString(), Cmd_GetCvarValue(), Cmd_List_f(), Cmd_Toggle_f(), Cmd_TokenizeString(), Cmd_UnAlias_f(), Collision_ClipLineToGenericEntity(), Collision_ClipPointToGenericEntity(), Collision_ClipToGenericEntity(), Collision_ClipTrace_Box(), Collision_PrintBrushAsQHull(), Collision_ValidateBrush(), COM_ChangeGameTypeForGameDirs(), Con_CenterPrintf(), Con_CompleteCommandLine(), Con_ConDump_f(), Con_Maps_f(), Crypto_DecryptPacket(), Crypto_EncryptPacket(), Crypto_FinishInstance(), Crypto_HostKey_Clear_f(), Crypto_HostKeys_f(), Crypto_Init(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_ServerParsePacket(), Crypto_StoreHostKey(), Curl_Begin(), Curl_Curl_f(), Curl_EndDownload(), Curl_Info_f(), Curl_Select(), Curl_SendRequirements(), Cvar_Del_f(), Cvar_Delete(), Cvar_Get(), Cvar_List_f(), Cvar_PrintHelp(), Cvar_Readonly(), Cvar_RegisterVariable(), Cvar_RegisterVirtual(), Cvar_Set(), Cvar_Set_f(), Cvar_SetA_f(), Cvar_SetQuick(), decode_image(), dp__strlcpy(), dp_stpecpy(), dp_ustr2stp(), em_savefs_f(), EntityFrame4_AckFrame(), EntityFrame4_CL_ReadFrame(), EntityFrame4_WriteFrame(), EntityFrame5_CL_ReadFrame(), EntityFrame5_WriteFrame(), EntityFrame_CL_ReadFrame(), EntityFrameCSQC_DeallocFrame(), EntityFrameCSQC_LostFrame(), EntityFrameQW_CL_ReadFrame(), EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadEntityUpdate(), FindFont(), Font_GetKerningForMap(), Font_LoadFile(), Font_LoadFont(), Font_LoadMap(), Font_LoadSize(), Font_SearchSize(), fractalnoise(), fractalnoisequick(), FS_AddFileToPack(), FS_AddPack(), FS_AddPack_Fullpath(), FS_Deflate(), FS_GameDir_f(), FS_Inflate(), FS_ListDirectory(), FS_ListDirectoryCmd(), FS_LoadAndCloseQFile(), FS_LoadPackPAK(), FS_LoadPackPK3FromFD(), FS_OpenPackedFile(), FS_OpenReadFile(), FS_OpenRealFile(), FS_OpenVirtualFile(), FS_Path_f(), FS_Read(), FS_Search(), FS_Seek(), FS_SetGameDirs(), FS_SysOpenFiledesc(), FS_Which_f(), FS_Write(), FS_WriteFileInBlocks(), GetMapList(), GetWavinfo(), GL_Backend_CompileShader(), gl_backend_start(), GL_DebugOutputCallback(), GL_Mesh_ListVBOs(), GL_Setup(), GL_TextureMode_f(), Host_Error(), Host_Init(), Host_LockSession(), Host_Quit_f(), Host_SaveConfig(), Host_Version_f(), Image_Compress(), Image_FixTransparentPixels_f(), Image_MipReduce32(), Image_Resample32(), IN_BestWeapon_f(), IN_BestWeapon_Register(), IN_BestWeapon_Register_f(), InfoString_GetValue(), InfoString_Print(), InfoString_SetValue(), jam_video(), JPEG_LoadImage_BGRA(), JPEG_OpenLibrary(), JPEG_SaveImage_to_Buffer(), Key_Bind_f(), Key_Event(), Key_History_f(), Key_History_Find_All(), Key_History_Find_Backwards(), Key_History_Find_Forwards(), Key_History_Push(), Key_In_Bind_f(), Key_In_BindList_f(), Key_In_Bindmap_f(), Key_In_Unbind_f(), Key_Parse_CommonKeys(), Key_PrintBindList(), Key_Unbind_f(), LHNET_OpenSocket_Connectionless(), LHNETADDRESS_FromString(), LibAV_LoadLibrary(), libavw_decodeframe(), libavw_message(), LibAvW_OpenLibrary(), LoadConChars_BGRA(), LoadFont_f(), loadimagepixelsbgra(), LoadLMP_BGRA(), LoadPCX_BGRA(), LoadSky_f(), LoadSubtitles(), LoadTGA_BGRA(), LoadWAL_BGRA(), Matrix4x4_Print(), Mem_PrintList(), Mem_PrintStats(), Mod_AliasInit(), Mod_BSP_DecompressVis(), Mod_BuildVBOs(), Mod_DARKPLACESMODEL_Load(), Mod_Decompile_OBJ(), Mod_Decompile_SMD(), Mod_FrameGroupify(), Mod_FrameGroupify_ParseGroups(), Mod_GenerateLightmaps_CreateLightmaps(), Mod_GenerateLightmaps_f(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDS2_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_LoadModel(), Mod_LoadQ3Shaders(), Mod_LoadSkinFiles(), Mod_LoadTextureFromQ3Shader(), Mod_MDL_LoadFrames(), Mod_Print_f(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q1BSP_LoadEdges(), Mod_Q1BSP_LoadLeafs(), Mod_Q1BSP_LoadLighting(), Mod_Q1BSP_LoadMapBrushes(), Mod_Q1BSP_LoadNodes(), Mod_Q1BSP_LoadTexinfo(), Mod_Q1BSP_LoadTextures(), Mod_Q1BSP_TraceBox(), Mod_Q1BSP_TraceLine(), Mod_Q2BSP_Load(), Mod_Q2BSP_LoadLeafs(), Mod_Q2BSP_LoadNodes(), Mod_Q2BSP_LoadTexinfo(), Mod_Q3BSP_LoadEffects(), Mod_Q3BSP_LoadEntities(), Mod_Q3BSP_LoadFaces(), Mod_Q3BSP_LoadLightGrid(), Mod_Q3BSP_LoadLightmaps(), Mod_Q3BSP_LoadTriangles(), Mod_UnloadModel(), Mod_ValidateElements(), Mod_VBSP_LoadEdges(), Mod_VBSP_LoadTexinfo(), Mod_VBSP_LoadTextures(), Mod_ZYMOTICMODEL_Load(), ModList_Enable(), MVM_count_edicts(), MVM_error_cmd(), NetConn_ClientFrame(), NetConn_ClientParsePacket(), NetConn_ConnectionEstablished(), NetConn_Init(), NetConn_OpenClientPort(), NetConn_OpenClientPorts(), NetConn_OpenServerPort(), NetConn_Read(), NetConn_ReceivedMessage(), NetConn_SendUnreliableMessage(), NetConn_ServerParsePacket(), NetConn_UpdateSockets(), NetConn_Write(), OGG_LoadVorbisFile(), OpenStream(), PHYS_TestEntityPosition(), PK3_GetTrueFileOffset(), PNG_error_fn(), PNG_fReadData(), PNG_LoadImage_BGRA(), PNG_warning_fn(), Portal_CheckPolygon(), Portal_Visibility(), PrintFrameName(), PrintStats(), PrintTargaHeader(), PRVM_Breakpoint(), PRVM_Breakpoint_f(), PRVM_CallProfile(), PRVM_ChildProfile_f(), PRVM_Crash(), PRVM_ED_EdictGet_f(), PRVM_ED_EdictSet_f(), PRVM_ED_GlobalGet_f(), PRVM_ED_ParseEdict(), PRVM_ED_ParseEpair(), PRVM_ED_ParseGlobals(), PRVM_ED_Print(), PRVM_ED_PrintEdicts_f(), PRVM_ED_Write(), PRVM_ED_WriteGlobals(), PRVM_EdictWatchpoint_f(), PRVM_ExplicitCoverageEvent(), PRVM_Fields_f(), PRVM_FriendlyProgFromString(), PRVM_FunctionCoverageEvent(), PRVM_GameCommand(), PRVM_Global_f(), PRVM_Globals_f(), PRVM_GlobalSet_f(), PRVM_GlobalWatchpoint_f(), PRVM_LeakTest(), PRVM_MarkReferencedEdicts(), PRVM_PrintFunction_f(), PRVM_PrintFunctionStatements(), PRVM_PrintState(), PRVM_PrintStatement(), PRVM_Profile(), PRVM_Profile_f(), PRVM_Prog_Load(), PRVM_StackTrace(), PRVM_StatementCoverageEvent(), PRVM_UpdateBreakpoints(), QW_CL_Changing_f(), QW_CL_CheckOrDownloadFile(), QW_CL_NextUpload_f(), QW_CL_ParseDownload(), QW_CL_RequestNextDownload(), QW_CL_SetInfo(), QW_CL_UpdateUserInfo(), R_Envmap_f(), R_GLSL_CompilePermutation(), R_GLSL_DumpShader_f(), R_InitParticleTexture(), R_ListWorldTextures_f(), R_LoadCubemap(), R_LoadQWSkin(), R_LoadSkyBox(), R_LoadTextureDDSFile(), R_Mesh_CreateFramebufferObject(), R_Mesh_Draw(), R_Mesh_Start(), R_Model_Sprite_Draw_TransparentCallback(), R_Modules_Start(), R_RegisterModule(), R_ReplaceWorldTexture_f(), R_SetSkyBox(), R_SetupTexture(), R_Shadow_ComputeShadowCasterCullingPlanes(), R_Shadow_EditLights_Edit_f(), R_Shadow_LoadLightsFile(), R_Shadow_LoadWorldLights(), R_Shadow_RenderLighting(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), R_SkinFrame_LoadInternalQuake(), R_SkinFrame_LoadInternalUsingTexture(), R_TextureStats_Print(), R_UnloadSkyBox(), R_Viewport_InitOrtho(), R_Water_ProcessPlanes(), RCon_Execute(), S_FindName(), S_FreeSfx(), S_LoadSound(), S_LoadWavFile(), S_LocalSoundEx(), S_PaintAndSubmit(), S_PlaySfxOnChannel(), S_Restart_f(), S_SetChannelLayout(), S_SoundInfo_f(), S_SoundList_f(), S_Startup(), S_StaticSound(), S_UnloadAllSounds_f(), S_Update(), SCR_CaptureVideo_Avi_BeginVideo(), SCR_CaptureVideo_Ogg_BeginVideo(), SCR_CaptureVideo_RIFF_Pop(), SCR_InfoBar_f(), SCR_ScreenShot_f(), SndSys_Init(), SV_Begin_f(), SV_CanSeeBox(), SV_CheckVelocity(), SV_ConnectClient(), SV_DropClient(), SV_Ent_Create_f(), SV_Ent_Remove_All_f(), SV_Ent_Remove_f(), SV_ExecuteClientMoves(), SV_FlyMove(), SV_Impact(), SV_LinkEdict(), SV_LinkEdict_TouchAreaGrid(), SV_Loadgame_f(), SV_MaxPlayers_f(), SV_ModelIndex(), SV_ParticleEffectIndex(), SV_Pause_f(), SV_Physics_ClientEntity(), SV_Physics_ClientEntity_NoThink(), SV_Physics_Entity(), SV_Ping_f(), SV_PointSuperContents(), SV_PushEntity(), SV_PushMove(), SV_ReadClientMessage(), SV_ReadClientMove(), SV_Savegame_to(), SV_ServerOptions(), SV_SoundIndex(), SV_Spawn_f(), SV_SpawnServer(), SV_StartDemoRecording(), SV_StartPointSound(), SV_StartSound(), SV_Status_f(), SV_StopDemoRecording(), SV_TraceBox(), SV_TraceLine(), SV_TracePoint(), SV_UnstickEntity(), SV_Viewmodel_f(), SV_WriteEntitiesToClient(), SVVM_count_edicts(), Sys_DirtyTime(), Sys_Error(), Sys_LoadDependency(), Sys_SDL_HandleEvents(), Sys_Sleep(), Sys_UpdateTime(), testmul128(), Thread_Init(), V_BonusFlash_f(), VID_ApplyDisplayMode(), VID_ApplyJoyState(), VID_EnableJoystick(), VID_Init(), VID_InitModeGL(), VID_Mode(), VID_Restart_f(), VID_SetVsync_c(), VID_Shared_SetJoystick(), VM_CL_effect(), VM_CL_findbox(), VM_CL_findradius(), VM_CL_makestatic(), VM_error(), VM_GetFileHandle(), VM_objerror(), VM_SV_findbox(), VM_SV_findradius(), VM_Warning(), W_LoadTextureWadFile(), World_LinkEdict_AreaGrid(), World_PrintAreaStats(), XMP_LoadModFile(), and XMP_OpenLibrary().

◆ Con_Quakebar()

const char * Con_Quakebar ( int len,
char * bar,
size_t barsize )

Returns a horizontal line.

Returns a graphical horizontal line of length len, but never wider than the console. Includes a newline, unless len is >= to the console width

Note
Authored by johnfitz
Parameters
[in]lenLength of the horizontal line
Returns
A string of the line

Definition at line 1570 of file console.c.

1571{
1572 assert(barsize >= 5);
1573
1574 len = min(len, (int)barsize - 2);
1575 len = min(len, con_linewidth);
1576
1577 bar[0] = '\35';
1578 memset(&bar[1], '\36', len - 2);
1579 bar[len - 1] = '\37';
1580
1581 if (len < con_linewidth)
1582 {
1583 bar[len] = '\n';
1584 bar[len + 1] = 0;
1585 }
1586 else
1587 bar[len] = 0;
1588
1589 return bar;
1590}

References con_linewidth, and min.

Referenced by Con_CenterPrint().

◆ Con_Rcon_Redirect_Abort()

void Con_Rcon_Redirect_Abort ( void )

Definition at line 1048 of file console.c.

1049{
1052}
lhnetaddress_t * rcon_redirect_dest
Definition console.c:101
lhnetsocket_t * rcon_redirect_sock
Definition console.c:100

References NULL, rcon_redirect_dest, and rcon_redirect_sock.

Referenced by Host_Error().

◆ Con_Rcon_Redirect_End()

void Con_Rcon_Redirect_End ( void )

Definition at line 1041 of file console.c.

1042{
1046}
static void Con_Rcon_Redirect_Flush(void)
Definition console.c:1024

References Con_Rcon_Redirect_Flush(), NULL, rcon_redirect_dest, and rcon_redirect_sock.

Referenced by RCon_Execute().

◆ Con_Rcon_Redirect_Init()

void Con_Rcon_Redirect_Init ( lhnetsocket_t * sock,
lhnetaddress_t * dest,
qbool proquakeprotocol )

Definition at line 1004 of file console.c.

1005{
1006 rcon_redirect_sock = sock;
1007 rcon_redirect_dest = dest;
1008 rcon_redirect_proquakeprotocol = proquakeprotocol;
1010 {
1011 // reserve space for the packet header
1012 rcon_redirect_buffer[0] = 0;
1013 rcon_redirect_buffer[1] = 0;
1014 rcon_redirect_buffer[2] = 0;
1015 rcon_redirect_buffer[3] = 0;
1016 // this is a reply to a CCREQ_RCON
1017 rcon_redirect_buffer[4] = (unsigned char)CCREP_RCON;
1018 }
1019 else
1020 memcpy(rcon_redirect_buffer, "\377\377\377\377n", 5); // QW rcon print
1022}
int rcon_redirect_bufferpos
Definition console.c:102
char rcon_redirect_buffer[1400]
Definition console.c:103
qbool rcon_redirect_proquakeprotocol
Definition console.c:104
#define CCREP_RCON
Definition netconn.h:130

References CCREP_RCON, rcon_redirect_buffer, rcon_redirect_bufferpos, rcon_redirect_dest, rcon_redirect_proquakeprotocol, and rcon_redirect_sock.

Referenced by RCon_Execute().

◆ Con_Shutdown()

void Con_Shutdown ( void )

Definition at line 941 of file console.c.

942{
947 con_mutex = NULL;
948}
void ConBuffer_Shutdown(conbuffer_t *buf)
Definition console.c:222
#define Thread_DestroyMutex(m)
Definition thread.h:16

References con, con_mutex, ConBuffer_Shutdown(), NULL, Thread_DestroyMutex, Thread_LockMutex, and Thread_UnlockMutex.

Referenced by Host_Shutdown().

◆ Con_ToggleConsole_f()

void Con_ToggleConsole_f ( cmd_state_t * cmd)

Definition at line 686 of file console.c.

687{
688 if (Sys_CheckParm ("-noconsole"))
690 return; // only allow the key bind to turn off console
691
692 // toggle the 'user wants console' bit
695}
int key_consoleactive
Definition keys.c:38
#define KEY_CONSOLEACTIVE_USER
Definition keys.h:380

References Con_ClearNotify(), key_consoleactive, KEY_CONSOLEACTIVE_USER, and Sys_CheckParm().

Referenced by Con_Init(), IN_Move_TouchScreen_Quake(), Key_Event(), M_Main_Key(), and M_Options_Key().

◆ ConBuffer_AddLine()

void ConBuffer_AddLine ( conbuffer_t * buf,
const char * line,
int len,
unsigned mask )

Appends a given string as a new line to the console.

Definition at line 332 of file console.c.

333{
334 char *putpos;
336
337 // developer_memory 1 during shutdown prints while conbuffer_t is being freed
338 if (!buf->active)
339 return;
340
342
343 if(len >= buf->textsize)
344 {
345 // line too large?
346 // only display end of line.
347 line += len - buf->textsize + 1;
348 len = buf->textsize - 1;
349 }
350 while(!(putpos = ConBuffer_BytesLeft(buf, len + 1)) || buf->lines_count >= buf->maxlines)
352 memcpy(putpos, line, len);
353 putpos[len] = 0;
354 ++buf->lines_count;
355
356 //fprintf(stderr, "Now have %d lines (%d -> %d).\n", buf->lines_count, buf->lines_first, CON_LINES_LAST);
357
359 p->start = putpos;
360 p->len = len;
361 p->addtime = cl.time;
362 p->mask = mask;
363 p->height = -1; // calculate when needed
364}
void ConBuffer_DeleteLine(conbuffer_t *buf)
Deletes the first line from the console history.
Definition console.c:263
static char * ConBuffer_BytesLeft(conbuffer_t *buf, int len)
Definition console.c:293
#define CONBUFFER_LINES_LAST(buf)
Definition console.h:138
double time
Definition client.h:868
unsigned mask
Definition console.h:116
double addtime
used only by console.c
Definition console.h:119
char * start
Definition console.h:114
int height
recalculated line height when needed (-1 to unset)
Definition console.h:120

References con_lineinfo_t::addtime, buf, cl, ConBuffer_BytesLeft(), ConBuffer_DeleteLine(), ConBuffer_FixTimes(), CONBUFFER_LINES_LAST, con_lineinfo_t::height, con_lineinfo_t::len, con_lineinfo_t::mask, mask, con_lineinfo_t::start, and client_state_t::time.

Referenced by Con_PrintToHistory(), Key_History_Init(), and Key_History_Push().

◆ ConBuffer_Clear()

void ConBuffer_Clear ( conbuffer_t * buf)

Definition at line 212 of file console.c.

213{
214 buf->lines_count = 0;
215}

References buf.

Referenced by Con_Clear_f(), and Key_History_f().

◆ ConBuffer_DeleteLastLine()

void ConBuffer_DeleteLastLine ( conbuffer_t * buf)

Deletes the last line from the console history.

Definition at line 278 of file console.c.

279{
280 if(buf->lines_count == 0)
281 return;
282 --buf->lines_count;
283}

References buf.

Referenced by Con_PrintToHistory().

◆ ConBuffer_DeleteLine()

void ConBuffer_DeleteLine ( conbuffer_t * buf)

Deletes the first line from the console history.

Definition at line 263 of file console.c.

264{
265 if(buf->lines_count == 0)
266 return;
267 --buf->lines_count;
268 buf->lines_first = (buf->lines_first + 1) % buf->maxlines;
269}

References buf.

Referenced by ConBuffer_AddLine().

◆ ConBuffer_FindNextLine()

int ConBuffer_FindNextLine ( conbuffer_t * buf,
unsigned mask_must,
unsigned mask_mustnot,
int start )

◆ ConBuffer_FindPrevLine()

int ConBuffer_FindPrevLine ( conbuffer_t * buf,
unsigned mask_must,
unsigned mask_mustnot,
int start )

Definition at line 366 of file console.c.

367{
368 int i;
369 if(start == -1)
370 start = buf->lines_count;
371 for(i = start - 1; i >= 0; --i)
372 {
374
375 if((l->mask & mask_must) != mask_must)
376 continue;
377 if(l->mask & mask_mustnot)
378 continue;
379
380 return i;
381 }
382
383 return -1;
384}

References buf, CONBUFFER_LINES, i, and con_lineinfo_t::mask.

◆ ConBuffer_FixTimes()

void ConBuffer_FixTimes ( conbuffer_t * buf)

Notifies the console code about the current time (and shifts back times of other entries when the time went backwards)

Definition at line 242 of file console.c.

243{
244 int i;
245 if(buf->lines_count >= 1)
246 {
247 double diff = cl.time - CONBUFFER_LINES_LAST(buf).addtime;
248 if(diff < 0)
249 {
250 for(i = 0; i < buf->lines_count; ++i)
251 CONBUFFER_LINES(buf, i).addtime += diff;
252 }
253 }
254}

References buf, cl, CONBUFFER_LINES, CONBUFFER_LINES_LAST, i, and client_state_t::time.

Referenced by Con_DrawNotify(), and ConBuffer_AddLine().

◆ ConBuffer_GetLine()

const char * ConBuffer_GetLine ( conbuffer_t * buf,
int i )

◆ ConBuffer_Init()

void ConBuffer_Init ( conbuffer_t * buf,
int textsize,
int maxlines,
mempool_t * mempool )

Definition at line 108 of file console.c.

109{
110 buf->active = true;
111 buf->textsize = textsize;
112 buf->text = (char *) Mem_Alloc(mempool, textsize);
113 buf->maxlines = maxlines;
114 buf->lines = (con_lineinfo_t *) Mem_Alloc(mempool, maxlines * sizeof(*buf->lines));
115 buf->lines_first = 0;
116 buf->lines_count = 0;
117}

References buf, and Mem_Alloc.

Referenced by Con_Init(), and Key_History_Init().

◆ ConBuffer_Shutdown()

void ConBuffer_Shutdown ( conbuffer_t * buf)

Definition at line 222 of file console.c.

223{
224 buf->active = false;
225 if (buf->text)
226 Mem_Free(buf->text);
227 if (buf->lines)
228 Mem_Free(buf->lines);
229 buf->text = NULL;
230 buf->lines = NULL;
231}

References buf, Mem_Free, and NULL.

Referenced by Con_Shutdown(), and Key_History_Shutdown().

◆ GetMapList()

qbool GetMapList ( const char * s,
char * completedname,
int completednamebufferlength )

Definition at line 2275 of file console.c.

2276{
2277 fssearch_t *t;
2278 char message[1024];
2279 int i, k, max, p, o, min;
2280 unsigned char *len;
2281 qfile_t *f;
2282 unsigned char buf[1024];
2283
2284 dpsnprintf(message, sizeof(message), "maps/%s*.bsp", s);
2285 t = FS_Search(message, 1, true, NULL);
2286 if(!t)
2287 return false;
2288 if (t->numfilenames > 1)
2289 Con_Printf("^1 %i maps found :\n", t->numfilenames);
2290 len = (unsigned char *)Z_Malloc(t->numfilenames);
2291 min = 666;
2292 for(max=i=0;i<t->numfilenames;i++)
2293 {
2294 k = (int)strlen(t->filenames[i]);
2295 k -= 9;
2296 if(max < k)
2297 max = k;
2298 else
2299 if(min > k)
2300 min = k;
2301 len[i] = k;
2302 }
2303 o = (int)strlen(s);
2304 for(i=0;i<t->numfilenames;i++)
2305 {
2306 int lumpofs = 0, lumplen = 0;
2307 char *entities = NULL;
2308 const char *data = NULL;
2309 char keyname[64];
2310 char entfilename[MAX_QPATH];
2311 char desc[64];
2312 desc[0] = 0;
2313 dp_strlcpy(message, "^1ERROR: open failed^7", sizeof(message));
2314 p = 0;
2315 f = FS_OpenVirtualFile(t->filenames[i], true);
2316 if(f)
2317 {
2318 dp_strlcpy(message, "^1ERROR: not a known map format^7", sizeof(message));
2319 memset(buf, 0, 1024);
2320 FS_Read(f, buf, 1024);
2321 if (!memcmp(buf, "IBSP", 4))
2322 {
2323 p = LittleLong(((int *)buf)[1]);
2324 if (p == Q3BSPVERSION || p == Q3BSPVERSION_LIVE || p == Q3BSPVERSION_IG)
2325 {
2326 q3dheader_t *header = (q3dheader_t *)buf;
2327 lumpofs = LittleLong(header->lumps[Q3LUMP_ENTITIES].fileofs);
2328 lumplen = LittleLong(header->lumps[Q3LUMP_ENTITIES].filelen);
2329 dpsnprintf(desc, sizeof(desc), "Q3BSP%i", p);
2330 }
2331 else if (p == Q2BSPVERSION)
2332 {
2333 q2dheader_t *header = (q2dheader_t *)buf;
2334 lumpofs = LittleLong(header->lumps[Q2LUMP_ENTITIES].fileofs);
2335 lumplen = LittleLong(header->lumps[Q2LUMP_ENTITIES].filelen);
2336 dpsnprintf(desc, sizeof(desc), "Q2BSP%i", p);
2337 }
2338 else
2339 dpsnprintf(desc, sizeof(desc), "IBSP%i", p);
2340 }
2341 else if (BuffLittleLong(buf) == BSPVERSION)
2342 {
2343 lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
2344 lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
2345 dpsnprintf(desc, sizeof(desc), "BSP29");
2346 }
2347 else if (BuffLittleLong(buf) == 30)
2348 {
2349 lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
2350 lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
2351 dpsnprintf(desc, sizeof(desc), "BSPHL");
2352 }
2353 else if (!memcmp(buf, "BSP2", 4))
2354 {
2355 lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
2356 lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
2357 dpsnprintf(desc, sizeof(desc), "BSP2");
2358 }
2359 else if (!memcmp(buf, "2PSB", 4))
2360 {
2361 lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
2362 lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
2363 dpsnprintf(desc, sizeof(desc), "BSP2RMQe");
2364 }
2365 else if(!memcmp(buf, "VBSP", 4))
2366 {
2367 hl2dheader_t *header = (hl2dheader_t *)buf;
2368 lumpofs = LittleLong(header->lumps[HL2LUMP_ENTITIES].fileofs);
2369 lumplen = LittleLong(header->lumps[HL2LUMP_ENTITIES].filelen);
2370 dpsnprintf(desc, sizeof(desc), "VBSP%i", LittleLong(((int *)buf)[1]));
2371 }
2372 else
2373 dpsnprintf(desc, sizeof(desc), "unknown%i", BuffLittleLong(buf));
2374 dp_strlcpy(entfilename, t->filenames[i], sizeof(entfilename));
2375 memcpy(entfilename + strlen(entfilename) - 4, ".ent", 5);
2376 entities = (char *)FS_LoadFile(entfilename, tempmempool, true, NULL);
2377 if (!entities && lumplen >= 10)
2378 {
2379 FS_Seek(f, lumpofs, SEEK_SET);
2380 entities = (char *)Z_Malloc(lumplen + 1);
2381 FS_Read(f, entities, lumplen);
2382 }
2383 if (entities)
2384 {
2385 // if there are entities to parse, a missing message key just
2386 // means there is no title, so clear the message string now
2387 message[0] = 0;
2388 data = entities;
2389 for (;;)
2390 {
2391 int l;
2392 if (!COM_ParseToken_Simple(&data, false, false, true))
2393 break;
2394 if (com_token[0] == '{')
2395 continue;
2396 if (com_token[0] == '}')
2397 break;
2398 // skip leading whitespace
2399 for (k = 0;com_token[k] && ISWHITESPACE(com_token[k]);k++);
2400 for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && !ISWHITESPACE(com_token[k+l]);l++)
2401 keyname[l] = com_token[k+l];
2402 keyname[l] = 0;
2403 if (!COM_ParseToken_Simple(&data, false, false, true))
2404 break;
2406 Con_DPrintf("key: %s %s\n", keyname, com_token);
2407 if (!strcmp(keyname, "message"))
2408 {
2409 // get the message contents
2411 break;
2412 }
2413 }
2414 }
2415 }
2416 if (entities)
2417 Z_Free(entities);
2418 if(f)
2419 FS_Close(f);
2420 *(t->filenames[i]+len[i]+5) = 0;
2421 Con_Printf("%16s (%-8s) %s\n", t->filenames[i]+5, desc, message);
2422 }
2423 Con_Print("\n");
2424 for(p=o;p<min;p++)
2425 {
2426 k = *(t->filenames[0]+5+p);
2427 if(k == 0)
2428 goto endcomplete;
2429 for(i=1;i<t->numfilenames;i++)
2430 if(*(t->filenames[i]+5+p) != k)
2431 goto endcomplete;
2432 }
2433endcomplete:
2434 if(p > o && completedname && completednamebufferlength > 0)
2435 {
2436 memset(completedname, 0, completednamebufferlength);
2437 memcpy(completedname, (t->filenames[0]+5), min(p, completednamebufferlength - 1));
2438 }
2439 Z_Free(len);
2440 FS_FreeSearch(t);
2441 return p > o;
2442}
#define BSPVERSION
Definition bspfile.h:29
#define LUMP_ENTITIES
Definition bspfile.h:39
int BuffLittleLong(const unsigned char *buffer)
Extract a little endian 32bit int from the given buffer.
Definition com_msg.c:71
#define LittleLong(l)
Definition common.h:92
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
fs_offset_t FS_Read(qfile_t *file, void *buffer, size_t buffersize)
Definition fs.c:3066
qfile_t * FS_OpenVirtualFile(const char *filepath, qbool quiet)
Definition fs.c:2928
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3540
int FS_Seek(qfile_t *file, fs_offset_t offset, int whence)
Definition fs.c:3359
int FS_Close(qfile_t *file)
Definition fs.c:2970
GLsizeiptr const GLvoid * data
Definition glquake.h:639
cvar_t developer_extra
Definition host.c:49
#define max(A, B)
Definition mathlib.h:38
#define Q2LUMP_ENTITIES
Definition model_q2bsp.h:14
#define Q2BSPVERSION
Definition model_q2bsp.h:7
#define Q3BSPVERSION_IG
Definition model_q3bsp.h:13
#define Q3BSPVERSION_LIVE
Definition model_q3bsp.h:12
#define Q3LUMP_ENTITIES
Definition model_q3bsp.h:15
#define Q3BSPVERSION
Definition model_q3bsp.h:11
#define HL2LUMP_ENTITIES
Definition model_vbsp.h:74
string message
Definition progsdefs.qc:205
#define ISWHITESPACE(ch)
Definition qdefs.h:184
hl2lump_t lumps[HL2HEADER_LUMPS]
Definition model_vbsp.h:159
int32_t filelen
Definition model_vbsp.h:150
int32_t fileofs
Definition model_vbsp.h:150
int fileofs
Definition bspfile.h:36
int filelen
Definition bspfile.h:36
lump_t lumps[Q2HEADER_LUMPS]
Definition model_q2bsp.h:39
lump_t lumps[Q3HEADER_LUMPS_MAX]
Definition model_q3bsp.h:41
#define Z_Malloc(size)
Definition zone.h:161
#define Z_Free(data)
Definition zone.h:164

References BSPVERSION, buf, BuffLittleLong(), COM_ParseToken_Simple(), com_token, Con_DPrintf(), Con_Print(), Con_Printf(), data, developer_extra, dp_strlcpy, dpsnprintf(), f, hl2lump_t::filelen, lump_t::filelen, fssearch_t::filenames, hl2lump_t::fileofs, lump_t::fileofs, FS_Close(), FS_FreeSearch(), FS_LoadFile(), FS_OpenVirtualFile(), FS_Read(), FS_Search(), FS_Seek(), HL2LUMP_ENTITIES, i, int(), cvar_t::integer, ISWHITESPACE, LittleLong, LUMP_ENTITIES, hl2dheader_t::lumps, q2dheader_t::lumps, q3dheader_t::lumps, max, MAX_QPATH, message, min, NULL, fssearch_t::numfilenames, Q2BSPVERSION, Q2LUMP_ENTITIES, Q3BSPVERSION, Q3BSPVERSION_IG, Q3BSPVERSION_LIVE, Q3LUMP_ENTITIES, strlen(), tempmempool, Z_Free, and Z_Malloc.

Referenced by Con_CompleteCommandLine(), and Con_Maps_f().

◆ Log_Close()

void Log_Close ( void )

Definition at line 521 of file console.c.

522{
523 qfile_t* l = logfile;
524
525 if (l == NULL)
526 return;
527
528 FS_Print (l, Log_Timestamp ("Log stopped"));
529 FS_Print (l, "\n");
530 logfile = NULL;
531 FS_Close (l);
532
533 crt_log_file[0] = '\0';
534}
qfile_t * logfile
Definition console.c:412
char crt_log_file[MAX_OSPATH]
Definition console.c:411
static const char * Log_Timestamp(const char *desc)
Definition console.c:474
int FS_Print(qfile_t *file, const char *msg)
Definition fs.c:3261

References crt_log_file, FS_Close(), FS_Print(), Log_Timestamp(), logfile, and NULL.

Referenced by Host_Shutdown(), and Log_ConPrint().

◆ Log_DestBuffer_Flush()

void Log_DestBuffer_Flush ( void )

call this once per frame to send out replies to rcon streaming clients

Definition at line 465 of file console.c.

466{
467 if (con_mutex)
470 if (con_mutex)
472}
static void Log_DestBuffer_Flush_NoLock(void)
Definition console.c:426

References con_mutex, Log_DestBuffer_Flush_NoLock(), Thread_LockMutex, and Thread_UnlockMutex.

Referenced by Host_Frame().

◆ Log_Init()

void Log_Init ( void )

◆ Log_Printf()

void Log_Printf ( const char * logfilename,
const char * fmt,
... )

Definition at line 655 of file console.c.

656{
657 qfile_t *file;
658
659 file = FS_OpenRealFile(logfilename, "a", true);
660 if (file != NULL)
661 {
662 va_list argptr;
663
664 va_start (argptr, fmt);
665 FS_VPrintf (file, fmt, argptr);
666 va_end (argptr);
667
668 FS_Close (file);
669 }
670}
int FS_VPrintf(qfile_t *file, const char *format, va_list ap)
Definition fs.c:3293
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
Definition fs.c:2901

References FS_Close(), FS_OpenRealFile(), FS_VPrintf(), and NULL.

Referenced by CL_FinishTimeDemo(), CL_IPLog_Add(), loadimagepixelsbgra(), and R_LoadTextureDDSFile().

◆ Log_Start()

void Log_Start ( void )

Definition at line 542 of file console.c.

543{
544 size_t pos;
545 size_t n;
546 Log_Open ();
547
548 // Dump the contents of the log queue into the log file and free it
549 if (logqueue != NULL)
550 {
551 unsigned char *temp = logqueue;
552 logqueue = NULL;
553 if(logq_ind != 0)
554 {
555 if (logfile != NULL)
556 FS_Write (logfile, temp, logq_ind);
558 {
559 for(pos = 0; pos < logq_ind; )
560 {
561 if(log_dest_buffer_pos == 0)
563 n = min(sizeof(log_dest_buffer) - log_dest_buffer_pos - 1, logq_ind - pos);
564 memcpy(log_dest_buffer + log_dest_buffer_pos, temp + pos, n);
567 pos += n;
568 }
569 }
570 }
571 Mem_Free (temp);
572 logq_ind = 0;
573 logq_size = 0;
574 }
575}
static void Log_Open(void)
Definition console.c:503
static void Log_DestBuffer_Init(void)
Definition console.c:420
size_t log_dest_buffer_pos
Definition console.c:409
char log_dest_buffer[1400]
Definition console.c:408
fs_offset_t FS_Write(qfile_t *file, const void *data, size_t datasize)
Definition fs.c:3019

References FS_Write(), log_dest_buffer, log_dest_buffer_pos, log_dest_udp, Log_DestBuffer_Flush_NoLock(), Log_DestBuffer_Init(), Log_Open(), logfile, logq_ind, logq_size, logqueue, Mem_Free, min, n, NULL, and cvar_t::string.

Referenced by Host_Init().

Variable Documentation

◆ con_backscroll

int con_backscroll
extern

◆ con_initialized

qbool con_initialized
extern

Definition at line 97 of file console.c.

Referenced by CL_UpdateScreen(), Con_Init(), and Con_MaskPrint().

◆ con_totallines

int con_totallines
extern