ref: 81efcd44e70f5ef130cea76791053e847c51499a
parent: bab80c934d2714937198f25041f8047146158f9c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Oct 12 19:53:55 EDT 2023
add "developer" cvar, Con_DPrintf, and shut up qc dprint
--- a/console.c
+++ b/console.c
@@ -10,6 +10,7 @@
float con_cursorspeed = 4;
#define CON_TEXTSIZE 16384
+#define MAXPRINTMSG 4096
qboolean con_forcedup; // because no entities to refresh
@@ -291,7 +292,7 @@
static void
print1(char *s, int n)
{
- char buf[4096], *p, *d;
+ char buf[MAXPRINTMSG], *p, *d;
if(!debug)
return;
@@ -308,7 +309,7 @@
{
int n;
va_list arg;
- char msg[4096];
+ char msg[MAXPRINTMSG];
static qboolean inupdate;
/* FIXME: Con_Print() above uses 1<<7 bit for color printing select
@@ -338,6 +339,28 @@
inupdate = false;
}
}
+}
+
+/*
+================
+Con_DPrintf
+
+A Con_Printf that only shows up if the "developer" cvar is set
+================
+*/
+void Con_DPrintf (char *fmt, ...)
+{
+ va_list argptr;
+ char msg[MAXPRINTMSG];
+
+ if (!developer.value)
+ return; // don't confuse non-developers with techie stuff...
+
+ va_start (argptr,fmt);
+ vsprintf (msg,fmt,argptr);
+ va_end (argptr);
+
+ Con_Printf ("%s", msg);
}
/*
--- a/console.h
+++ b/console.h
@@ -14,6 +14,7 @@
void Con_Init (void);
void Con_DrawConsole (int lines, qboolean drawinput);
void Con_Printf (char *fmt, ...);
+void Con_DPrintf (char *fmt, ...);
void Con_Clear_f (void);
void Con_DrawNotify (void);
void Con_ClearNotify (void);
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -876,8 +876,7 @@
void
PF_dprint(void)
{
- /* just always print it, but not on the console */
- fprint(2, "%s", PF_VarString(0));
+ Con_DPrintf("%s", PF_VarString(0));
}
void PF_ftos (void)
--- a/quakedef.h
+++ b/quakedef.h
@@ -190,6 +190,7 @@
// host
//
extern cvar_t sys_ticrate;
+extern cvar_t developer;
extern qboolean host_initialized; // true if into command execution
extern double host_frametime;
--- a/sv_main.c
+++ b/sv_main.c
@@ -7,6 +7,8 @@
server_t sv;
server_static_t svs;
+cvar_t developer = {"developer", "0"}; // show extra messages
+
// we can't just change protocol mid-game, so it's saved here first
static protocol_t *sv_protocol = &protos[PROTO_RMQ];
@@ -63,6 +65,7 @@
Cvar_RegisterVariable (&sv_idealpitchscale);
Cvar_RegisterVariable (&sv_aim);
Cvar_RegisterVariable (&sv_nostep);
+ Cvar_RegisterVariable (&developer);
Cmd_AddCommand("sv_protocol", SV_Protocol_f);