From 4babd979d6be5bac74374312c42683eebb1f6d2e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 31 May 2001 02:43:48 +0000 Subject: [PATCH] nuke --enable-packetlog in favor of a net_packetlog cvar so packetlogging is always available. also change the packet log open mode from truncate to append. --- acconfig.h | 3 --- configure.in | 13 ------------- qw/include/net.h | 2 -- qw/source/net_packetlog.c | 22 +++++++++++++++------- qw/source/net_udp.c | 16 +++++++++------- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/acconfig.h b/acconfig.h index 18c80d03e..b84f44104 100644 --- a/acconfig.h +++ b/acconfig.h @@ -103,9 +103,6 @@ /* Define this to something appropriate for declaring 0 length arrays */ #undef ZERO_LENGTH_ARRAY -/* Define this if you want to have packet logging */ -#undef PACKET_LOGGING - /* Define this if you have FB_AUX_VGA_PLANES_VGA4 */ #undef HAVE_FB_AUX_VGA_PLANES_VGA4 diff --git a/configure.in b/configure.in index bef143eff..170c64080 100644 --- a/configure.in +++ b/configure.in @@ -1166,11 +1166,6 @@ else AC_MSG_RESULT(no) fi -AC_ARG_ENABLE(packetlog, - [ --enable-packetlog compile with packet logger (for development)], - packetlog=$enable_packetlog -) - AC_ARG_ENABLE(optimize, [ --disable-optimize compile without optimizations (for development)], optimize=$disable_optimize, @@ -1216,14 +1211,6 @@ else CFLAGS="$CFLAGS " fi -AC_MSG_CHECKING(for packet logging) -if test "x$packetlog" = xyes; then - AC_MSG_RESULT(yes) - AC_DEFINE(PACKET_LOGGING) -else - AC_MSG_RESULT(no) -fi - dnl CFLAGS for release and devel versions AC_ARG_ENABLE(profile, [ --enable-profile compile with profiling (for development)], diff --git a/qw/include/net.h b/qw/include/net.h index bbc47d090..dbd27d91c 100644 --- a/qw/include/net.h +++ b/qw/include/net.h @@ -132,11 +132,9 @@ void Netchan_AckPacket (netchan_t *chan); qboolean Netchan_CanPacket (netchan_t *chan); qboolean Netchan_CanReliable (netchan_t *chan); -#ifdef PACKET_LOGGING extern int Net_Log_Init (char **sound_precache); extern void Log_Incoming_Packet (char *p, int len); extern void Log_Outgoing_Packet (char *p, int len); extern void Net_LogStop (void); -#endif #endif // _NET_H diff --git a/qw/source/net_packetlog.c b/qw/source/net_packetlog.c index d4915b748..8a24026fe 100644 --- a/qw/source/net_packetlog.c +++ b/qw/source/net_packetlog.c @@ -34,8 +34,6 @@ // FIXME: we did support Quake1 protocol too... -#ifdef PACKET_LOGGING - #define QUAKEWORLD #include @@ -48,6 +46,7 @@ #include "server.h" #include "QF/va.h" +cvar_t *net_packetlog; cvar_t *net_loglevel; //extern server_t sv; @@ -203,7 +202,7 @@ Net_LogStart (char *fname) Qexpand_squiggle (fs_userpath->string, e_path); Con_Printf ("Opening packet logfile: %s\n", fname); - Net_PacketLog = Qopen (va ("%s/%s", e_path, fname), "wt+"); + Net_PacketLog = Qopen (va ("%s/%s", e_path, fname), "at"); if (!Net_PacketLog) return -1; return 0; @@ -958,11 +957,24 @@ Parse_Client_Packet (void) } } +void +Net_PacketLog_f (cvar_t *var) +{ + if (var->int_val) { + Net_LogStart ("qfpacket.log"); + } else { + Net_LogStop (); + } +} + int Net_Log_Init (char **sound_precache) { Net_sound_precache = sound_precache; + net_packetlog = Cvar_Get ("net_packetlog", "0", CVAR_NONE, Net_PacketLog_f, + "enable/disable packet logging"); + // 0 = no logging // 1 = hex dump only // 2 = parse/hexdump @@ -972,9 +984,5 @@ Net_Log_Init (char **sound_precache) net_loglevel = Cvar_Get ("net_loglevel", "2", CVAR_NONE, NULL, "Packet logging/parsing"); - - Net_LogStart ("qfpacket.log"); return 0; } - -#endif // PACKET_LOGGING diff --git a/qw/source/net_udp.c b/qw/source/net_udp.c index ad6588a25..54b46629e 100644 --- a/qw/source/net_udp.c +++ b/qw/source/net_udp.c @@ -70,11 +70,13 @@ #include "QF/compat.h" #include "QF/console.h" +#include "QF/cvar.h" #include "QF/msg.h" -#include "net.h" #include "QF/sys.h" #include "QF/qargs.h" +#include "net.h" + #ifdef _WIN32 # include # undef EWOULDBLOCK @@ -93,6 +95,8 @@ # endif #endif +extern cvar_t *net_packetlog; + netadr_t net_local_adr; netadr_t net_from; @@ -307,9 +311,8 @@ NET_GetPacket (void) return false; } -#ifdef PACKET_LOGGING - Log_Incoming_Packet(net_message_buffer,_net_message_message.cursize); -#endif + if (net_packetlog->int_val) + Log_Incoming_Packet(net_message_buffer,_net_message_message.cursize); return ret; } @@ -323,9 +326,8 @@ NET_SendPacket (int length, void *data, netadr_t to) NetadrToSockadr (&to, &addr); -#ifdef PACKET_LOGGING - Log_Outgoing_Packet(data,length); -#endif + if (net_packetlog->int_val) + Log_Outgoing_Packet(data,length); ret = sendto (net_socket, data, length, 0, (struct sockaddr *) &addr,