X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=console.c;h=6bf28ec7d87d26e5d197606f1769ba064a170703;hp=7767617cfd7f2f8335a50511a51910a040420170;hb=HEAD;hpb=906474fc025ff5b0b8799d9045a581bceafd2e7d diff --git a/console.c b/console.c index 7767617c..a33264c1 100644 --- a/console.c +++ b/console.c @@ -333,7 +333,7 @@ ConBuffer_AddLine Appends a given string as a new line to the console. ================ */ -void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask) +void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, unsigned mask) { char *putpos; con_lineinfo_t *p; @@ -367,7 +367,7 @@ void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask) p->height = -1; // calculate when needed } -int ConBuffer_FindPrevLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start) +int ConBuffer_FindPrevLine(conbuffer_t *buf, unsigned mask_must, unsigned mask_mustnot, int start) { int i; if(start == -1) @@ -391,8 +391,8 @@ const char *ConBuffer_GetLine(conbuffer_t *buf, int i) { static char copybuf[MAX_INPUTLINE]; // client only con_lineinfo_t *l = &CONBUFFER_LINES(buf, i); - size_t sz = l->len+1 > sizeof(copybuf) ? sizeof(copybuf) : l->len+1; - dp_strlcpy(copybuf, l->start, sz); + + dp_ustr2stp(copybuf, sizeof(copybuf), l->start, l->len); return copybuf; } @@ -719,8 +719,9 @@ static void Con_MsgCmdMode(cmd_state_t *cmd, signed char mode) chat_mode = mode; if(Cmd_Argc(cmd) > 1) { - dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args(cmd)); - chat_bufferpos = (unsigned int)strlen(chat_buffer); + chat_bufferpos = dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args(cmd)); + if (chat_bufferpos < 0) + chat_bufferpos = 0; } } @@ -1150,10 +1151,10 @@ Con_MaskPrint */ extern cvar_t timestamps; extern cvar_t timeformat; -void Con_MaskPrint(int additionalmask, const char *msg) +void Con_MaskPrint(unsigned additionalmask, const char *msg) { - static int mask = 0; - static int index = 0; + static unsigned mask = 0; + static unsigned index = 0; static char line[MAX_INPUTLINE]; if (con_mutex) @@ -1355,12 +1356,12 @@ void Con_MaskPrint(int additionalmask, const char *msg) *out++ = '['; *out++ = 'm'; } - *out++ = 0; - Sys_Print(printline); + *out = '\0'; + Sys_Print(printline, out - printline); } else if(sys_colortranslation.integer == 2) // Quake { - Sys_Print(line); + Sys_Print(line, index); } else // strip { @@ -1410,8 +1411,8 @@ void Con_MaskPrint(int additionalmask, const char *msg) break; } } - *out++ = 0; - Sys_Print(printline); + *out = '\0'; + Sys_Print(printline, out - printline); } } // empty the line buffer @@ -1429,7 +1430,7 @@ void Con_MaskPrint(int additionalmask, const char *msg) Con_MaskPrintf ================ */ -void Con_MaskPrintf(int mask, const char *fmt, ...) +void Con_MaskPrintf(unsigned mask, const char *fmt, ...) { va_list argptr; char msg[MAX_INPUTLINE]; @@ -1699,7 +1700,7 @@ static int Con_DisplayLineFunc(void *passthrough, const char *line, size_t lengt return 1; } -static int Con_DrawNotifyRect(int mask_must, int mask_mustnot, float maxage, float x, float y, float width, float height, float fontsize, float alignment_x, float alignment_y, const char *continuationString) +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) { int i; int lines = 0; @@ -1900,7 +1901,7 @@ If alpha is 0, the line is not drawn, but still wrapped and its height returned. ================ */ -static int Con_DrawConsoleLine(int mask_must, int mask_mustnot, float y, int lineno, float ymin, float ymax) +static int Con_DrawConsoleLine(unsigned mask_must, unsigned mask_mustnot, float y, int lineno, float ymin, float ymax) { float width = vid_conwidth.value; con_text_info_t ti; @@ -1932,7 +1933,7 @@ Calculates the last visible line index and how much to show of it based on con_backscroll. ================ */ -static void Con_LastVisibleLine(int mask_must, int mask_mustnot, int *last, int *limitlast) +static void Con_LastVisibleLine(unsigned mask_must, unsigned mask_mustnot, int *last, int *limitlast) { int lines_seen = 0; int i; @@ -1974,7 +1975,7 @@ Draws the console with the solid background The typing input line at the bottom should only be drawn if typing is allowed ================ */ -void Con_DrawConsole (int lines) +void Con_DrawConsole (int lines, qbool forcedfullscreen) { float alpha, alpha0; double sx, sy; @@ -1996,7 +1997,7 @@ void Con_DrawConsole (int lines) r_draw2d_force = true; // draw the background - alpha0 = cls.signon == SIGNONS ? scr_conalpha.value : 1.0f; // always full alpha when not in game + alpha0 = forcedfullscreen ? 1.0f : scr_conalpha.value; // always full alpha when not forced fullscreen if((alpha = alpha0 * scr_conalphafactor.value) > 0) { sx = scr_conscroll_x.value; @@ -2160,7 +2161,7 @@ qbool GetMapList (const char *s, char *completedname, int completednamebufferlen if (!memcmp(buf, "IBSP", 4)) { p = LittleLong(((int *)buf)[1]); - if (p == Q3BSPVERSION) + if (p == Q3BSPVERSION || p == Q3BSPVERSION_LIVE || p == Q3BSPVERSION_IG) { q3dheader_t *header = (q3dheader_t *)buf; lumpofs = LittleLong(header->lumps[Q3LUMP_ENTITIES].fileofs); @@ -2785,7 +2786,8 @@ int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console) space = strchr(line + 1, ' '); if(space && pos == (space - line) + 1) { - dp_strlcpy(command, line + 1, min(sizeof(command), (unsigned int)(space - line))); + // adding 1 to line drops the leading ] + dp_ustr2stp(command, sizeof(command), line + 1, space - (line + 1)); 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? if(patterns && !*patterns)