mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 01:45:19 +01:00
engine: common: add cvars net_send_debug and net_recv_debug to print server/client messages to console
This commit is contained in:
parent
1bd59096fd
commit
ece204c30f
@ -17,8 +17,6 @@ GNU General Public License for more details.
|
||||
#include "protocol.h"
|
||||
#include "net_buffer.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
//#define DEBUG_NET_MESSAGES_SEND
|
||||
//#define DEBUG_NET_MESSAGES_READ
|
||||
|
||||
// precalculated bit masks for WriteUBitLong.
|
||||
// Using these tables instead of doing the calculations
|
||||
@ -323,28 +321,30 @@ void MSG_WriteVec3Angles( sizebuf_t *sb, const float *fa )
|
||||
|
||||
void MSG_WriteCmdExt( sizebuf_t *sb, int cmd, netsrc_t type, const char *name )
|
||||
{
|
||||
#ifdef DEBUG_NET_MESSAGES_SEND
|
||||
if( name != NULL )
|
||||
if( unlikely( net_send_debug.value ))
|
||||
{
|
||||
// get custom name
|
||||
Con_Printf( "^1sv^7 write: %s\n", name );
|
||||
}
|
||||
else if( type == NS_SERVER )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
if( name != NULL )
|
||||
{
|
||||
// get engine message name
|
||||
Con_Printf( "^1sv^7 write: %s\n", svc_strings[cmd] );
|
||||
// get custom name
|
||||
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, name );
|
||||
}
|
||||
else if( type == NS_SERVER )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
{
|
||||
// get engine message name
|
||||
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, svc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
else if( type == NS_CLIENT )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1cl^7 (%d) write: %s\n", sb->iCurBit, clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( type == NS_CLIENT )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1cl^7 write: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MSG_WriteUBitLong( sb, cmd, sizeof( uint8_t ) << 3 );
|
||||
}
|
||||
|
||||
@ -570,16 +570,18 @@ int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
|
||||
{
|
||||
int cmd = MSG_ReadUBitLong( sb, sizeof( uint8_t ) << 3 );
|
||||
|
||||
#ifdef DEBUG_NET_MESSAGES_READ
|
||||
if( type == NS_SERVER )
|
||||
if( unlikely( net_recv_debug.value ))
|
||||
{
|
||||
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
|
||||
if( type == NS_SERVER )
|
||||
{
|
||||
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
|
||||
}
|
||||
else if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
else if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
#endif
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,12 @@ such as during the connection stage while waiting for the client to load,
|
||||
then a packet only needs to be delivered if there is something in the
|
||||
unacknowledged reliable
|
||||
*/
|
||||
CVAR_DEFINE_AUTO( net_showpackets, "0", 0, "show network packets" );
|
||||
CVAR_DEFINE_AUTO( net_showpackets, "0", FCVAR_PRIVILEGED, "show network packets" );
|
||||
static CVAR_DEFINE_AUTO( net_chokeloop, "0", 0, "apply bandwidth choke to loopback packets" );
|
||||
static CVAR_DEFINE_AUTO( net_showdrop, "0", 0, "show packets that are dropped" );
|
||||
static CVAR_DEFINE_AUTO( net_qport, "0", FCVAR_READ_ONLY, "current quake netport" );
|
||||
CVAR_DEFINE_AUTO( net_send_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for outgoing messages" );
|
||||
CVAR_DEFINE_AUTO( net_recv_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for incoming messages" );
|
||||
|
||||
int net_drop;
|
||||
netadr_t net_from;
|
||||
@ -265,6 +267,8 @@ void Netchan_Init( void )
|
||||
Cvar_RegisterVariable( &net_chokeloop );
|
||||
Cvar_RegisterVariable( &net_showdrop );
|
||||
Cvar_RegisterVariable( &net_qport );
|
||||
Cvar_RegisterVariable( &net_send_debug );
|
||||
Cvar_RegisterVariable( &net_recv_debug );
|
||||
Cvar_FullSet( net_qport.name, buf, net_qport.flags );
|
||||
|
||||
net_mempool = Mem_AllocPool( "Network Pool" );
|
||||
|
@ -50,8 +50,10 @@ typedef enum
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
extern convar_t net_showpackets;
|
||||
extern convar_t net_clockwindow;
|
||||
extern convar_t net_showpackets;
|
||||
extern convar_t net_clockwindow;
|
||||
extern convar_t net_send_debug;
|
||||
extern convar_t net_recv_debug;
|
||||
|
||||
void NET_Init( void );
|
||||
void NET_Shutdown( void );
|
||||
|
Loading…
Reference in New Issue
Block a user