mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-22 04:01:17 +00:00
various printf, Sys_Printf, Con_Printf cleanups. Con_Printf now ALWAYS prints
to consol/logfile whether output is recirected or not. Also, Con_Printf will not print the time stamp if the last char of the previous print wasn't \n
This commit is contained in:
parent
3b0d17acc4
commit
451afbd488
8 changed files with 39 additions and 99 deletions
|
@ -218,18 +218,7 @@ Sys_Error (char *error, ...)
|
|||
Host_Shutdown ();
|
||||
exit (1);
|
||||
}
|
||||
/*
|
||||
void
|
||||
Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vprintf (fmt, argptr);
|
||||
|
||||
va_end (argptr);
|
||||
}
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
|
|
|
@ -57,61 +57,6 @@ qboolean is_server = false;
|
|||
// General routines
|
||||
// =======================================================================
|
||||
|
||||
/*
|
||||
void Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
||||
va_start (argptr,fmt);
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf (text,sizeof(text),fmt,argptr);
|
||||
#else
|
||||
vsprintf (text,fmt,argptr);
|
||||
#endif
|
||||
va_end (argptr);
|
||||
fprintf(stderr, "%s", text);
|
||||
|
||||
Con_Print (text);
|
||||
}
|
||||
|
||||
void Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
|
||||
va_list argptr;
|
||||
char text[1024], *t_p;
|
||||
int l, r;
|
||||
|
||||
if (nostdout)
|
||||
return;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf (text,sizeof(text),fmt,argptr);
|
||||
#else
|
||||
vsprintf (text,fmt,argptr);
|
||||
#endif
|
||||
va_end (argptr);
|
||||
|
||||
l = strlen(text);
|
||||
t_p = text;
|
||||
|
||||
// make sure everything goes through, even though we are non-blocking
|
||||
while (l)
|
||||
{
|
||||
r = write (1, text, l);
|
||||
if (r != l)
|
||||
sleep (0);
|
||||
if (r > 0)
|
||||
{
|
||||
t_p += r;
|
||||
l -= r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
|
|
|
@ -241,7 +241,8 @@ D_SCDump (void)
|
|||
for (test = sc_base; test; test = test->next) {
|
||||
if (test == sc_rover)
|
||||
Sys_Printf ("ROVER:\n");
|
||||
printf ("%p : %i bytes %i width\n", test, test->size, test->width);
|
||||
Sys_Printf ("%p : %i bytes %i width\n", test, test->size,
|
||||
test->width);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -417,7 +417,7 @@ COM_WriteBuffers (const char *filename, int count, ...)
|
|||
Sys_Error ("Error opening %s", filename);
|
||||
}
|
||||
|
||||
Sys_Printf ("COM_WriteFile: %s\n", name);
|
||||
Sys_Printf ("COM_WriteBuffers: %s\n", name);
|
||||
while (count--) {
|
||||
void *data = va_arg (args, void*);
|
||||
int len = va_arg (args, int);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "console.h"
|
||||
#include "sizebuf.h"
|
||||
#include "sys.h"
|
||||
|
||||
|
@ -60,8 +61,7 @@ SZ_GetSpace (sizebuf_t *buf, int length)
|
|||
if (length > buf->maxsize)
|
||||
Sys_Error ("SZ_GetSpace: %i is > full buffer size", length);
|
||||
|
||||
Sys_Printf ("SZ_GetSpace: overflow\n"); // because Con_Printf may be
|
||||
// redirected
|
||||
Con_Printf ("SZ_GetSpace: overflow\n");
|
||||
SZ_Clear (buf);
|
||||
buf->overflowed = true;
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
|
|||
|
||||
i = client - svs.clients;
|
||||
|
||||
// Sys_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i);
|
||||
// Con_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i);
|
||||
|
||||
MSG_WriteByte (buf, svc_updatefrags);
|
||||
MSG_WriteByte (buf, i);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
/*
|
||||
=============================================================================
|
||||
|
||||
Con_Printf redirection
|
||||
Con_Printf redirection
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
@ -127,6 +127,7 @@ Handles cursor positioning, line wrapping, etc
|
|||
void
|
||||
Con_Printf (char *fmt, ...)
|
||||
{
|
||||
static int pending = 0; // partial line being printed
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
char msg2[MAXPRINTMSG];
|
||||
|
@ -144,26 +145,30 @@ Con_Printf (char *fmt, ...)
|
|||
if (strlen (msg) + strlen (outputbuf) > sizeof (outputbuf) - 1)
|
||||
SV_FlushRedirect ();
|
||||
strncat (outputbuf, msg, sizeof (outputbuf) - strlen (outputbuf));
|
||||
return;
|
||||
} else { // We want to output to console and
|
||||
// maybe logfile
|
||||
if (sv_timestamps && sv_timefmt && sv_timefmt->string
|
||||
&& sv_timestamps->int_val) timestamps = true;
|
||||
|
||||
if (timestamps) {
|
||||
mytime = time (NULL);
|
||||
local = localtime (&mytime);
|
||||
strftime (msg3, sizeof (msg3), sv_timefmt->string, local);
|
||||
|
||||
snprintf (msg2, sizeof (msg2), "%s%s", msg3, msg);
|
||||
} else {
|
||||
snprintf (msg2, sizeof (msg2), "%s", msg);
|
||||
}
|
||||
|
||||
Sys_Printf ("%s", msg2); // also echo to debugging console
|
||||
if (sv_logfile)
|
||||
Qprintf (sv_logfile, "%s", msg2);
|
||||
}
|
||||
// We want to output to console and maybe logfile
|
||||
if (sv_timestamps && sv_timefmt && sv_timefmt->string
|
||||
&& sv_timestamps->int_val && !pending)
|
||||
timestamps = true;
|
||||
|
||||
if (timestamps) {
|
||||
mytime = time (NULL);
|
||||
local = localtime (&mytime);
|
||||
strftime (msg3, sizeof (msg3), sv_timefmt->string, local);
|
||||
|
||||
snprintf (msg2, sizeof (msg2), "%s%s", msg3, msg);
|
||||
} else {
|
||||
snprintf (msg2, sizeof (msg2), "%s", msg);
|
||||
}
|
||||
if (msg2[strlen (msg2) - 1] != '\n') {
|
||||
pending = 1;
|
||||
} else {
|
||||
pending = 0;
|
||||
}
|
||||
|
||||
Sys_Printf ("%s", msg2); // also echo to debugging console
|
||||
if (sv_logfile)
|
||||
Qprintf (sv_logfile, "%s", msg2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -248,7 +253,7 @@ SV_BroadcastPrintf (int level, char *fmt, ...)
|
|||
vsnprintf (string, sizeof (string), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
Sys_Printf ("%s", string); // print to the console
|
||||
Con_Printf ("%s", string); // print to the console
|
||||
|
||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||
if (level < cl->messagelevel)
|
||||
|
|
|
@ -642,13 +642,13 @@ SV_NextUpload (void)
|
|||
if (!host_client->upload) {
|
||||
host_client->upload = Qopen (host_client->uploadfn, "wb");
|
||||
if (!host_client->upload) {
|
||||
Sys_Printf ("Can't create %s\n", host_client->uploadfn);
|
||||
Con_Printf ("Can't create %s\n", host_client->uploadfn);
|
||||
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
||||
ClientReliableWrite_String (host_client, "stopul");
|
||||
*host_client->uploadfn = 0;
|
||||
return;
|
||||
}
|
||||
Sys_Printf ("Receiving %s from %d...\n", host_client->uploadfn,
|
||||
Con_Printf ("Receiving %s from %d...\n", host_client->uploadfn,
|
||||
host_client->userid);
|
||||
if (host_client->remote_snap)
|
||||
OutofBandPrintf (host_client->snap_from,
|
||||
|
@ -668,7 +668,7 @@ SV_NextUpload (void)
|
|||
Qclose (host_client->upload);
|
||||
host_client->upload = NULL;
|
||||
|
||||
Sys_Printf ("%s upload completed.\n", host_client->uploadfn);
|
||||
Con_Printf ("%s upload completed.\n", host_client->uploadfn);
|
||||
|
||||
if (host_client->remote_snap) {
|
||||
char *p;
|
||||
|
@ -759,7 +759,7 @@ SV_BeginDownload_f (void)
|
|||
host_client->download = NULL;
|
||||
}
|
||||
|
||||
Sys_Printf ("Couldn't download %s to %s\n", name, host_client->name);
|
||||
Con_Printf ("Couldn't download %s to %s\n", name, host_client->name);
|
||||
ClientReliableWrite_Begin (host_client, svc_download, 4);
|
||||
ClientReliableWrite_Short (host_client, -1);
|
||||
ClientReliableWrite_Byte (host_client, 0);
|
||||
|
@ -767,7 +767,7 @@ SV_BeginDownload_f (void)
|
|||
}
|
||||
|
||||
if (zip && strcmp (realname, name)) {
|
||||
Sys_Printf ("download renamed to %s\n", realname);
|
||||
Con_Printf ("download renamed to %s\n", realname);
|
||||
ClientReliableWrite_Begin (host_client, svc_download,
|
||||
strlen (realname) + 5);
|
||||
ClientReliableWrite_Short (host_client, -2);
|
||||
|
@ -777,7 +777,7 @@ SV_BeginDownload_f (void)
|
|||
}
|
||||
|
||||
SV_NextDownload_f ();
|
||||
Sys_Printf ("Downloading %s to %s\n", name, host_client->name);
|
||||
Con_Printf ("Downloading %s to %s\n", name, host_client->name);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -851,7 +851,7 @@ SV_Say (qboolean team)
|
|||
strncat (text, p, sizeof (text) - strlen (text));
|
||||
strncat (text, "\n", sizeof (text) - strlen (text));
|
||||
|
||||
Sys_Printf ("%s", text);
|
||||
Con_Printf ("%s", text);
|
||||
|
||||
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
||||
if (client->state != cs_spawned)
|
||||
|
|
Loading…
Reference in a new issue