summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-09-04 15:53:16 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-09-04 15:53:16 +0000
commita63351b924daa288b120af78607434ca5acc60d8 (patch)
tree902f9b525cf107ee27cee2788ddaedfe313b8a8d
parentb96aee6bda286ae78d7821a2dfd21582daa05ba3 (diff)
Changed Com_DPrintf, Com_WPrintf and Com_EPrintf functions to macros.
Introduced Com_LPrintf, FS_DPrintf, SV_DPrintf. Don't include any developer code at all unless built with _DEBUG.
-rw-r--r--source/baseq2/g_main.c33
-rw-r--r--source/cl_input.c10
-rw-r--r--source/cl_local.h18
-rw-r--r--source/cl_main.c18
-rw-r--r--source/cl_parse.c89
-rw-r--r--source/cl_pred.c13
-rw-r--r--source/cl_public.h2
-rw-r--r--source/cl_scrn.c2
-rw-r--r--source/com_local.h10
-rw-r--r--source/common.c101
-rw-r--r--source/files.c41
-rw-r--r--source/mvd_client.c14
-rw-r--r--source/mvd_local.h2
-rw-r--r--source/mvd_parse.c73
-rw-r--r--source/net_chan.c178
-rw-r--r--source/prompt.c6
-rw-r--r--source/q_msg.c217
-rw-r--r--source/q_msg.h14
-rw-r--r--source/q_shared.c74
-rw-r--r--source/q_shared.h25
-rw-r--r--source/snd_main.c11
-rw-r--r--source/sv_local.h12
-rw-r--r--source/sv_main.c8
-rw-r--r--source/sv_send.c65
-rw-r--r--source/sv_user.c22
-rw-r--r--source/ui_atoms.c2
-rw-r--r--source/ui_confirm.c2
-rw-r--r--source/ui_local.h2
-rw-r--r--source/ui_multiplayer.c8
-rw-r--r--source/ui_public.h2
30 files changed, 449 insertions, 625 deletions
diff --git a/source/baseq2/g_main.c b/source/baseq2/g_main.c
index 918e014..2766c78 100644
--- a/source/baseq2/g_main.c
+++ b/source/baseq2/g_main.c
@@ -230,32 +230,22 @@ EXPORTED game_export_t *GetGameAPI (game_import_t *import)
#ifndef GAME_HARD_LINKED
// this is only here so the functions in q_shared.c can link
-void Com_Printf( const char *fmt, ... ) {
+void Com_LPrintf( print_type_t type, const char *fmt, ... ) {
va_list argptr;
char text[MAX_STRING_CHARS];
- va_start( argptr, fmt );
- Q_vsnprintf( text, sizeof( text ), fmt, argptr );
- va_end( argptr );
-
- gi.dprintf( "%s", text );
-}
-
-void Com_DPrintf( const char *fmt, ... ) {
-}
-
-void Com_WPrintf( const char *fmt, ... ) {
- va_list argptr;
- char text[MAX_STRING_CHARS];
+ if( type == PRINT_DEVELOPER ) {
+ return;
+ }
va_start( argptr, fmt );
Q_vsnprintf( text, sizeof( text ), fmt, argptr );
va_end( argptr );
- gi.dprintf( "WARNING: %s", text );
+ gi.dprintf( "%s", text );
}
-void Com_EPrintf( const char *fmt, ... ) {
+void Com_Error( error_type_t type, const char *fmt, ... ) {
va_list argptr;
char text[MAX_STRING_CHARS];
@@ -263,17 +253,6 @@ void Com_EPrintf( const char *fmt, ... ) {
Q_vsnprintf( text, sizeof( text ), fmt, argptr );
va_end( argptr );
- gi.dprintf( "ERROR: %s", text );
-}
-
-void Com_Error( comErrorType_t err_level, const char *error, ... ) {
- va_list argptr;
- char text[MAX_STRING_CHARS];
-
- va_start( argptr, error );
- Q_vsnprintf( text, sizeof( text ), error, argptr );
- va_end( argptr );
-
gi.error( "%s", text );
}
#endif
diff --git a/source/cl_input.c b/source/cl_input.c
index 8b0ff6a..e7ade51 100644
--- a/source/cl_input.c
+++ b/source/cl_input.c
@@ -28,7 +28,9 @@ static cvar_t *cl_nodelta;
static cvar_t *cl_maxpackets;
static cvar_t *cl_packetdup;
static cvar_t *cl_fuzzhack;
+#ifdef _DEBUG
static cvar_t *cl_showpackets;
+#endif
static cvar_t *cl_instantpacket;
static cvar_t *m_filter;
@@ -673,7 +675,9 @@ void CL_RegisterInput( void ) {
cl_maxpackets = Cvar_Get( "cl_maxpackets", "30", 0 );
cl_fuzzhack = Cvar_Get( "cl_fuzzhack", "0", 0 );
cl_packetdup = Cvar_Get( "cl_packetdup", "1", 0 );
+#ifdef _DEBUG
cl_showpackets = Cvar_Get( "cl_showpackets", "0", 0 );
+#endif
cl_instantpacket = Cvar_Get( "cl_instantpacket", "1", 0 );
cl_upspeed = Cvar_Get ( "cl_upspeed", "200", 0 );
@@ -882,9 +886,11 @@ static void CL_SendDefaultCmd( void ) {
// deliver the message
//
cursize = cls.netchan->Transmit( cls.netchan, msg_write.cursize, msg_write.data, 1 );
+#ifdef _DEBUG
if( cl_showpackets->integer ) {
Com_Printf( "%"PRIz" ", cursize );
}
+#endif
SZ_Clear( &msg_write );
}
@@ -959,9 +965,11 @@ static void CL_SendBatchedCmd( void ) {
cmd = &cl.cmds[j & CMD_MASK];
totalMsec += cmd->msec;
bits = MSG_WriteDeltaUsercmd_Enhanced( oldcmd, cmd, cls.protocolVersion );
+#ifdef _DEBUG
if( cl_showpackets->integer == 3 ) {
MSG_ShowDeltaUsercmdBits_Enhanced( bits );
}
+#endif
oldcmd = cmd;
}
}
@@ -970,6 +978,7 @@ static void CL_SendBatchedCmd( void ) {
// deliver the message
//
cursize = cls.netchan->Transmit( cls.netchan, msg_write.cursize, msg_write.data, 1 );
+#ifdef _DEBUG
if( cl_showpackets->integer == 1 ) {
Com_Printf( "%"PRIz"(%i) ", cursize, totalCmds );
} else if( cl_showpackets->integer == 2 ) {
@@ -977,6 +986,7 @@ static void CL_SendBatchedCmd( void ) {
} else if( cl_showpackets->integer == 3 ) {
Com_Printf( " | " );
}
+#endif
SZ_Clear( &msg_write );
diff --git a/source/cl_local.h b/source/cl_local.h
index 3b05a93..5a86b63 100644
--- a/source/cl_local.h
+++ b/source/cl_local.h
@@ -342,9 +342,24 @@ extern cvar_t *cl_noskins;
extern cvar_t *cl_kickangles;
extern cvar_t *cl_rollhack;
+#ifdef _DEBUG
+#define SHOWNET(level,...) \
+ if( cl_shownet->integer > level ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#define SHOWCLAMP(level,...) \
+ if( cl_showclamp->integer > level ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#define SHOWMISS(...) \
+ if( cl_showmiss->integer ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
extern cvar_t *cl_shownet;
extern cvar_t *cl_showmiss;
extern cvar_t *cl_showclamp;
+#else
+#define SHOWNET(...)
+#define SHOWCLAMP(...)
+#define SHOWMISS(...)
+#endif
extern cvar_t *cl_vwep;
@@ -520,7 +535,7 @@ void CL_AddLightStyles (void);
void CL_Init (void);
void CL_Quit_f (void);
-void CL_Disconnect( comErrorType_t type, const char *text );
+void CL_Disconnect( error_type_t type, const char *text );
void CL_RequestNextDownload (void);
void CL_CheckForResend( void );
void CL_ClearState (void);
@@ -701,6 +716,7 @@ float SCR_FadeAlpha( unsigned startTime, unsigned visTime, unsigned fadeTime )
int SCR_DrawStringEx( int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font );
void SCR_DrawStringMulti( int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font );
+
//
// cl_keys.c
//
diff --git a/source/cl_main.c b/source/cl_main.c
index 9980feb..64c672f 100644
--- a/source/cl_main.c
+++ b/source/cl_main.c
@@ -46,9 +46,11 @@ cvar_t *r_maxfps;
cvar_t *cl_kickangles;
cvar_t *cl_rollhack;
+#ifdef _DEBUG
cvar_t *cl_shownet;
cvar_t *cl_showmiss;
cvar_t *cl_showclamp;
+#endif
cvar_t *cl_thirdperson;
cvar_t *cl_thirdperson_angle;
@@ -600,7 +602,7 @@ Sends a disconnect message to the server
This is also called on Com_Error, so it shouldn't cause any errors
=====================
*/
-void CL_Disconnect( comErrorType_t type, const char *text ) {
+void CL_Disconnect( error_type_t type, const char *text ) {
SCR_EndLoadingPlaque(); // get rid of loading plaque
if( cls.state > ca_disconnected && !cls.demo.playback ) {
@@ -2520,9 +2522,12 @@ static void CL_InitLocal ( void ) {
r_maxfps = Cvar_Get( "r_maxfps", "0", CVAR_ARCHIVE );
cl_rollhack = Cvar_Get( "cl_rollhack", "1", 0 );
+#ifdef _DEBUG
cl_shownet = Cvar_Get( "cl_shownet", "0", 0 );
cl_showmiss = Cvar_Get ( "cl_showmiss", "0", 0 );
cl_showclamp = Cvar_Get ( "showclamp", "0", 0 );
+#endif
+
cl_timeout = Cvar_Get ( "cl_timeout", "120", 0 );
rcon_address = Cvar_Get ( "rcon_address", "", CVAR_PRIVATE );
@@ -2648,23 +2653,18 @@ static void CL_SetClientTime( void ) {
prevtime = cl.servertime - cl.frametime;
if( cl.time > cl.servertime ) {
- if( cl_showclamp->integer )
- Com_Printf( "high clamp %i\n", cl.time - cl.servertime );
+ SHOWCLAMP( 1, "high clamp %i\n", cl.time - cl.servertime );
cl.time = cl.servertime;
cl.lerpfrac = 1.0f;
} else if( cl.time < prevtime ) {
- if( cl_showclamp->integer )
- Com_Printf( "low clamp %i\n", prevtime - cl.time );
+ SHOWCLAMP( 1, "low clamp %i\n", prevtime - cl.time );
cl.time = prevtime;
cl.lerpfrac = 0;
} else {
cl.lerpfrac = ( cl.time - prevtime ) * cl.framefrac;
}
- if( cl_showclamp->integer == 2 ) {
- Com_Printf( "time %i, lerpfrac %.3f\n",
- cl.time, cl.lerpfrac );
- }
+ SHOWCLAMP( 2, "time %i, lerpfrac %.3f\n", cl.time, cl.lerpfrac );
}
static void CL_MeasureStats( void ) {
diff --git a/source/cl_parse.c b/source/cl_parse.c
index 8dd5a16..587e3f2 100644
--- a/source/cl_parse.c
+++ b/source/cl_parse.c
@@ -246,7 +246,7 @@ static inline void CL_ParseDeltaEntity( server_frame_t *frame,
{
entity_state_t *state;
- if( frame->numEntities == MAX_PACKET_ENTITIES ) {
+ if( frame->numEntities >= MAX_PACKET_ENTITIES ) {
Com_Error( ERR_DROP, "%s: MAX_PACKET_ENTITIES exceeded", __func__ );
}
@@ -254,9 +254,12 @@ static inline void CL_ParseDeltaEntity( server_frame_t *frame,
cl.numEntityStates++;
frame->numEntities++;
- if( cl_shownet->integer > 2 ) {
+#ifdef _DEBUG
+ if( cl_shownet->integer > 2 && bits ) {
MSG_ShowDeltaEntityBits( bits );
+ Com_Printf( "\n" );
}
+#endif
MSG_ParseDeltaEntity( old, state, newnum, bits, cl.esFlags );
}
@@ -309,9 +312,7 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
while( oldnum < newnum ) {
// one or more entities from the old packet are unchanged
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " unchanged: %i\n", oldnum );
- }
+ SHOWNET( 2, " unchanged: %i\n", oldnum );
CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 );
oldindex++;
@@ -327,9 +328,7 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
if( bits & U_REMOVE ) {
// the entity present in oldframe is not in the current frame
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " remove: %i\n", newnum );
- }
+ SHOWNET( 2, " remove: %i\n", newnum );
if( oldnum != newnum ) {
Com_DPrintf( "U_REMOVE: oldnum != newnum\n" );
}
@@ -351,13 +350,8 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
if( oldnum == newnum ) {
// delta from previous state
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " delta: %i ", newnum );
- }
+ SHOWNET( 2, " delta: %i ", newnum );
CL_ParseDeltaEntity( frame, newnum, oldstate, bits );
- if( cl_shownet->integer > 2 ) {
- Com_Printf( "\n" );
- }
oldindex++;
@@ -373,13 +367,8 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
if( oldnum > newnum ) {
// delta from baseline
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " baseline: %i ", newnum );
- }
+ SHOWNET( 2, " baseline: %i ", newnum );
CL_ParseDeltaEntity( frame, newnum, &cl.baselines[newnum], bits );
- if( cl_shownet->integer > 2 ) {
- Com_Printf( "\n" );
- }
continue;
}
@@ -388,11 +377,9 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
// any remaining entities in the old frame are copied over
while( oldnum != 99999 ) {
// one or more entities from the old packet are unchanged
- if( cl_shownet->integer > 3 ) {
- Com_Printf( " unchanged: %i\n", oldnum );
- }
+ SHOWNET( 3, " unchanged: %i\n", oldnum );
CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 );
-
+
oldindex++;
if( oldindex >= oldframe->numEntities ) {
@@ -561,18 +548,18 @@ static void CL_ParseFrame( int extrabits ) {
}
}
- if( cl_shownet->integer > 2 ) {
- Com_Printf( "%3"PRIz":playerinfo\n", msg_read.readcount - 1 );
- }
+ SHOWNET( 2, "%3"PRIz":playerinfo\n", msg_read.readcount - 1 );
// parse playerstate
bits = MSG_ReadShort();
if( cls.serverProtocol > PROTOCOL_VERSION_DEFAULT ) {
MSG_ParseDeltaPlayerstate_Enhanced( from, &frame.ps, bits, extraflags );
+#ifdef _DEBUG
if( cl_shownet->integer > 2 ) {
MSG_ShowDeltaPlayerstateBits_Enhanced( bits );
Com_Printf( "\n" );
}
+#endif
if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) {
// parse clientNum
if( extraflags & EPS_CLIENTNUM ) {
@@ -585,10 +572,12 @@ static void CL_ParseFrame( int extrabits ) {
}
} else {
MSG_ParseDeltaPlayerstate_Default( from, &frame.ps, bits );
+#ifdef _DEBUG
if( cl_shownet->integer > 2 ) {
MSG_ShowDeltaPlayerstateBits_Default( bits );
Com_Printf( "\n" );
}
+#endif
frame.clientNum = cl.clientNum;
}
if( !frame.ps.fov ) {
@@ -603,15 +592,14 @@ static void CL_ParseFrame( int extrabits ) {
}
}
- if( cl_shownet->integer > 2 ) {
- Com_Printf( "%3"PRIz":packetentities\n", msg_read.readcount - 1 );
- }
+ SHOWNET( 2, "%3"PRIz":packetentities\n", msg_read.readcount - 1 );
CL_ParsePacketEntities( oldframe, &frame );
// save the frame off in the backup array for later delta comparisons
cl.frames[currentframe & UPDATE_MASK] = frame;
+#ifdef _DEBUG
if( cl_shownet->integer > 2 ) {
int rtt = 0;
if( cls.netchan ) {
@@ -621,6 +609,7 @@ static void CL_ParseFrame( int extrabits ) {
Com_Printf( "%3"PRIz":frame:%d delta:%d rtt:%d\n",
msg_read.readcount - 1, frame.number, frame.delta, rtt );
}
+#endif
if( !frame.valid ) {
cl.frame.valid = qfalse;
@@ -661,9 +650,7 @@ static void CL_ParseConfigstring( int index ) {
maxlen = CS_SIZE( index );
len = MSG_ReadString( string, maxlen );
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " %d \"%s\"\n", index, Q_FormatString( string ) );
- }
+ SHOWNET( 2, " %d \"%s\"\n", index, string );
if( len >= maxlen ) {
Com_WPrintf(
@@ -718,10 +705,12 @@ static void CL_ParseBaseline( int index, int bits ) {
if( index < 1 || index >= MAX_EDICTS ) {
Com_Error( ERR_DROP, "%s: bad index: %d", __func__, index );
}
+#ifdef _DEBUG
if( cl_shownet->integer > 2 ) {
MSG_ShowDeltaEntityBits( bits );
Com_Printf( "\n" );
}
+#endif
MSG_ParseDeltaEntity( NULL, &cl.baselines[index], index, bits, cl.esFlags );
}
@@ -1115,9 +1104,7 @@ static void CL_ParseStartSoundPacket( void ) {
pos = NULL;
}
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " %s\n", cl.configstrings[CS_SOUNDS+sound_num] );
- }
+ SHOWNET( 2, " %s\n", cl.configstrings[CS_SOUNDS+sound_num] );
if( cl.sound_precache[sound_num] ) {
S_StartSound( pos, ent, channel, cl.sound_precache[sound_num],
@@ -1197,9 +1184,7 @@ static void CL_ParsePrint( void ) {
level = MSG_ReadByte();
MSG_ReadString( string, sizeof( string ) );
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " %i \"%s\"\n", level, Q_FormatString( string ) );
- }
+ SHOWNET( 2, " %i \"%s\"\n", level, string );
if( level != PRINT_CHAT ) {
Com_Printf( "%s", string );
@@ -1249,11 +1234,7 @@ static void CL_ParseCenterPrint( void ) {
char string[MAX_STRING_CHARS];
MSG_ReadString( string, sizeof( string ) );
-
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " \"%s\"\n", Q_FormatString( string ) );
- }
-
+ SHOWNET( 2, " \"%s\"\n", string );
SCR_CenterPrint( string );
}
@@ -1266,11 +1247,7 @@ static void CL_ParseStuffText( void ) {
char s[MAX_STRING_CHARS];
MSG_ReadString( s, sizeof( s ) );
-
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " \"%s\"\n", Q_FormatString( s ) );
- }
-
+ SHOWNET( 2, " \"%s\"\n", s );
Cbuf_AddText( &cl_cmdbuf, s );
}
@@ -1281,11 +1258,7 @@ CL_ParseLayout
*/
static void CL_ParseLayout( void ) {
MSG_ReadString( cl.layout, sizeof( cl.layout ) );
-
- if( cl_shownet->integer > 2 ) {
- Com_Printf( " \"%s\"\n", Q_FormatString( cl.layout ) );
- }
-
+ SHOWNET( 2, " \"%s\"\n", cl.layout );
cl.putaway = qfalse;
}
@@ -1379,11 +1352,13 @@ void CL_ParseServerMessage( void ) {
size_t readcount;
int index, bits;
+#ifdef _DEBUG
if( cl_shownet->integer == 1 ) {
Com_Printf( "%"PRIz" ", msg_read.cursize );
} else if( cl_shownet->integer > 1 ) {
Com_Printf( "------------------\n" );
}
+#endif
//
// parse the message
@@ -1396,18 +1371,18 @@ void CL_ParseServerMessage( void ) {
readcount = msg_read.readcount;
if( ( cmd = MSG_ReadByte() ) == -1 ) {
- if( cl_shownet->integer > 1 ) {
- Com_Printf( "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 );
- }
+ SHOWNET( 1, "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 );
break;
}
extrabits = cmd >> SVCMD_BITS;
cmd &= SVCMD_MASK;
+#ifdef _DEBUG
if( cl_shownet->integer > 1 ) {
MSG_ShowSVC( cmd );
}
+#endif
// other commands
switch( cmd ) {
diff --git a/source/cl_pred.c b/source/cl_pred.c
index c240aba..744eb33 100644
--- a/source/cl_pred.c
+++ b/source/cl_pred.c
@@ -67,8 +67,9 @@ void CL_CheckPredictionError( void ) {
// a teleport or something
VectorClear( cl.prediction_error );
} else {
- if( cl_showmiss->integer && ( delta[0] || delta[1] || delta[2] ) ) {
- Com_Printf( "prediction miss on %i: %i (%d %d %d)\n", cl.frame.number, len, delta[0], delta[1], delta[2]);
+ if( delta[0] || delta[1] || delta[2] ) {
+ SHOWMISS( "prediction miss on %i: %i (%d %d %d)\n",
+ cl.frame.number, len, delta[0], delta[1], delta[2]);
}
VectorCopy( ps->pmove.origin, cl.predicted_origins[cmd] );
@@ -203,16 +204,12 @@ void CL_PredictMovement( void ) {
// if we are too far out of date, just freeze
if( current - ack > CMD_BACKUP - 1 ) {
- if( cl_showmiss->integer ) {
- Com_Printf( "%i: exceeded CMD_BACKUP\n", cl.frame.number );
- }
+ SHOWMISS( "%i: exceeded CMD_BACKUP\n", cl.frame.number );
return;
}
if( !cl.cmd.msec && current == ack ) {
- if( cl_showmiss->integer ) {
- Com_Printf( "%i: not moved\n", cl.frame.number );
- }
+ SHOWMISS( "%i: not moved\n", cl.frame.number );
return;
}
diff --git a/source/cl_public.h b/source/cl_public.h
index 5d79bfc..ad24c83 100644
--- a/source/cl_public.h
+++ b/source/cl_public.h
@@ -52,7 +52,7 @@ void CL_ProcessEvents( void );
void CL_ErrorEvent( void );
#endif
void CL_Init (void);
-void CL_Disconnect( comErrorType_t type, const char *text );
+void CL_Disconnect( error_type_t type, const char *text );
void CL_Shutdown (void);
void CL_Frame (unsigned msec);
void CL_LocalConnect( void );
diff --git a/source/cl_scrn.c b/source/cl_scrn.c
index 0319b17..6a7d363 100644
--- a/source/cl_scrn.c
+++ b/source/cl_scrn.c
@@ -1094,9 +1094,11 @@ void SCR_BeginLoadingPlaque( void ) {
if( cls.disable_screen ) {
return;
}
+#ifdef _DEBUG
if( developer->integer ) {
return;
}
+#endif
// if at console or menu, don't bring up the plaque
if( cls.key_dest & (KEY_CONSOLE|KEY_MENU) ) {
return;
diff --git a/source/com_local.h b/source/com_local.h
index eb44fbd..6212c2d 100644
--- a/source/com_local.h
+++ b/source/com_local.h
@@ -542,7 +542,17 @@ void Com_FlushLogs( void );
#define Com_IsDedicated() 1
#endif
+#ifdef _DEBUG
+#define Com_DPrintf(...) \
+ if( developer && developer->integer ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#else
+#define Com_DPrintf(...)
+#endif
+
+#ifdef _DEBUG
extern cvar_t *developer;
+#endif
extern cvar_t *dedicated;
#if USE_CLIENT
extern cvar_t *host_speeds;
diff --git a/source/common.c b/source/common.c
index 50b3592..00feb0a 100644
--- a/source/common.c
+++ b/source/common.c
@@ -45,7 +45,9 @@ static char com_errorMsg[MAXPRINTMSG];
static char **com_argv;
static int com_argc;
+#ifdef _DEBUG
cvar_t *developer;
+#endif
cvar_t *timescale;
cvar_t *fixedtime;
cvar_t *dedicated;
@@ -314,7 +316,7 @@ Both client and server can use this, and it will output
to the apropriate place.
=============
*/
-void Com_Printf( const char *fmt, ... ) {
+void Com_LPrintf( print_type_t type, const char *fmt, ... ) {
va_list argptr;
char msg[MAXPRINTMSG];
static int recursive;
@@ -333,6 +335,17 @@ void Com_Printf( const char *fmt, ... ) {
if( rd_target ) {
Com_Redirect( msg, len );
} else {
+ switch( type ) {
+ case PRINT_WARNING:
+ Com_SetColor( COLOR_YELLOW );
+ break;
+ case PRINT_ERROR:
+ Com_SetColor( COLOR_RED );
+ break;
+ default:
+ break;
+ }
+
#if USE_CLIENT
// graphical console
Con_Print( msg );
@@ -350,6 +363,15 @@ void Com_Printf( const char *fmt, ... ) {
if( com_logFile ) {
logfile_write( msg );
}
+
+ switch( type ) {
+ case PRINT_WARNING:
+ case PRINT_ERROR:
+ Com_SetColor( COLOR_NONE );
+ break;
+ default:
+ break;
+ }
}
recursive--;
@@ -357,61 +379,6 @@ void Com_Printf( const char *fmt, ... ) {
/*
-================
-Com_DPrintf
-
-A Com_Printf that only shows up if the "developer" cvar is set
-================
-*/
-void Com_DPrintf( const char *fmt, ... ) {
- va_list argptr;
- char msg[MAXPRINTMSG];
-
- if( !developer || !developer->integer )
- return; // don't confuse non-developers with techie stuff...
-
- va_start( argptr, fmt );
- Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
- va_end( argptr );
-
- Com_Printf( "%s", msg );
-}
-
-/*
-================
-Com_WPrintf
-
-================
-*/
-void Com_WPrintf( const char *fmt, ... ) {
- va_list argptr;
- char msg[MAXPRINTMSG];
-
- va_start( argptr, fmt );
- Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
- va_end( argptr );
-
- Com_Printf( "WARNING: %s", msg );
-}
-
-/*
-================
-Com_EPrintf
-
-================
-*/
-void Com_EPrintf( const char *fmt, ... ) {
- va_list argptr;
- char msg[MAXPRINTMSG];
-
- va_start( argptr, fmt );
- Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
- va_end( argptr );
-
- Com_Printf( "ERROR: %s", msg );
-}
-
-/*
=============
Com_Error
@@ -419,7 +386,7 @@ Both client and server can use this, and it will
do the apropriate things.
=============
*/
-void Com_Error( comErrorType_t code, const char *fmt, ... ) {
+void Com_Error( error_type_t code, const char *fmt, ... ) {
va_list argptr;
static qboolean recursive;
@@ -442,7 +409,7 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) {
Com_AbortRedirect();
if( code == ERR_DISCONNECT || code == ERR_SILENT ) {
- Com_Printf( "%s\n", com_errorMsg );
+ Com_WPrintf( "%s\n", com_errorMsg );
SV_Shutdown( va( "Server was killed: %s", com_errorMsg ),
KILL_DISCONNECT );
#if USE_CLIENT
@@ -461,9 +428,9 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) {
}
if( code == ERR_DROP ) {
- Com_Printf( "********************\n"
- "ERROR: %s\n"
- "********************\n", com_errorMsg );
+ Com_EPrintf( "********************\n"
+ "ERROR: %s\n"
+ "********************\n", com_errorMsg );
SV_Shutdown( va( "Server crashed: %s\n", com_errorMsg ), KILL_DROP );
#if USE_CLIENT
CL_Disconnect( ERR_DROP, com_errorMsg );
@@ -655,11 +622,11 @@ void Z_LeakTest( memtag_t tag ) {
}
if( numLeaks ) {
- Com_Printf( "************* Z_LeakTest *************\n"
- "%s leaked %"PRIz" bytes of memory (%"PRIz" object%s)\n"
- "**************************************\n",
- z_tagnames[tag < TAG_MAX ? tag : TAG_FREE],
- numBytes, numLeaks, numLeaks == 1 ? "" : "s" );
+ Com_WPrintf( "************* Z_LeakTest *************\n"
+ "%s leaked %"PRIz" bytes of memory (%"PRIz" object%s)\n"
+ "**************************************\n",
+ z_tagnames[tag < TAG_MAX ? tag : TAG_FREE],
+ numBytes, numLeaks, numLeaks == 1 ? "" : "s" );
}
}
@@ -1563,7 +1530,9 @@ void Qcommon_Init( int argc, char **argv ) {
#if USE_CLIENT
host_speeds = Cvar_Get ("host_speeds", "0", 0);
#endif
+#ifdef _DEBUG
developer = Cvar_Get ("developer", "0", 0);
+#endif
timescale = Cvar_Get ("timescale", "1", CVAR_CHEAT );
fixedtime = Cvar_Get ("fixedtime", "0", CVAR_CHEAT );
logfile_enable = Cvar_Get( "logfile", "0", 0 );
diff --git a/source/files.c b/source/files.c
index 15aa260..ad2b9cc 100644
--- a/source/files.c
+++ b/source/files.c
@@ -57,6 +57,13 @@ QUAKE FILESYSTEM
#define MAX_READ 0x40000 // read in blocks of 256k
#define MAX_WRITE 0x40000 // write in blocks of 256k
+#ifdef _DEBUG
+#define FS_DPrintf(...) \
+ if( fs_debug && fs_debug->integer ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#else
+#define FS_DPrintf(...)
+#endif
//
// in memory
@@ -123,7 +130,9 @@ typedef struct fsLink_s {
char fs_gamedir[MAX_OSPATH];
//static char fs_basedir[MAX_OSPATH];
+#ifdef _DEBUG
static cvar_t *fs_debug;
+#endif
static cvar_t *fs_restrict_mask;
static searchpath_t *fs_searchpaths;
@@ -135,7 +144,9 @@ static fsFile_t fs_files[MAX_FILE_HANDLES];
static qboolean fs_fileFromPak;
+#ifdef _DEBUG
static int fs_count_read, fs_count_strcmp, fs_count_open;
+#endif
cvar_t *fs_game;
@@ -209,26 +220,6 @@ int FS_pathcmpn( const char *s1, const char *s2, size_t n ) {
/*
================
-FS_DPrintf
-================
-*/
-static void FS_DPrintf( char *format, ... ) {
- va_list argptr;
- char string[MAXPRINTMSG];
-
- if( !fs_debug || !fs_debug->integer ) {
- return;
- }
-
- va_start( argptr, format );
- Q_vsnprintf( string, sizeof( string ), format, argptr );
- va_end( argptr );
-
- Com_Printf( S_COLOR_CYAN "%s", string );
-}
-
-/*
-================
FS_AllocHandle
================
*/
@@ -714,7 +705,9 @@ static size_t FS_FOpenFileRead( fsFile_t *file, const char *name, qboolean uniqu
size_t len;
fs_fileFromPak = qfalse;
+#ifdef _DEBUG
fs_count_read++;
+#endif
//
// search through the path, one element at a time
@@ -737,7 +730,9 @@ static size_t FS_FOpenFileRead( fsFile_t *file, const char *name, qboolean uniqu
pak = search->pack;
entry = pak->fileHash[ hash & ( pak->hashSize - 1 ) ];
for( ; entry; entry = entry->hashNext ) {
+#ifdef _DEBUG
fs_count_strcmp++;
+#endif
if( !FS_pathcmp( entry->name, name ) ) {
// found it!
return FS_FOpenFromPak( file, pak, entry, unique );
@@ -766,7 +761,9 @@ static size_t FS_FOpenFileRead( fsFile_t *file, const char *name, qboolean uniqu
continue;
}
+#ifdef _DEBUG
fs_count_open++;
+#endif
fp = fopen( fullpath, "rb" );
if( !fp ) {
continue;
@@ -2213,6 +2210,7 @@ static void FS_Stats_f( void ) {
//totalHashSize += pack->hashSize;
}
+#ifdef _DEBUG
#if USE_LOADBUF
Com_Printf( "LoadFile counter: %d\n", loadCount );
Com_Printf( "Static LoadFile counter: %d\n", loadCountStatic );
@@ -2233,6 +2231,7 @@ static void FS_Stats_f( void ) {
Com_Printf( "%s\n", file->name );
}
}
+#endif // _DEBUG
}
static void FS_Link_g( genctx_t *ctx ) {
@@ -2596,7 +2595,9 @@ void FS_Init( void ) {
Cmd_Register( c_fs );
+#ifdef _DEBUG
fs_debug = Cvar_Get( "fs_debug", "0", 0 );
+#endif
fs_restrict_mask = Cvar_Get( "fs_restrict_mask", "0", CVAR_NOSET );
Cvar_Get( "fs_gamedir", "", CVAR_ROM );
diff --git a/source/mvd_client.c b/source/mvd_client.c
index a134173..4e46647 100644
--- a/source/mvd_client.c
+++ b/source/mvd_client.c
@@ -105,7 +105,7 @@ int mvd_chanid;
jmp_buf mvd_jmpbuf;
-#if USE_CLIENT
+#ifdef _DEBUG
cvar_t *mvd_shownet;
#endif
@@ -1191,7 +1191,7 @@ static neterr_t run_connect( gtv_t *gtv ) {
static neterr_t run_stream( gtv_t *gtv ) {
neterr_t ret;
-#if USE_CLIENT
+#ifdef _DEBUG
int count;
size_t usage;
#endif
@@ -1201,7 +1201,7 @@ static neterr_t run_stream( gtv_t *gtv ) {
return ret;
}
-#if USE_CLIENT
+#ifdef _DEBUG
count = 0;
usage = FIFO_Usage( &gtv->stream.recv );
#endif
@@ -1216,19 +1216,19 @@ static neterr_t run_stream( gtv_t *gtv ) {
if( !parse_message( gtv, &gtv->z_buf ) ) {
break;
}
-#if USE_CLIENT
+#ifdef _DEBUG
count++;
#endif
}
} else
#endif
while( parse_message( gtv, &gtv->stream.recv ) ) {
-#if USE_CLIENT
+#ifdef _DEBUG
count++;
#endif
}
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer == -1 ) {
size_t total = usage - FIFO_Usage( &gtv->stream.recv );
@@ -2116,7 +2116,7 @@ MVD_Register
==============
*/
void MVD_Register( void ) {
-#if USE_CLIENT
+#ifdef _DEBUG
mvd_shownet = Cvar_Get( "mvd_shownet", "0", 0 );
#endif
mvd_timeout = Cvar_Get( "mvd_timeout", "90", 0 );
diff --git a/source/mvd_local.h b/source/mvd_local.h
index 9042dc2..a5c906b 100644
--- a/source/mvd_local.h
+++ b/source/mvd_local.h
@@ -162,7 +162,7 @@ extern list_t mvd_channel_list;
extern mvd_t mvd_waitingRoom;
extern qboolean mvd_dirty;
-#if USE_CLIENT
+#ifdef _DEBUG
extern cvar_t *mvd_shownet;
#endif
diff --git a/source/mvd_parse.c b/source/mvd_parse.c
index f2d74cb..b9d77fb 100644
--- a/source/mvd_parse.c
+++ b/source/mvd_parse.c
@@ -24,7 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mvd_local.h"
-#if USE_CLIENT
+#ifdef _DEBUG
+#define SHOWNET(level,...) \
+ if( mvd_shownet->integer > level ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
#define MVD_ShowSVC( cmd ) \
Com_Printf( "%3"PRIz":%s\n", msg_read.readcount - 1, \
@@ -53,8 +56,9 @@ static const char *MVD_ServerCommandString( int cmd ) {
M(print)
}
}
-
-#endif // USE_CLIENT
+#else
+#define SHOWNET(...)
+#endif
static void MVD_LinkEdict( mvd_t *mvd, edict_t *ent ) {
int index;
@@ -437,7 +441,7 @@ static void MVD_ParseUnicast( mvd_t *mvd, mvd_ops_t op, int extrabits ) {
while( msg_read.readcount < last ) {
cmd = MSG_ReadByte();
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer > 1 ) {
MSG_ShowSVC( cmd );
}
@@ -456,11 +460,7 @@ static void MVD_ParseUnicast( mvd_t *mvd, mvd_ops_t op, int extrabits ) {
MVD_UnicastStuff( mvd, reliable, player );
break;
default:
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%"PRIz":SKIPPING UNICAST\n", msg_read.readcount - 1 );
- }
-#endif
+ SHOWNET( 1, "%"PRIz":SKIPPING UNICAST\n", msg_read.readcount - 1 );
// send remaining data and return
data = msg_read.data + msg_read.readcount - 1;
length = last - msg_read.readcount + 1;
@@ -470,11 +470,7 @@ static void MVD_ParseUnicast( mvd_t *mvd, mvd_ops_t op, int extrabits ) {
}
}
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%"PRIz":END OF UNICAST\n", msg_read.readcount - 1 );
- }
-#endif
+ SHOWNET( 1, "%"PRIz":END OF UNICAST\n", msg_read.readcount - 1 );
if( msg_read.readcount > last ) {
MVD_Destroyf( mvd, "%s: read past end of unicast", __func__ );
@@ -771,7 +767,7 @@ static void MVD_ParsePacketEntities( mvd_t *mvd ) {
ent = &mvd->edicts[number];
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer > 2 ) {
Com_Printf( " %s: %d ", ent->inuse ?
"delta" : "baseline", number );
@@ -788,11 +784,7 @@ static void MVD_ParsePacketEntities( mvd_t *mvd ) {
}
if( bits & U_REMOVE ) {
-#if USE_CLIENT
- if( mvd_shownet->integer > 2 ) {
- Com_Printf( " remove: %d\n", number );
- }
-#endif
+ SHOWNET( 2, " remove: %d\n", number );
ent->inuse = qfalse;
continue;
}
@@ -832,7 +824,7 @@ static void MVD_ParsePacketPlayers( mvd_t *mvd ) {
bits = MSG_ReadShort();
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer > 2 ) {
Com_Printf( " %s: %d ", player->inuse ?
"delta" : "baseline", number );
@@ -844,11 +836,7 @@ static void MVD_ParsePacketPlayers( mvd_t *mvd ) {
MSG_ParseDeltaPlayerstate_Packet( &player->ps, &player->ps, bits );
if( bits & PPS_REMOVE ) {
-#if USE_CLIENT
- if( mvd_shownet->integer > 2 ) {
- Com_Printf( " remove: %d\n", number );
- }
-#endif
+ SHOWNET( 2, " remove: %d\n", number );
player->inuse = qfalse;
continue;
}
@@ -881,28 +869,11 @@ static void MVD_ParseFrame( mvd_t *mvd ) {
CM_SetPortalStates( &mvd->cm, NULL, 0 );
}
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%3"PRIz":playerinfo\n", msg_read.readcount - 1 );
- }
-#endif
-
+ SHOWNET( 1, "%3"PRIz":playerinfo\n", msg_read.readcount - 1 );
MVD_ParsePacketPlayers( mvd );
-
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%3"PRIz":packetentities\n", msg_read.readcount - 1 );
- }
-#endif
-
+ SHOWNET( 1, "%3"PRIz":packetentities\n", msg_read.readcount - 1 );
MVD_ParsePacketEntities( mvd );
-
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%3"PRIz":frame:%u\n", msg_read.readcount - 1, mvd->framenum );
- }
-#endif
-
+ SHOWNET( 1, "%3"PRIz":frame:%u\n", msg_read.readcount - 1, mvd->framenum );
MVD_PlayerToEntityStates( mvd );
mvd->framenum++;
@@ -1118,7 +1089,7 @@ static void MVD_ParseServerData( mvd_t *mvd, int extrabits ) {
void MVD_ParseMessage( mvd_t *mvd ) {
int cmd, extrabits;
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer == 1 ) {
Com_Printf( "%"PRIz" ", msg_read.cursize );
} else if( mvd_shownet->integer > 1 ) {
@@ -1134,11 +1105,7 @@ void MVD_ParseMessage( mvd_t *mvd ) {
MVD_Destroyf( mvd, "Read past end of message" );
}
if( msg_read.readcount == msg_read.cursize ) {
-#if USE_CLIENT
- if( mvd_shownet->integer > 1 ) {
- Com_Printf( "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 );
- }
-#endif
+ SHOWNET( 1, "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 );
break;
}
@@ -1146,7 +1113,7 @@ void MVD_ParseMessage( mvd_t *mvd ) {
extrabits = cmd >> SVCMD_BITS;
cmd &= SVCMD_MASK;
-#if USE_CLIENT
+#ifdef _DEBUG
if( mvd_shownet->integer > 1 ) {
MVD_ShowSVC( cmd );
}
diff --git a/source/net_chan.c b/source/net_chan.c
index 022a189..36dd5c3 100644
--- a/source/net_chan.c
+++ b/source/net_chan.c
@@ -80,8 +80,19 @@ then a packet only needs to be delivered if there is something in the
unacknowledged reliable
*/
+#ifdef _DEBUG
static cvar_t *showpackets;
static cvar_t *showdrop;
+#define SHOWPACKET(...) \
+ if( showpackets->integer ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#define SHOWDROP(...) \
+ if( showdrop->integer ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#else
+#define SHOWPACKET(...)
+#define SHOWDROP(...)
+#endif
cvar_t *net_qport;
cvar_t *net_maxmsglen;
@@ -98,11 +109,13 @@ Netchan_Init
void Netchan_Init( void ) {
int port;
- // pick a port value that should be nice and random
- port = Sys_Milliseconds() & 0xffff;
-
+#ifdef _DEBUG
showpackets = Cvar_Get( "showpackets", "0", 0 );
showdrop = Cvar_Get( "showdrop", "0", 0 );
+#endif
+
+ // pick a port value that should be nice and random
+ port = Sys_Milliseconds() & 0xffff;
net_qport = Cvar_Get( "qport", va( "%d", port ), 0 );
net_maxmsglen = Cvar_Get( "net_maxmsglen", "1390", 0 );
net_chantype = Cvar_Get( "net_chantype", "1", 0 );
@@ -230,19 +243,15 @@ static size_t NetchanOld_Transmit( netchan_t *netchan, size_t length, const void
Com_WPrintf( "%s: dumped unreliable\n",
NET_AdrToString( &netchan->remote_address ) );
-#if USE_CLIENT
- if( showpackets->integer ) {
- Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d",
- send.cursize,
- netchan->outgoing_sequence - 1,
- netchan->incoming_sequence,
- chan->incoming_reliable_sequence );
- if( send_reliable ) {
- Com_Printf( " reliable=%i", chan->reliable_sequence );
- }
- Com_Printf( "\n" );
+ SHOWPACKET( "send %4"PRIz" : s=%d ack=%d rack=%d",
+ send.cursize,
+ netchan->outgoing_sequence - 1,
+ netchan->incoming_sequence,
+ chan->incoming_reliable_sequence );
+ if( send_reliable ) {
+ SHOWPACKET( " reliable=%i", chan->reliable_sequence );
}
-#endif
+ SHOWPACKET( "\n" );
// send the datagram
for( i = 0; i < numpackets; i++ ) {
@@ -289,29 +298,23 @@ static qboolean NetchanOld_Process( netchan_t *netchan ) {
sequence &= ~( 1 << 31 );
sequence_ack &= ~( 1 << 31 );
-#if USE_CLIENT
- if( showpackets->integer ) {
- Com_Printf( "recv %4"PRIz" : s=%d ack=%d rack=%d",
- msg_read.cursize,
- sequence,
- sequence_ack,
- reliable_ack );
- if( reliable_message ) {
- Com_Printf( " reliable=%d", chan->incoming_reliable_sequence ^ 1 );
- }
- Com_Printf( "\n" );
+ SHOWPACKET( "recv %4"PRIz" : s=%d ack=%d rack=%d",
+ msg_read.cursize,
+ sequence,
+ sequence_ack,
+ reliable_ack );
+ if( reliable_message ) {
+ SHOWPACKET( " reliable=%d", chan->incoming_reliable_sequence ^ 1 );
}
-#endif
+ SHOWPACKET( "\n" );
//
// discard stale or duplicated packets
//
if( sequence <= netchan->incoming_sequence ) {
- if( showdrop->integer )
- Com_Printf( "%s: out of order packet %i at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- sequence,
- netchan->incoming_sequence );
+ SHOWDROP( "%s: out of order packet %i at %i\n",
+ NET_AdrToString( &netchan->remote_address ),
+ sequence, netchan->incoming_sequence );
return qfalse;
}
@@ -320,11 +323,9 @@ static qboolean NetchanOld_Process( netchan_t *netchan ) {
//
netchan->dropped = sequence - ( netchan->incoming_sequence + 1 );
if( netchan->dropped > 0 ) {
- if( showdrop->integer )
- Com_Printf( "%s: dropped %i packets at %i\n",
+ SHOWDROP( "%s: dropped %i packets at %i\n",
NET_AdrToString( &netchan->remote_address ),
- netchan->dropped,
- sequence );
+ netchan->dropped, sequence );
}
//
@@ -469,22 +470,18 @@ static size_t NetchanNew_TransmitNextFragment( netchan_t *netchan ) {
SZ_Write( &send, chan->fragment_out.data + chan->fragment_out.readcount,
fragment_length );
-#if USE_CLIENT
- if( showpackets->integer ) {
- Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d "
- "fragment_offset=%"PRIz" more_fragments=%d",
- send.cursize,
- netchan->outgoing_sequence,
- netchan->incoming_sequence,
- chan->incoming_reliable_sequence,
- chan->fragment_out.readcount,
- more_fragments );
- if( send_reliable ) {
- Com_Printf( " reliable=%i ", chan->reliable_sequence );
- }
- Com_Printf( "\n" );
+ SHOWPACKET( "send %4"PRIz" : s=%d ack=%d rack=%d "
+ "fragment_offset=%"PRIz" more_fragments=%d",
+ send.cursize,
+ netchan->outgoing_sequence,
+ netchan->incoming_sequence,
+ chan->incoming_reliable_sequence,
+ chan->fragment_out.readcount,
+ more_fragments );
+ if( send_reliable ) {
+ SHOWPACKET( " reliable=%i ", chan->reliable_sequence );
}
-#endif
+ SHOWPACKET( "\n" );
chan->fragment_out.readcount += fragment_length;
netchan->fragment_pending = more_fragments;
@@ -594,19 +591,15 @@ static size_t NetchanNew_Transmit( netchan_t *netchan, size_t length, const void
// add the unreliable part
SZ_Write( &send, data, length );
-#if USE_CLIENT
- if( showpackets->integer ) {
- Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d",
- send.cursize,
- netchan->outgoing_sequence - 1,
- netchan->incoming_sequence,
- chan->incoming_reliable_sequence );
- if( send_reliable ) {
- Com_Printf( " reliable=%d", chan->reliable_sequence );
- }
- Com_Printf( "\n" );
+ SHOWPACKET( "send %4"PRIz" : s=%d ack=%d rack=%d",
+ send.cursize,
+ netchan->outgoing_sequence - 1,
+ netchan->incoming_sequence,
+ chan->incoming_reliable_sequence );
+ if( send_reliable ) {
+ SHOWPACKET( " reliable=%d", chan->reliable_sequence );
}
-#endif
+ SHOWPACKET( "\n" );
// send the datagram
for( i = 0; i < numpackets; i++ ) {
@@ -657,30 +650,24 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) {
fragment_offset &= 0x7FFF;
}
-#if USE_CLIENT
- if( showpackets->integer ) {
- Com_Printf( "recv %4"PRIz" : s=%d ack=%d rack=%d",
- msg_read.cursize, sequence, sequence_ack, reliable_ack );
- if( fragmented_message ) {
- Com_Printf( " fragment_offset=%d more_fragments=%d",
- fragment_offset, more_fragments );
- }
- if( reliable_message ) {
- Com_Printf( " reliable=%d", chan->incoming_reliable_sequence ^ 1 );
- }
- Com_Printf( "\n" );
+ SHOWPACKET( "recv %4"PRIz" : s=%d ack=%d rack=%d",
+ msg_read.cursize, sequence, sequence_ack, reliable_ack );
+ if( fragmented_message ) {
+ SHOWPACKET( " fragment_offset=%d more_fragments=%d",
+ fragment_offset, more_fragments );
}
-#endif
+ if( reliable_message ) {
+ SHOWPACKET( " reliable=%d", chan->incoming_reliable_sequence ^ 1 );
+ }
+ SHOWPACKET( "\n" );
//
// discard stale or duplicated packets
//
if( sequence <= netchan->incoming_sequence ) {
- if( showdrop->integer || showpackets->integer ) {
- Com_Printf( "%s: out of order packet %i at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- sequence, netchan->incoming_sequence );
- }
+ SHOWDROP( "%s: out of order packet %i at %i\n",
+ NET_AdrToString( &netchan->remote_address ),
+ sequence, netchan->incoming_sequence );
return qfalse;
}
@@ -689,11 +676,9 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) {
//
netchan->dropped = sequence - ( netchan->incoming_sequence + 1 );
if( netchan->dropped > 0 ) {
- if( showdrop->integer || showpackets->integer ) {
- Com_Printf( "%s: dropped %i packets at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- netchan->dropped, sequence );
- }
+ SHOWDROP( "%s: dropped %i packets at %i\n",
+ NET_AdrToString( &netchan->remote_address ),
+ netchan->dropped, sequence );
}
//
@@ -717,30 +702,21 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) {
}
if( fragment_offset < chan->fragment_in.cursize ) {
- if( showdrop->integer || showpackets->integer ) {
- Com_Printf( "%s: out of order fragment at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- sequence );
- }
+ SHOWDROP( "%s: out of order fragment at %i\n",
+ NET_AdrToString( &netchan->remote_address ), sequence );
return qfalse;
}
if( fragment_offset > chan->fragment_in.cursize ) {
- if( showdrop->integer || showpackets->integer ) {
- Com_Printf( "%s: dropped fragment(s) at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- sequence );
- }
+ SHOWDROP( "%s: dropped fragment(s) at %i\n",
+ NET_AdrToString( &netchan->remote_address ), sequence );
return qfalse;
}
length = msg_read.cursize - msg_read.readcount;
if( chan->fragment_in.cursize + length > chan->fragment_in.maxsize ) {
- if( showdrop->integer || showpackets->integer ) {
- Com_Printf( "%s: oversize fragment at %i\n",
- NET_AdrToString( &netchan->remote_address ),
- sequence );
- }
+ SHOWDROP( "%s: oversize fragment at %i\n",
+ NET_AdrToString( &netchan->remote_address ), sequence );
return qfalse;
}
diff --git a/source/prompt.c b/source/prompt.c
index 85c1f22..54b9dfa 100644
--- a/source/prompt.c
+++ b/source/prompt.c
@@ -101,7 +101,7 @@ static void Prompt_ShowIndividualMatches(
if( numCommands ) {
qsort( matches + offset, numCommands, sizeof( matches[0] ), SortStrcmp );
- prompt->printf( "\n" S_COLOR_YELLOW "%i possible command%s:\n",
+ prompt->printf( "\n%i possible command%s:\n",
numCommands, numCommands != 1 ? "s" : "" );
Prompt_ShowMatches( prompt, matches, offset, offset + numCommands );
@@ -111,7 +111,7 @@ static void Prompt_ShowIndividualMatches(
if( numCvars ) {
qsort( matches + offset, numCvars, sizeof( matches[0] ), SortStrcmp );
- prompt->printf( "\n" S_COLOR_YELLOW "%i possible variable%s:\n",
+ prompt->printf( "\n%i possible variable%s:\n",
numCvars, numCvars != 1 ? "s" : "" );
Prompt_ShowMatches( prompt, matches, offset, offset + numCvars );
@@ -121,7 +121,7 @@ static void Prompt_ShowIndividualMatches(
if( numAliases ) {
qsort( matches + offset, numAliases, sizeof( matches[0] ), SortStrcmp );
- prompt->printf( "\n" S_COLOR_YELLOW "%i possible alias%s:\n",
+ prompt->printf( "\n%i possible alias%s:\n",
numAliases, numAliases != 1 ? "es" : "" );
Prompt_ShowMatches( prompt, matches, offset, offset + numAliases );
diff --git a/source/q_msg.c b/source/q_msg.c
index e34ca21..bbfd655 100644
--- a/source/q_msg.c
+++ b/source/q_msg.c
@@ -2339,87 +2339,12 @@ void MSG_ParseDeltaPlayerstate_Packet( const player_state_t *from,
#endif // USE_MVD_CLIENT
-#if USE_CLIENT
+#ifdef _DEBUG
#define SHOWBITS( data ) \
do { Com_Printf( "%s ", data ); } while( 0 )
-void MSG_ShowDeltaEntityBits( int bits ) {
- if( bits & U_MODEL ) {
- SHOWBITS( "modelindex" );
- }
- if( bits & U_MODEL2 ) {
- SHOWBITS( "modelindex2" );
- }
- if( bits & U_MODEL3 ) {
- SHOWBITS( "modelindex3" );
- }
- if( bits & U_MODEL4 ) {
- SHOWBITS( "modelindex4" );
- }
-
- if( bits & U_FRAME8 )
- SHOWBITS( "frame8" );
- if( bits & U_FRAME16 )
- SHOWBITS( "frame16" );
-
- if( ( bits & ( U_SKIN8 | U_SKIN16 ) ) == ( U_SKIN8 | U_SKIN16 ) )
- SHOWBITS( "skinnum32" );
- else if( bits & U_SKIN8 )
- SHOWBITS( "skinnum8" );
- else if( bits & U_SKIN16 )
- SHOWBITS( "skinnum16" );
-
- if( ( bits & ( U_EFFECTS8 | U_EFFECTS16 ) ) == ( U_EFFECTS8 | U_EFFECTS16 ) )
- SHOWBITS( "effects32" );
- else if( bits & U_EFFECTS8 )
- SHOWBITS( "effects8" );
- else if( bits & U_EFFECTS16 )
- SHOWBITS( "effects16" );
-
- if( ( bits & ( U_RENDERFX8 | U_RENDERFX16 ) ) == ( U_RENDERFX8 | U_RENDERFX16 ) )
- SHOWBITS( "renderfx32" );
- else if( bits & U_RENDERFX8 )
- SHOWBITS( "renderfx8" );
- else if( bits & U_RENDERFX16 )
- SHOWBITS( "renderfx16" );
-
- if( bits & U_ORIGIN1 ) {
- SHOWBITS( "origin[0]" );
- }
- if( bits & U_ORIGIN2 ) {
- SHOWBITS( "origin[1]" );
- }
- if( bits & U_ORIGIN3 ) {
- SHOWBITS( "origin[2]" );
- }
-
- if( bits & U_ANGLE1 ) {
- SHOWBITS( "angles[0]" );
- }
- if( bits & U_ANGLE2 ) {
- SHOWBITS( "angles[2]" );
- }
- if( bits & U_ANGLE3 ) {
- SHOWBITS( "angles[3]" );
- }
-
- if( bits & U_OLDORIGIN ) {
- SHOWBITS( "old_origin" );
- }
-
- if( bits & U_SOUND ) {
- SHOWBITS( "sound" );
- }
-
- if( bits & U_EVENT ) {
- SHOWBITS( "event" );
- }
-
- if( bits & U_SOLID ) {
- SHOWBITS( "solid" );
- }
-}
+#if USE_CLIENT
void MSG_ShowDeltaPlayerstateBits_Default( int flags ) {
if( flags & PS_M_TYPE ) {
@@ -2574,6 +2499,113 @@ void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags ) {
}
}
+
+void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ) {
+ if( !bits ) {
+ SHOWBITS( "<none>" );
+ return;
+ }
+ if( bits & CM_ANGLE1 )
+ SHOWBITS( "angle1" );
+ if( bits & CM_ANGLE2 )
+ SHOWBITS( "angle2" );
+ if( bits & CM_ANGLE3 )
+ SHOWBITS( "angle3" );
+
+ if( bits & CM_FORWARD )
+ SHOWBITS( "forward" );
+ if( bits & CM_SIDE )
+ SHOWBITS( "side" );
+ if( bits & CM_UP )
+ SHOWBITS( "up" );
+
+ if( bits & CM_BUTTONS )
+ SHOWBITS( "buttons" );
+ if( bits & CM_IMPULSE )
+ SHOWBITS( "msec" );
+}
+
+#endif // USE_CLIENT
+
+#if USE_CLIENT || USE_MVD_CLIENT
+
+void MSG_ShowDeltaEntityBits( int bits ) {
+ if( bits & U_MODEL ) {
+ SHOWBITS( "modelindex" );
+ }
+ if( bits & U_MODEL2 ) {
+ SHOWBITS( "modelindex2" );
+ }
+ if( bits & U_MODEL3 ) {
+ SHOWBITS( "modelindex3" );
+ }
+ if( bits & U_MODEL4 ) {
+ SHOWBITS( "modelindex4" );
+ }
+
+ if( bits & U_FRAME8 )
+ SHOWBITS( "frame8" );
+ if( bits & U_FRAME16 )
+ SHOWBITS( "frame16" );
+
+ if( ( bits & ( U_SKIN8 | U_SKIN16 ) ) == ( U_SKIN8 | U_SKIN16 ) )
+ SHOWBITS( "skinnum32" );
+ else if( bits & U_SKIN8 )
+ SHOWBITS( "skinnum8" );
+ else if( bits & U_SKIN16 )
+ SHOWBITS( "skinnum16" );
+
+ if( ( bits & ( U_EFFECTS8 | U_EFFECTS16 ) ) == ( U_EFFECTS8 | U_EFFECTS16 ) )
+ SHOWBITS( "effects32" );
+ else if( bits & U_EFFECTS8 )
+ SHOWBITS( "effects8" );
+ else if( bits & U_EFFECTS16 )
+ SHOWBITS( "effects16" );
+
+ if( ( bits & ( U_RENDERFX8 | U_RENDERFX16 ) ) == ( U_RENDERFX8 | U_RENDERFX16 ) )
+ SHOWBITS( "renderfx32" );
+ else if( bits & U_RENDERFX8 )
+ SHOWBITS( "renderfx8" );
+ else if( bits & U_RENDERFX16 )
+ SHOWBITS( "renderfx16" );
+
+ if( bits & U_ORIGIN1 ) {
+ SHOWBITS( "origin[0]" );
+ }
+ if( bits & U_ORIGIN2 ) {
+ SHOWBITS( "origin[1]" );
+ }
+ if( bits & U_ORIGIN3 ) {
+ SHOWBITS( "origin[2]" );
+ }
+
+ if( bits & U_ANGLE1 ) {
+ SHOWBITS( "angles[0]" );
+ }
+ if( bits & U_ANGLE2 ) {
+ SHOWBITS( "angles[2]" );
+ }
+ if( bits & U_ANGLE3 ) {
+ SHOWBITS( "angles[3]" );
+ }
+
+ if( bits & U_OLDORIGIN ) {
+ SHOWBITS( "old_origin" );
+ }
+
+ if( bits & U_SOUND ) {
+ SHOWBITS( "sound" );
+ }
+
+ if( bits & U_EVENT ) {
+ SHOWBITS( "event" );
+ }
+
+ if( bits & U_SOLID ) {
+ SHOWBITS( "solid" );
+ }
+}
+
void MSG_ShowDeltaPlayerstateBits_Packet( int flags ) {
if( flags & PPS_M_TYPE ) {
SHOWBITS( "pmove.pm_type" );
@@ -2636,31 +2668,6 @@ void MSG_ShowDeltaPlayerstateBits_Packet( int flags ) {
}
}
-void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ) {
- if( !bits ) {
- SHOWBITS( "<none>" );
- return;
- }
- if( bits & CM_ANGLE1 )
- SHOWBITS( "angle1" );
- if( bits & CM_ANGLE2 )
- SHOWBITS( "angle2" );
- if( bits & CM_ANGLE3 )
- SHOWBITS( "angle3" );
-
- if( bits & CM_FORWARD )
- SHOWBITS( "forward" );
- if( bits & CM_SIDE )
- SHOWBITS( "side" );
- if( bits & CM_UP )
- SHOWBITS( "up" );
-
- if( bits & CM_BUTTONS )
- SHOWBITS( "buttons" );
- if( bits & CM_IMPULSE )
- SHOWBITS( "msec" );
-}
-
const char *MSG_ServerCommandString( int cmd ) {
switch( cmd ) {
case -1: return "END OF MESSAGE";
@@ -2694,7 +2701,9 @@ const char *MSG_ServerCommandString( int cmd ) {
}
}
-#endif // USE_CLIENT
+#endif // USE_CLIENT || USE_MVD_CLIENT
+
+#endif // _DEBUG
//===========================================================================
@@ -2735,7 +2744,7 @@ void *SZ_GetSpace( sizebuf_t *buf, size_t length ) {
__func__, buf->tag, length, buf->maxsize );
}
- Com_DPrintf( "%s: %#x: overflow\n", __func__, buf->tag );
+ //Com_DPrintf( "%s: %#x: overflow\n", __func__, buf->tag );
SZ_Clear( buf );
buf->overflowed = qtrue;
}
diff --git a/source/q_msg.h b/source/q_msg.h
index 2e41eb0..9aea1ce 100644
--- a/source/q_msg.h
+++ b/source/q_msg.h
@@ -140,16 +140,18 @@ void MSG_ParseDeltaPlayerstate_Enhanced( const player_state_t *from, player_s
#endif
void MSG_ParseDeltaPlayerstate_Packet( const player_state_t *from, player_state_t *to, int flags );
+#ifdef _DEBUG
#if USE_CLIENT
-void MSG_ShowDeltaEntityBits( int bits );
void MSG_ShowDeltaPlayerstateBits_Default( int flags );
void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags );
-void MSG_ShowDeltaPlayerstateBits_Packet( int flags );
void MSG_ShowDeltaUsercmdBits_Enhanced( int bits );
+#endif
+#if USE_CLIENT || USE_MVD_CLIENT
+void MSG_ShowDeltaEntityBits( int bits );
+void MSG_ShowDeltaPlayerstateBits_Packet( int flags );
const char *MSG_ServerCommandString( int cmd );
-
#define MSG_ShowSVC( cmd ) \
- Com_Printf( "%3"PRIz":%s\n", msg_read.readcount - 1, \
+ Com_LPrintf( PRINT_DEVELOPER, "%3"PRIz":%s\n", msg_read.readcount - 1, \
MSG_ServerCommandString( cmd ) )
-
-#endif // USE_CLIENT
+#endif // USE_CLIENT || USE_MVD_CLIENT
+#endif // _DEBUG
diff --git a/source/q_shared.c b/source/q_shared.c
index 5a27132..8706ddb 100644
--- a/source/q_shared.c
+++ b/source/q_shared.c
@@ -512,80 +512,20 @@ int Q_HighlightStr( char *out, const char *in, int bufsize ) {
Q_IsWhiteSpace
================
*/
-qboolean Q_IsWhiteSpace( const char *string ) {
- while( *string ) {
- if( ( *string & 127 ) > 32 ) {
+qboolean Q_IsWhiteSpace( const char *s ) {
+ int c;
+
+ while( *s ) {
+ c = *s++;
+ c &= 127;
+ if( Q_isgraph( c ) ) {
return qfalse;
}
- string++;
}
return qtrue;
}
-/*
-================
-Q_FormatString
-
-replaces some common escape codes and unprintable characters
-================
-*/
-char *Q_FormatString( const char *string ) {
- static char buffer[MAX_STRING_CHARS];
- char *dst;
- int c;
-
- dst = buffer;
- while( *string ) {
- c = *string++;
-
- switch( c ) {
- case '\t':
- *dst++ = '\\';
- *dst++ = 't';
- break;
- case '\b':
- *dst++ = '\\';
- *dst++ = 'b';
- break;
- case '\r':
- *dst++ = '\\';
- *dst++ = 'r';
- break;
- case '\n':
- *dst++ = '\\';
- *dst++ = 'n';
- break;
- case '\\':
- *dst++ = '\\';
- *dst++ = '\\';
- break;
- case '\"':
- *dst++ = '\\';
- *dst++ = '\"';
- break;
- default:
- if( c < 32 || c >= 127 ) {
- *dst++ = '\\';
- *dst++ = 'x';
- *dst++ = hexchars[c >> 4];
- *dst++ = hexchars[c & 15];
- } else {
- *dst++ = c;
- }
- break;
- }
-
- if( dst - buffer >= MAX_STRING_CHARS - 4 ) {
- break;
- }
- }
-
- *dst = 0;
-
- return buffer;
-}
-
size_t Q_FormatFileSize( char *dest, size_t bytes, size_t size ) {
if( bytes >= 1000000 ) {
return Q_snprintf( dest, size, "%2.1fM", ( float )bytes / 1000000 );
diff --git a/source/q_shared.h b/source/q_shared.h
index fe07962..d8cc113 100644
--- a/source/q_shared.h
+++ b/source/q_shared.h
@@ -112,26 +112,28 @@ typedef int fileHandle_t;
#define MAX_CLIENT_NAME 16
-typedef enum comErrorType_e {
+typedef enum {
ERR_FATAL, // exit the entire game with a popup window
ERR_DROP, // print to console and disconnect from game
ERR_DISCONNECT, // don't kill server
ERR_SILENT
-} comErrorType_t;
+} error_type_t;
-typedef enum comPrintType_e {
+typedef enum {
PRINT_ALL, // general messages
PRINT_DEVELOPER, // only print when "developer 1"
PRINT_WARNING, // print in yellow color
PRINT_ERROR // print in red color
-} comPrintType_t;
+} print_type_t;
-void Com_Printf( const char *fmt, ... ) q_printf( 1, 2 );
-void Com_DPrintf( const char *fmt, ... ) q_printf( 1, 2 );
-void Com_WPrintf( const char *fmt, ... ) q_printf( 1, 2 );
-void Com_EPrintf( const char *fmt, ... ) q_printf( 1, 2 );
-void Com_Error( comErrorType_t code, const char *fmt, ... )
- q_noreturn q_printf( 2, 3 );
+void Com_LPrintf( print_type_t type, const char *fmt, ... )
+ q_printf( 2, 3 );
+void Com_Error( error_type_t code, const char *fmt, ... )
+ q_noreturn q_printf( 2, 3 );
+
+#define Com_Printf(...) Com_LPrintf( PRINT_ALL, __VA_ARGS__ )
+#define Com_WPrintf(...) Com_LPrintf( PRINT_WARNING, __VA_ARGS__ )
+#define Com_EPrintf(...) Com_LPrintf( PRINT_ERROR, __VA_ARGS__ )
// game print flags
#define PRINT_LOW 0 // pickup messages
@@ -140,7 +142,7 @@ void Com_Error( comErrorType_t code, const char *fmt, ... )
#define PRINT_CHAT 3 // chat messages
// destination class for gi.multicast()
-typedef enum multicast_e {
+typedef enum {
MULTICAST_ALL,
MULTICAST_PHS,
MULTICAST_PVS,
@@ -329,7 +331,6 @@ static inline int rand_byte( void ) {
#define Q_ClearBit( data, bit ) ( (data)[(bit) >> 3] &= ~( 1 << ( (bit) & 7 ) ) )
qboolean Q_IsWhiteSpace( const char *string );
-char *Q_FormatString( const char *string );
size_t Q_FormatFileSize( char *dest, size_t bytes, size_t size );
int Q_ClearStr( char *out, const char *in, int bufsize );
int Q_HighlightStr( char *out, const char *in, int bufsize );
diff --git a/source/snd_main.c b/source/snd_main.c
index 688e4f6..9930967 100644
--- a/source/snd_main.c
+++ b/source/snd_main.c
@@ -72,7 +72,9 @@ static cvar_t *s_enable;
#if USE_DSOUND
static cvar_t *s_direct;
#endif
+#ifdef _DEBUG
static cvar_t *s_show;
+#endif
static cvar_t *s_mixahead;
static cvar_t *s_ambient;
@@ -182,7 +184,9 @@ void S_Init( void ) {
s_volume = Cvar_Get( "s_volume", "0.7", CVAR_ARCHIVE );
s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE );
+#ifdef _DEBUG
s_show = Cvar_Get( "s_show", "0", 0 );
+#endif
s_testsound = Cvar_Get( "s_testsound", "0", 0 );
s_ambient = Cvar_Get( "s_ambient", "1", 0 );
@@ -590,8 +594,10 @@ void S_IssuePlaysound( playsound_t *ps ) {
channel_t *ch;
sfxcache_t *sc;
+#ifdef _DEBUG
if( s_show->integer )
Com_Printf( "Issue %i\n", ps->begin );
+#endif
// pick a channel to play on
ch = S_PickChannel( ps->entnum, ps->entchannel );
if( !ch ) {
@@ -994,7 +1000,6 @@ Called once each time through the main loop
*/
void S_Update( void ) {
int i;
- int total;
channel_t *ch;
if( cvar_modified & CVAR_SOUND ) {
@@ -1049,12 +1054,13 @@ void S_Update( void ) {
// add loopsounds
S_AddLoopSounds ();
+#ifdef _DEBUG
//
// debugging output
//
if (s_show->integer)
{
- total = 0;
+ int total = 0;
ch = channels;
for (i=0 ; i<MAX_CHANNELS; i++, ch++)
if (ch->sfx && (ch->leftvol || ch->rightvol) )
@@ -1067,6 +1073,7 @@ void S_Update( void ) {
Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
}
}
+#endif
// mix some sound
S_Update_();
diff --git a/source/sv_local.h b/source/sv_local.h
index 57fa292..0ae3b04 100644
--- a/source/sv_local.h
+++ b/source/sv_local.h
@@ -52,6 +52,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SV_Mallocz( size ) Z_TagMallocz( size, TAG_SERVER )
#define SV_CopyString( s ) Z_TagCopyString( s, TAG_SERVER )
+#ifdef _DEBUG
+#define SV_DPrintf(level,...) \
+ if( sv_debug && sv_debug->integer > level ) \
+ Com_LPrintf( PRINT_DEVELOPER, __VA_ARGS__ )
+#else
+#define SV_DPrintf(...)
+#endif
+
#define SV_BASELINES_SHIFT 6
#define SV_BASELINES_PER_CHUNK ( 1 << SV_BASELINES_SHIFT )
#define SV_BASELINES_MASK ( SV_BASELINES_PER_CHUNK - 1 )
@@ -394,8 +402,8 @@ extern cvar_t *sv_fps;
extern cvar_t *sv_force_reconnect;
extern cvar_t *sv_iplimit;
-#if USE_CLIENT
-extern cvar_t *sv_debug_send;
+#ifdef _DEBUG
+extern cvar_t *sv_debug;
extern cvar_t *sv_pad_packets;
#endif
extern cvar_t *sv_novis;
diff --git a/source/sv_main.c b/source/sv_main.c
index e6d8ed4..cbd03c6 100644
--- a/source/sv_main.c
+++ b/source/sv_main.c
@@ -61,8 +61,8 @@ cvar_t *sv_redirect_address;
cvar_t *sv_hostname;
cvar_t *sv_public; // should heartbeats be sent
-#if USE_CLIENT
-cvar_t *sv_debug_send;
+#ifdef _DEBUG
+cvar_t *sv_debug;
cvar_t *sv_pad_packets;
#endif
cvar_t *sv_lan_force_rate;
@@ -1816,8 +1816,8 @@ void SV_Init( void ) {
sv_downloadserver = Cvar_Get( "sv_downloadserver", "", 0 );
sv_redirect_address = Cvar_Get( "sv_redirect_address", "", 0 );
-#if USE_CLIENT
- sv_debug_send = Cvar_Get( "sv_debug_send", "0", 0 );
+#ifdef _DEBUG
+ sv_debug = Cvar_Get( "sv_debug", "0", 0 );
sv_pad_packets = Cvar_Get( "sv_pad_packets", "0", 0 );
#endif
sv_lan_force_rate = Cvar_Get( "sv_lan_force_rate", "0", CVAR_LATCH );
diff --git a/source/sv_send.c b/source/sv_send.c
index 25dde99..3327f78 100644
--- a/source/sv_send.c
+++ b/source/sv_send.c
@@ -333,12 +333,8 @@ unless told otherwise.
=======================
*/
void SV_ClientAddMessage( client_t *client, int flags ) {
-#if USE_CLIENT
- if( sv_debug_send->integer > 1 ) {
- Com_Printf( S_COLOR_BLUE"%s: add%c: %"PRIz"\n", client->name,
- ( flags & MSG_RELIABLE ) ? 'r' : 'u', msg_write.cursize );
- }
-#endif
+ SV_DPrintf( 1, "Added %sreliable message to %s: %"PRIz" bytes\n",
+ ( flags & MSG_RELIABLE ) ? "" : "un", client->name, msg_write.cursize );
if( !msg_write.cursize ) {
return;
@@ -466,13 +462,8 @@ static void emit_snd( client_t *client, message_packet_t *msg ) {
}
}
if( i == frame->numEntities ) {
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE
- "Forcing position on entity %d for %s\n",
- entnum, client->name );
- }
-#endif
+ SV_DPrintf( 0, "Forcing position on entity %d for %s\n",
+ entnum, client->name );
flags |= SND_POS; // entity is not present in frame
}
}
@@ -562,11 +553,7 @@ static void write_reliable_messages_old( client_t *client, size_t maxsize ) {
int count;
if( client->netchan->reliable_length ) {
-#if USE_CLIENT
- if( sv_debug_send->integer > 1 ) {
- Com_Printf( S_COLOR_BLUE"%s: unacked\n", client->name );
- }
-#endif
+ SV_DPrintf( 1, "%s to %s: unacked\n", __func__, client->name );
return; // there is still outgoing reliable message pending
}
@@ -577,18 +564,14 @@ static void write_reliable_messages_old( client_t *client, size_t maxsize ) {
if( client->netchan->message.cursize + msg->cursize > maxsize ) {
if( !count ) {
// this should never happen
- Com_WPrintf( "%s: %s: overflow on the first message\n",
+ Com_WPrintf( "%s to %s: overflow on the first message\n",
__func__, client->name );
}
break;
}
-#if USE_CLIENT
- if( sv_debug_send->integer > 1 ) {
- Com_Printf( S_COLOR_BLUE"%s: wrt%d: %d\n",
- client->name, count, msg->cursize );
- }
-#endif
+ SV_DPrintf( 1, "%s to %s: writing msg %d: %d bytes\n",
+ __func__, client->name, count, msg->cursize );
SZ_Write( &client->netchan->message, msg->data, msg->cursize );
free_msg_packet( client, msg );
@@ -673,12 +656,8 @@ static void write_datagram_old( client_t *client ) {
// and the player_state_t
client->WriteFrame( client );
if( msg_write.cursize > maxsize ) {
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE"Frame overflowed for %s: %"PRIz" > %"PRIz"\n",
- client->name, msg_write.cursize, maxsize );
- }
-#endif
+ SV_DPrintf( 0, "Frame %d overflowed for %s: %"PRIz" > %"PRIz"\n",
+ sv.framenum, client->name, msg_write.cursize, maxsize );
SZ_Clear( &msg_write );
}
@@ -748,7 +727,7 @@ static void write_datagram_new( client_t *client ) {
emit_messages( client, msg_write.maxsize );
}
-#if USE_CLIENT
+#ifdef _DEBUG
if( sv_pad_packets->integer ) {
size_t pad = msg_write.cursize + sv_pad_packets->integer;
@@ -816,12 +795,8 @@ void SV_SendClientMessages( void ) {
// don't overrun bandwidth
if( SV_RateDrop( client ) ) {
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( "Frame %d surpressed for %s\n",
- sv.framenum, client->name );
- }
-#endif
+ SV_DPrintf( 0, "Frame %d surpressed for %s\n",
+ sv.framenum, client->name );
client->surpressCount++;
} else {
// don't write any frame data until all fragments are sent
@@ -870,12 +845,7 @@ void SV_SendAsyncPackets( void ) {
// make sure all fragments are transmitted first
if( netchan->fragment_pending ) {
cursize = netchan->TransmitNextFragment( netchan );
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE"%s: frag: %"PRIz"\n",
- client->name, cursize );
- }
-#endif
+ SV_DPrintf( 0, "%s: frag: %"PRIz"\n", client->name, cursize );
goto calctime;
}
@@ -900,12 +870,7 @@ void SV_SendAsyncPackets( void ) {
netchan->reliable_length || retransmit )
{
cursize = netchan->Transmit( netchan, 0, NULL, 1 );
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE"%s: send: %"PRIz"\n",
- client->name, cursize );
- }
-#endif
+ SV_DPrintf( 0, "%s: send: %"PRIz"\n", client->name, cursize );
calctime:
SV_CalcSendTime( client, cursize );
}
diff --git a/source/sv_user.c b/source/sv_user.c
index 04d512f..d8d7884 100644
--- a/source/sv_user.c
+++ b/source/sv_user.c
@@ -203,12 +203,8 @@ static void write_compressed_gamestate( void ) {
return;
}
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE"%s: comp: %lu into %lu\n",
- sv_client->name, svs.z.total_in, svs.z.total_out );
- }
-#endif
+ SV_DPrintf( 0, "%s: comp: %lu into %lu\n",
+ sv_client->name, svs.z.total_in, svs.z.total_out );
patch[0] = svs.z.total_out & 255;
patch[1] = ( svs.z.total_out >> 8 ) & 255;
@@ -223,12 +219,8 @@ static inline int z_flush( byte *buffer ) {
return ret;
}
-#if USE_CLIENT
- if( sv_debug_send->integer ) {
- Com_Printf( S_COLOR_BLUE"%s: comp: %lu into %lu\n",
- sv_client->name, svs.z.total_in, svs.z.total_out );
- }
-#endif
+ SV_DPrintf( 0, "%s: comp: %lu into %lu\n",
+ sv_client->name, svs.z.total_in, svs.z.total_out );
MSG_WriteByte( svc_zpacket );
MSG_WriteShort( svs.z.total_out );
@@ -1232,10 +1224,8 @@ void SV_ExecuteClientMessage( client_t *client ) {
break;
}
- if( developer->integer ) {
- Com_Printf( S_COLOR_BLUE "ClientCommand( %s ): %s\n",
- client->name, Q_FormatString( buffer ) );
- }
+ Com_DPrintf( "ClientCommand( %s ): %s\n",
+ client->name, buffer );
if( !NET_IsLocalAddress( &client->netchan->remote_address ) ) {
// malicious users may try using too many string commands
diff --git a/source/ui_atoms.c b/source/ui_atoms.c
index fb421ee..0065e41 100644
--- a/source/ui_atoms.c
+++ b/source/ui_atoms.c
@@ -238,7 +238,7 @@ void UI_OpenMenu( uiMenu_t type ) {
UI_PushMenu( menu );
}
-void UI_ErrorMenu( comErrorType_t type, const char *text ) {
+void UI_ErrorMenu( error_type_t type, const char *text ) {
if( !uis.initialized ) {
return;
}
diff --git a/source/ui_confirm.c b/source/ui_confirm.c
index 7c7adeb..4a6b849 100644
--- a/source/ui_confirm.c
+++ b/source/ui_confirm.c
@@ -93,7 +93,7 @@ static menuSound_t ErrorKeydown( menuFrameWork_t *self, int key ) {
return QMS_OUT;
}
-void M_Menu_Error( comErrorType_t type, const char *text ) {
+void M_Menu_Error( error_type_t type, const char *text ) {
color_t color;
if( !text ) {
diff --git a/source/ui_local.h b/source/ui_local.h
index c9d1d3a..0160d28 100644
--- a/source/ui_local.h
+++ b/source/ui_local.h
@@ -318,7 +318,7 @@ qboolean Menu_Push( menuFrameWork_t *menu );
void Menu_Pop( menuFrameWork_t *menu );
void Menu_Free( menuFrameWork_t *menu );
-void M_Menu_Error( comErrorType_t type, const char *text );
+void M_Menu_Error( error_type_t type, const char *text );
void M_Menu_Confirm( const char *text, confirmAction_t action );
void M_Menu_PlayerConfig( void );
void M_Menu_Demos( void );
diff --git a/source/ui_multiplayer.c b/source/ui_multiplayer.c
index b7beec8..15d1786 100644
--- a/source/ui_multiplayer.c
+++ b/source/ui_multiplayer.c
@@ -147,18 +147,18 @@ void UI_AddToServerList( const serverStatus_t *status ) {
map = Info_ValueForKey( info, "mapname" );
if( !map[0] ) {
map = "???";
- } else {
+ } /*else {
Q_snprintf( value, sizeof( value ), "maps/%s.bsp", map );
if( FS_LoadFile( value, NULL ) == INVALID_LENGTH ) {
Q_concat( value, sizeof( value ), S_COLOR_RED, map, NULL );
map = value;
}
- }
+ }*/
j = atoi( Info_ValueForKey( info, "maxclients" ) );
k = atoi( Info_ValueForKey( info, "needpass" ) );
- Q_snprintf( key, sizeof( key ), "%s%d/%d",
- status->numPlayers < j ? k > 0 ? S_COLOR_YELLOW : "" : S_COLOR_RED,
+ Q_snprintf( key, sizeof( key ), "%d/%d",
+ //status->numPlayers < j ? k > 0 ? S_COLOR_YELLOW : "" : S_COLOR_RED,
status->numPlayers, j );
if( m_join.names[i] ) {
diff --git a/source/ui_public.h b/source/ui_public.h
index 0ab77e9..01f335a 100644
--- a/source/ui_public.h
+++ b/source/ui_public.h
@@ -32,7 +32,7 @@ void UI_Keydown( int key );
void UI_CharEvent( int key );
void UI_Draw( int realtime );
void UI_OpenMenu( uiMenu_t menu );
-void UI_ErrorMenu( comErrorType_t type, const char *text );
+void UI_ErrorMenu( error_type_t type, const char *text );
void UI_AddToServerList( const serverStatus_t *status );
void UI_MouseEvent( int x, int y );
qboolean UI_IsTransparent( void );