mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
cleanup Com_sprintf, minor tuning
This commit is contained in:
parent
6472514c8f
commit
5692388da1
2 changed files with 3 additions and 10 deletions
|
@ -1100,22 +1100,15 @@ Com_sprintf(char *dest, int size, char *fmt, ...)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char bigbuffer[0x10000];
|
|
||||||
|
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
len = vsnprintf(bigbuffer, 0x10000, fmt, argptr);
|
len = vsnprintf(dest, size, fmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
if ((len >= size) || (len == size))
|
if (len >= size)
|
||||||
{
|
{
|
||||||
Com_Printf("Com_sprintf: overflow\n");
|
Com_Printf("Com_sprintf: overflow\n");
|
||||||
|
|
||||||
dest = NULL;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bigbuffer[size - 1] = '\0';
|
|
||||||
strcpy(dest, bigbuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -1218,7 +1218,7 @@ Cmd_PlayerList_f(edict_t *ent)
|
||||||
|
|
||||||
if (strlen(text) + strlen(st) > sizeof(text) - 50)
|
if (strlen(text) + strlen(st) > sizeof(text) - 50)
|
||||||
{
|
{
|
||||||
sprintf(text + strlen(text), "And more...\n");
|
strcpy(text + strlen(text), "And more...\n");
|
||||||
gi.cprintf(ent, PRINT_HIGH, "%s", text);
|
gi.cprintf(ent, PRINT_HIGH, "%s", text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue