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.
This commit is contained in:
Bill Currie 2001-05-31 02:43:48 +00:00
parent 889b9ce740
commit 4babd979d6
5 changed files with 24 additions and 32 deletions

View file

@ -103,9 +103,6 @@
/* Define this to something appropriate for declaring 0 length arrays */ /* Define this to something appropriate for declaring 0 length arrays */
#undef ZERO_LENGTH_ARRAY #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 */ /* Define this if you have FB_AUX_VGA_PLANES_VGA4 */
#undef HAVE_FB_AUX_VGA_PLANES_VGA4 #undef HAVE_FB_AUX_VGA_PLANES_VGA4

View file

@ -1166,11 +1166,6 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
AC_ARG_ENABLE(packetlog,
[ --enable-packetlog compile with packet logger (for development)],
packetlog=$enable_packetlog
)
AC_ARG_ENABLE(optimize, AC_ARG_ENABLE(optimize,
[ --disable-optimize compile without optimizations (for development)], [ --disable-optimize compile without optimizations (for development)],
optimize=$disable_optimize, optimize=$disable_optimize,
@ -1216,14 +1211,6 @@ else
CFLAGS="$CFLAGS " CFLAGS="$CFLAGS "
fi 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 dnl CFLAGS for release and devel versions
AC_ARG_ENABLE(profile, AC_ARG_ENABLE(profile,
[ --enable-profile compile with profiling (for development)], [ --enable-profile compile with profiling (for development)],

View file

@ -132,11 +132,9 @@ void Netchan_AckPacket (netchan_t *chan);
qboolean Netchan_CanPacket (netchan_t *chan); qboolean Netchan_CanPacket (netchan_t *chan);
qboolean Netchan_CanReliable (netchan_t *chan); qboolean Netchan_CanReliable (netchan_t *chan);
#ifdef PACKET_LOGGING
extern int Net_Log_Init (char **sound_precache); extern int Net_Log_Init (char **sound_precache);
extern void Log_Incoming_Packet (char *p, int len); extern void Log_Incoming_Packet (char *p, int len);
extern void Log_Outgoing_Packet (char *p, int len); extern void Log_Outgoing_Packet (char *p, int len);
extern void Net_LogStop (void); extern void Net_LogStop (void);
#endif
#endif // _NET_H #endif // _NET_H

View file

@ -34,8 +34,6 @@
// FIXME: we did support Quake1 protocol too... // FIXME: we did support Quake1 protocol too...
#ifdef PACKET_LOGGING
#define QUAKEWORLD #define QUAKEWORLD
#include <ctype.h> #include <ctype.h>
@ -48,6 +46,7 @@
#include "server.h" #include "server.h"
#include "QF/va.h" #include "QF/va.h"
cvar_t *net_packetlog;
cvar_t *net_loglevel; cvar_t *net_loglevel;
//extern server_t sv; //extern server_t sv;
@ -203,7 +202,7 @@ Net_LogStart (char *fname)
Qexpand_squiggle (fs_userpath->string, e_path); Qexpand_squiggle (fs_userpath->string, e_path);
Con_Printf ("Opening packet logfile: %s\n", fname); 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) if (!Net_PacketLog)
return -1; return -1;
return 0; 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 int
Net_Log_Init (char **sound_precache) Net_Log_Init (char **sound_precache)
{ {
Net_sound_precache = 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 // 0 = no logging
// 1 = hex dump only // 1 = hex dump only
// 2 = parse/hexdump // 2 = parse/hexdump
@ -972,9 +984,5 @@ Net_Log_Init (char **sound_precache)
net_loglevel = net_loglevel =
Cvar_Get ("net_loglevel", "2", CVAR_NONE, NULL, Cvar_Get ("net_loglevel", "2", CVAR_NONE, NULL,
"Packet logging/parsing"); "Packet logging/parsing");
Net_LogStart ("qfpacket.log");
return 0; return 0;
} }
#endif // PACKET_LOGGING

View file

@ -70,11 +70,13 @@
#include "QF/compat.h" #include "QF/compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "net.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "net.h"
#ifdef _WIN32 #ifdef _WIN32
# include <windows.h> # include <windows.h>
# undef EWOULDBLOCK # undef EWOULDBLOCK
@ -93,6 +95,8 @@
# endif # endif
#endif #endif
extern cvar_t *net_packetlog;
netadr_t net_local_adr; netadr_t net_local_adr;
netadr_t net_from; netadr_t net_from;
@ -307,9 +311,8 @@ NET_GetPacket (void)
return false; return false;
} }
#ifdef PACKET_LOGGING if (net_packetlog->int_val)
Log_Incoming_Packet(net_message_buffer,_net_message_message.cursize); Log_Incoming_Packet(net_message_buffer,_net_message_message.cursize);
#endif
return ret; return ret;
} }
@ -323,9 +326,8 @@ NET_SendPacket (int length, void *data, netadr_t to)
NetadrToSockadr (&to, &addr); NetadrToSockadr (&to, &addr);
#ifdef PACKET_LOGGING if (net_packetlog->int_val)
Log_Outgoing_Packet(data,length); Log_Outgoing_Packet(data,length);
#endif
ret = ret =
sendto (net_socket, data, length, 0, (struct sockaddr *) &addr, sendto (net_socket, data, length, 0, (struct sockaddr *) &addr,