white space

This commit is contained in:
Bill Currie 2000-12-19 22:48:16 +00:00
parent 5de89ed5f1
commit 3669d78d1b

View file

@ -24,8 +24,6 @@
Boston, MA 02111-1307, USA Boston, MA 02111-1307, USA
$Id$ $Id$
*/ */
// fixme: we did support Quake1 protocol too... // fixme: we did support Quake1 protocol too...
@ -65,8 +63,7 @@ int Net_LogStart(char *fname);
void Net_LogStop (void); void Net_LogStop (void);
// note: this is SUPPOSED to be duplicate, like many others // note: this is SUPPOSED to be duplicate, like many others
char *svc_string[] = char *svc_string[] = {
{
"svc_bad", "svc_bad",
"svc_nop", "svc_nop",
"svc_disconnect", "svc_disconnect",
@ -76,9 +73,11 @@ char *svc_string[] =
"svc_sound", // <see code> "svc_sound", // <see code>
"svc_time", // [float] server time "svc_time", // [float] server time
"svc_print", // [string] null terminated string "svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's console buffer "svc_stufftext", // [string] stuffed into client's
// the string should be \n terminated // console buffer the string
"svc_setangle", // [vec3] set the view angle to this absolute value // should be \n terminated
"svc_setangle", // [vec3] set the view angle to this
// absolute value
"svc_serverdata", // [long] version ... "svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string] "svc_lightstyle", // [byte] [string]
@ -88,7 +87,8 @@ char *svc_string[] =
"svc_stopsound", // <see code> "svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte] "svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable> "svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] from "svc_damage", // [byte] impact [byte] blood [vec3]
// from
"svc_spawnstatic", "svc_spawnstatic",
"svc_spawnbinary", "svc_spawnbinary",
@ -144,8 +144,7 @@ char *svc_string[] =
"NEW PROTOCOL" "NEW PROTOCOL"
}; };
char *clc_string[] = char *clc_string[] = {
{
"clc_bad", "clc_bad",
"clc_nop", "clc_nop",
"clc_disconnect", "clc_disconnect",
@ -167,19 +166,19 @@ char *clc_string[] =
#define svc_clientdata 15 // <shortbits + data> #define svc_clientdata 15 // <shortbits + data>
#define svc_updatecolors 17 // [byte] [byte] #define svc_updatecolors 17 // [byte] [byte]
#define svc_particle 18 // [vec3] <variable> #define svc_particle 18 // [vec3] <variable>
#define svc_signonnum 25 // [byte] used for the signon sequence #define svc_signonnum 25 // [byte] used for the signon
// sequence
QFile *Net_PacketLog; QFile *Net_PacketLog;
/* /*
=================
NET_LogPrintf NET_LogPrintf
Prints packet to logfile, adds time stamp etc. Prints packet to logfile, adds time stamp etc.
=================
*/ */
void Net_LogPrintf (char *fmt, ...) void
Net_LogPrintf (char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char text[2048]; char text[2048];
@ -187,52 +186,60 @@ void Net_LogPrintf (char *fmt, ...)
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (text, sizeof (text), fmt, argptr); vsnprintf (text, sizeof (text), fmt, argptr);
va_end (argptr); va_end (argptr);
if (!Net_PacketLog) return; if (!Net_PacketLog)
return;
Qprintf (Net_PacketLog, "%s", text); Qprintf (Net_PacketLog, "%s", text);
Qflush (Net_PacketLog); Qflush (Net_PacketLog);
} }
int Net_LogStart(char *fname) int
Net_LogStart (char *fname)
{ {
Con_Printf ("Opening packet logfile: %s\n", fname); Con_Printf ("Opening packet logfile: %s\n", fname);
Net_PacketLog = Qopen (fname, "wt+"); Net_PacketLog = Qopen (fname, "wt+");
if(!Net_PacketLog) return -1; if (!Net_PacketLog)
return -1;
return 0; return 0;
} }
void Net_LogStop(void) void
Net_LogStop (void)
{ {
if (Net_PacketLog) Qclose(Net_PacketLog); if (Net_PacketLog)
Qclose (Net_PacketLog);
Net_PacketLog = NULL; Net_PacketLog = NULL;
} }
void hex_dump_buf(unsigned char *buf, int len) void
hex_dump_buf (unsigned char *buf, int len)
{ {
int pos = 0, llen, i; int pos = 0, llen, i;
while(pos < len) while (pos < len) {
{
llen = (len - pos < 16 ? len - pos : 16); llen = (len - pos < 16 ? len - pos : 16);
Net_LogPrintf ("%08x: ", pos); Net_LogPrintf ("%08x: ", pos);
for(i = 0; i < llen; i++) Net_LogPrintf("%02x ", buf[pos + i]); for (i = 0; i < llen; i++)
for(i = 0; i < 16 - llen; i++) Net_LogPrintf(" "); Net_LogPrintf ("%02x ", buf[pos + i]);
for (i = 0; i < 16 - llen; i++)
Net_LogPrintf (" ");
Net_LogPrintf (" | "); Net_LogPrintf (" | ");
for (i = 0; i < llen; i++) for (i = 0; i < llen; i++)
Net_LogPrintf ("%c", isprint (buf[pos + i]) ? buf[pos + i] : '.'); Net_LogPrintf ("%c", isprint (buf[pos + i]) ? buf[pos + i] : '.');
for(i = 0; i < 16 - llen; i++) Net_LogPrintf(" "); for (i = 0; i < 16 - llen; i++)
Net_LogPrintf (" ");
Net_LogPrintf ("\n"); Net_LogPrintf ("\n");
pos += llen; pos += llen;
} }
} }
void ascii_dump_buf(unsigned char *buf, int len) void
ascii_dump_buf (unsigned char *buf, int len)
{ {
int pos = 0, llen, i; int pos = 0, llen, i;
while(pos < len) while (pos < len) {
{
llen = (len - pos < 60 ? len - pos : 60); llen = (len - pos < 60 ? len - pos : 60);
Net_LogPrintf ("%08x: ", pos); Net_LogPrintf ("%08x: ", pos);
for (i = 0; i < llen; i++) for (i = 0; i < llen; i++)
@ -242,42 +249,61 @@ int pos = 0, llen, i;
} }
} }
void Log_Incoming_Packet(char *p, int len) void
Log_Incoming_Packet (char *p, int len)
{ {
if (!netloglevel->int_val) return; if (!netloglevel->int_val)
return;
if (is_server) { if (is_server) {
Net_LogPrintf("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n", len); Net_LogPrintf
if (netloglevel->int_val!=3) hex_dump_buf((unsigned char *)p,len); ("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n",
if (netloglevel->int_val>1) Analyze_Client_Packet(p,len); len);
} if (netloglevel->int_val != 3)
else { hex_dump_buf ((unsigned char *) p, len);
Net_LogPrintf("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n", len); if (netloglevel->int_val > 1)
if (netloglevel->int_val!=3) hex_dump_buf((unsigned char *)p,len);; Analyze_Client_Packet (p, len);
if (netloglevel->int_val>1) Analyze_Server_Packet(p,len); } else {
Net_LogPrintf
("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n",
len);
if (netloglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len);;
if (netloglevel->int_val > 1)
Analyze_Server_Packet (p, len);
} }
return; return;
} }
void Log_Outgoing_Packet(char *p, int len) void
Log_Outgoing_Packet (char *p, int len)
{ {
if (!netloglevel->int_val) return; if (!netloglevel->int_val)
return;
if (is_server) { if (is_server) {
Net_LogPrintf("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n", len); Net_LogPrintf
if (netloglevel->int_val!=3) hex_dump_buf((unsigned char *)p,len);; ("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n",
if (netloglevel->int_val>1) Analyze_Server_Packet(p,len); len);
} if (netloglevel->int_val != 3)
else { hex_dump_buf ((unsigned char *) p, len);;
Net_LogPrintf("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n", len); if (netloglevel->int_val > 1)
if (netloglevel->int_val!=3) hex_dump_buf((unsigned char *)p,len);; Analyze_Server_Packet (p, len);
if (netloglevel->int_val>1) Analyze_Client_Packet(p,len); } else {
Net_LogPrintf
("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n",
len);
if (netloglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len);;
if (netloglevel->int_val > 1)
Analyze_Client_Packet (p, len);
} }
return; return;
} }
void Analyze_Server_Packet(byte *data,int len) void
Analyze_Server_Packet (byte * data, int len)
{ {
// Fixme: quick-hack // Fixme: quick-hack
net_message.data = data; net_message.data = data;
@ -288,44 +314,49 @@ void Analyze_Server_Packet(byte *data,int len)
} }
void Parse_Server_Packet() void
Parse_Server_Packet ()
{ {
long seq1, seq2; long seq1, seq2;
int c, i, ii, iii, mask1, mask2; int c, i, ii, iii, mask1, mask2;
char *s; char *s;
seq1 = MSG_ReadLong (); seq1 = MSG_ReadLong ();
if (msg_badread) return; if (msg_badread)
return;
if(seq1==-1) if (seq1 == -1) {
{
Net_LogPrintf ("Special Packet"); Net_LogPrintf ("Special Packet");
} else } else {
{
seq2 = MSG_ReadLong (); seq2 = MSG_ReadLong ();
// fixme display seqs right when reliable // fixme display seqs right when reliable
Net_LogPrintf("\nSeq: %ld Ack: %ld ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
seq2 & 0x7FFFFFFF);
if ((seq1 >>31) &0x01) Net_LogPrintf("SV_REL "); if ((seq1 >> 31) & 0x01)
if ((seq2 >>31) &0x01) Net_LogPrintf("SV_RELACK"); Net_LogPrintf ("SV_REL ");
if ((seq2 >> 31) & 0x01)
Net_LogPrintf ("SV_RELACK");
Net_LogPrintf ("\n"); Net_LogPrintf ("\n");
while(1) while (1) {
{ if (msg_badread)
if (msg_badread) break; break;
c = MSG_ReadByte (); c = MSG_ReadByte ();
if (c == -1) break; if (c == -1)
break;
// Net_LogPrintf("\n<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); // Net_LogPrintf("\n<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF);
Net_LogPrintf ("<%06x> [0x%02x] ", MSG_GetReadCount (), c); Net_LogPrintf ("<%06x> [0x%02x] ", MSG_GetReadCount (), c);
if (c<53) Net_LogPrintf("%s: ",svc_string[c]); if (c < 53)
Net_LogPrintf ("%s: ", svc_string[c]);
// else Net_LogPrintf("(UNK: %d): ",c); // else Net_LogPrintf("(UNK: %d): ",c);
if (MSG_GetReadCount()>net_message.cursize) return; if (MSG_GetReadCount () > net_message.cursize)
return;
switch (c) switch (c) {
{
case svc_bad: case svc_bad:
Net_LogPrintf (" - should not happen"); Net_LogPrintf (" - should not happen");
case svc_nop: case svc_nop:
@ -353,8 +384,11 @@ void Parse_Server_Packet()
case svc_sound: case svc_sound:
i = MSG_ReadShort (); i = MSG_ReadShort ();
Net_LogPrintf (": (%d) ", i); Net_LogPrintf (": (%d) ", i);
if (i & SND_VOLUME) Net_LogPrintf("Volume %d ", MSG_ReadByte()); if (i & SND_VOLUME)
if (i & SND_ATTENUATION) Net_LogPrintf("Ann: %f", (float)MSG_ReadByte () / 64.0); Net_LogPrintf ("Volume %d ", MSG_ReadByte ());
if (i & SND_ATTENUATION)
Net_LogPrintf ("Ann: %f",
(float) MSG_ReadByte () / 64.0);
ii = MSG_ReadByte (); ii = MSG_ReadByte ();
// fixme: well, cl. for client :-) // fixme: well, cl. for client :-)
@ -382,7 +416,8 @@ void Parse_Server_Packet()
Net_LogPrintf ("%s", MSG_ReadString ()); Net_LogPrintf ("%s", MSG_ReadString ());
break; break;
case svc_setangle: case svc_setangle:
for (i=0;i<3;i++) Net_LogPrintf("%f ",MSG_ReadAngle()); for (i = 0; i < 3; i++)
Net_LogPrintf ("%f ", MSG_ReadAngle ());
break; break;
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
case svc_serverdata: case svc_serverdata:
@ -391,13 +426,15 @@ void Parse_Server_Packet()
Net_LogPrintf (" Dir: %s", MSG_ReadString ()); Net_LogPrintf (" Dir: %s", MSG_ReadString ());
Net_LogPrintf (" User ID: %d", MSG_ReadByte ()); Net_LogPrintf (" User ID: %d", MSG_ReadByte ());
Net_LogPrintf (" Map: %s", MSG_ReadString ()); Net_LogPrintf (" Map: %s", MSG_ReadString ());
for(i=0;i<10;i++) MSG_ReadFloat(); for (i = 0; i < 10; i++)
MSG_ReadFloat ();
break; break;
#endif #endif
case svc_lightstyle: case svc_lightstyle:
i = MSG_ReadByte (); i = MSG_ReadByte ();
if (i >= MAX_LIGHTSTYLES) return; if (i >= MAX_LIGHTSTYLES)
return;
Net_LogPrintf ("%d %s", i, MSG_ReadString ()); Net_LogPrintf ("%d %s", i, MSG_ReadString ());
break; break;
case svc_updatename: case svc_updatename:
@ -408,7 +445,8 @@ void Parse_Server_Packet()
#endif #endif
break; break;
case svc_updatefrags: case svc_updatefrags:
Net_LogPrintf("player: %d frags: %d",MSG_ReadByte(),MSG_ReadShort()); Net_LogPrintf ("player: %d frags: %d", MSG_ReadByte (),
MSG_ReadShort ());
break; break;
case svc_clientdata: case svc_clientdata:
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
@ -430,8 +468,10 @@ void Parse_Server_Packet()
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
Net_LogPrintf ("**QW OBSOLETE**"); Net_LogPrintf ("**QW OBSOLETE**");
#else #else
for (i=0;i<3;i++) Net_LogPrintf(" %f",MSG_ReadCoord()); for (i = 0; i < 3; i++)
for (i=0;i<3;i++) Net_LogPrintf(" %d",MSG_ReadChar()); Net_LogPrintf (" %f", MSG_ReadCoord ());
for (i = 0; i < 3; i++)
Net_LogPrintf (" %d", MSG_ReadChar ());
Net_LogPrintf (" Count: %d", MSG_ReadByte ()); Net_LogPrintf (" Count: %d", MSG_ReadByte ());
Net_LogPrintf (" Color: %d", MSG_ReadByte ()); Net_LogPrintf (" Color: %d", MSG_ReadByte ());
#endif #endif
@ -439,13 +479,19 @@ void Parse_Server_Packet()
case svc_damage: case svc_damage:
// fixme parse damage // fixme parse damage
Net_LogPrintf("armor: %d health: %d",MSG_ReadByte(),MSG_ReadByte()); Net_LogPrintf ("armor: %d health: %d", MSG_ReadByte (),
Net_LogPrintf(" from %f,%f,%f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); MSG_ReadByte ());
Net_LogPrintf (" from %f,%f,%f", MSG_ReadCoord (),
MSG_ReadCoord (), MSG_ReadCoord ());
break; break;
case svc_spawnstatic: case svc_spawnstatic:
Net_LogPrintf ("%d", MSG_ReadByte ()); Net_LogPrintf ("%d", MSG_ReadByte ());
Net_LogPrintf(" Frame: %d Color: %d Skin: %",MSG_ReadByte(),MSG_ReadByte(),MSG_ReadByte()); Net_LogPrintf (" Frame: %d Color: %d Skin: %",
for(i = 0; i < 3; i++) Net_LogPrintf("%d: %f %f", i+1, MSG_ReadCoord(), MSG_ReadAngle()); MSG_ReadByte (), MSG_ReadByte (),
MSG_ReadByte ());
for (i = 0; i < 3; i++)
Net_LogPrintf ("%d: %f %f", i + 1, MSG_ReadCoord (),
MSG_ReadAngle ());
break; break;
case svc_spawnbinary: case svc_spawnbinary:
Net_LogPrintf ("**OBSOLETE**"); Net_LogPrintf ("**OBSOLETE**");
@ -463,8 +509,7 @@ void Parse_Server_Packet()
break; break;
case svc_temp_entity: case svc_temp_entity:
i = MSG_ReadByte (); i = MSG_ReadByte ();
switch(i) switch (i) {
{
case 0: case 0:
case 1: case 1:
case 3: case 3:
@ -474,22 +519,29 @@ void Parse_Server_Packet()
case 10: case 10:
case 11: case 11:
case 13: case 13:
Net_LogPrintf(" origin %f %f %f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); Net_LogPrintf (" origin %f %f %f", MSG_ReadCoord (),
MSG_ReadCoord (), MSG_ReadCoord ());
break; break;
case 5: case 5:
case 6: case 6:
case 9: case 9:
Net_LogPrintf (" created by %d", MSG_ReadShort ()); Net_LogPrintf (" created by %d", MSG_ReadShort ());
Net_LogPrintf(" origin: %f,%f,%f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); Net_LogPrintf (" origin: %f,%f,%f",
Net_LogPrintf(" trace endpos: %f,%f,%f", MSG_ReadCoord(), MSG_ReadCoord(), MSG_ReadCoord()); MSG_ReadCoord (), MSG_ReadCoord (),
MSG_ReadCoord ());
Net_LogPrintf (" trace endpos: %f,%f,%f",
MSG_ReadCoord (), MSG_ReadCoord (),
MSG_ReadCoord ());
break; break;
case 2: case 2:
case 12: case 12:
Net_LogPrintf (" count: %d", MSG_ReadByte ()); Net_LogPrintf (" count: %d", MSG_ReadByte ());
printf(" origin: %f,%f,%f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); printf (" origin: %f,%f,%f", MSG_ReadCoord (),
MSG_ReadCoord (), MSG_ReadCoord ());
break; break;
default: default:
Net_LogPrintf(" unknown value %d for tempentity",i); Net_LogPrintf (" unknown value %d for tempentity",
i);
break; break;
} }
break; break;
@ -512,13 +564,17 @@ void Parse_Server_Packet()
case svc_foundsecret: case svc_foundsecret:
break; break;
case svc_spawnstaticsound: case svc_spawnstaticsound:
Net_LogPrintf("pos %f,%f,%f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); Net_LogPrintf ("pos %f,%f,%f", MSG_ReadCoord (),
Net_LogPrintf("%d %d %d",MSG_ReadByte(),MSG_ReadByte(),MSG_ReadByte()); MSG_ReadCoord (), MSG_ReadCoord ());
Net_LogPrintf ("%d %d %d", MSG_ReadByte (), MSG_ReadByte (),
MSG_ReadByte ());
break; break;
case svc_intermission: case svc_intermission:
for (i=0 ; i<3 ; i++) Net_LogPrintf("%f ",MSG_ReadCoord()); for (i = 0; i < 3; i++)
Net_LogPrintf ("%f ", MSG_ReadCoord ());
Net_LogPrintf ("\n"); Net_LogPrintf ("\n");
for (i=0 ; i<3 ; i++) Net_LogPrintf("%f ",MSG_ReadAngle ()); for (i = 0; i < 3; i++)
Net_LogPrintf ("%f ", MSG_ReadAngle ());
break; break;
case svc_finale: case svc_finale:
Net_LogPrintf ("%s", MSG_ReadString ()); Net_LogPrintf ("%s", MSG_ReadString ());
@ -558,44 +614,62 @@ void Parse_Server_Packet()
case svc_download: case svc_download:
ii = MSG_ReadShort (); ii = MSG_ReadShort ();
Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte ()); Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte ());
for (i=0;i<ii;i++) MSG_ReadByte(); for (i = 0; i < ii; i++)
MSG_ReadByte ();
break; break;
case svc_playerinfo: case svc_playerinfo:
Net_LogPrintf ("\n\tPlayer: %d", MSG_ReadByte ()); Net_LogPrintf ("\n\tPlayer: %d", MSG_ReadByte ());
mask1 = MSG_ReadShort (); mask1 = MSG_ReadShort ();
Net_LogPrintf (" Mask1: %d", mask1); Net_LogPrintf (" Mask1: %d", mask1);
Net_LogPrintf(" Origin: %f,%f,%f",MSG_ReadCoord(),MSG_ReadCoord(),MSG_ReadCoord()); Net_LogPrintf (" Origin: %f,%f,%f", MSG_ReadCoord (),
MSG_ReadCoord (), MSG_ReadCoord ());
Net_LogPrintf (" Frame: %d", MSG_ReadByte ()); Net_LogPrintf (" Frame: %d", MSG_ReadByte ());
if(mask1 & PF_MSEC) Net_LogPrintf(" Ping: %d",MSG_ReadByte()); if (mask1 & PF_MSEC)
Net_LogPrintf (" Ping: %d", MSG_ReadByte ());
if(mask1 & PF_COMMAND) if (mask1 & PF_COMMAND) {
{
mask2 = MSG_ReadByte (); // command mask2 = MSG_ReadByte (); // command
if(mask2 & 0x01) Net_LogPrintf(" Pitch: %f", MSG_ReadAngle16()); if (mask2 & 0x01)
if(mask2 & 0x80) Net_LogPrintf(" Yaw: %f", MSG_ReadAngle16()); Net_LogPrintf (" Pitch: %f", MSG_ReadAngle16 ());
if(mask2 & 0x02) Net_LogPrintf(" Roll: %f", MSG_ReadAngle16()); if (mask2 & 0x80)
if(mask2 & 0x04) Net_LogPrintf(" Speed1: %d", MSG_ReadShort()); Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16 ());
if(mask2 & 0x08) Net_LogPrintf(" Speed2: %d", MSG_ReadShort()); if (mask2 & 0x02)
if(mask2 & 0x10) Net_LogPrintf(" Speed3: %d", MSG_ReadShort()); Net_LogPrintf (" Roll: %f", MSG_ReadAngle16 ());
if(mask2 & 0x20) Net_LogPrintf(" Flag: %d", MSG_ReadByte()); if (mask2 & 0x04)
if(mask2 & 0x40) Net_LogPrintf(" Impulse: %d", MSG_ReadByte()); Net_LogPrintf (" Speed1: %d", MSG_ReadShort ());
if (mask2 & 0x08)
Net_LogPrintf (" Speed2: %d", MSG_ReadShort ());
if (mask2 & 0x10)
Net_LogPrintf (" Speed3: %d", MSG_ReadShort ());
if (mask2 & 0x20)
Net_LogPrintf (" Flag: %d", MSG_ReadByte ());
if (mask2 & 0x40)
Net_LogPrintf (" Impulse: %d", MSG_ReadByte ());
Net_LogPrintf (" Msec: %d", MSG_ReadByte ()); Net_LogPrintf (" Msec: %d", MSG_ReadByte ());
} }
if(mask1 & PF_VELOCITY1) Net_LogPrintf(" Xspd: %f", MSG_ReadCoord()); if (mask1 & PF_VELOCITY1)
if(mask1 & PF_VELOCITY2) Net_LogPrintf(" Yspd: %f", MSG_ReadCoord()); Net_LogPrintf (" Xspd: %f", MSG_ReadCoord ());
if(mask1 & PF_VELOCITY3) Net_LogPrintf(" ZSpd: %f", MSG_ReadCoord()); if (mask1 & PF_VELOCITY2)
if(mask1 & PF_MODEL) Net_LogPrintf(" Model: %d", MSG_ReadByte()); Net_LogPrintf (" Yspd: %f", MSG_ReadCoord ());
if(mask1 & PF_SKINNUM) Net_LogPrintf(" Skin: %d", MSG_ReadByte()); if (mask1 & PF_VELOCITY3)
if(mask1 & PF_EFFECTS) Net_LogPrintf(" Effects: %d", MSG_ReadByte()); Net_LogPrintf (" ZSpd: %f", MSG_ReadCoord ());
if (mask1 & PF_MODEL)
Net_LogPrintf (" Model: %d", MSG_ReadByte ());
if (mask1 & PF_SKINNUM)
Net_LogPrintf (" Skin: %d", MSG_ReadByte ());
if (mask1 & PF_EFFECTS)
Net_LogPrintf (" Effects: %d", MSG_ReadByte ());
if(mask1 & PF_WEAPONFRAME) Net_LogPrintf(" Weapon frame: %d", MSG_ReadByte()); if (mask1 & PF_WEAPONFRAME)
Net_LogPrintf (" Weapon frame: %d", MSG_ReadByte ());
break; break;
case svc_nails: case svc_nails:
ii = MSG_ReadByte (); ii = MSG_ReadByte ();
Net_LogPrintf (" %d (bits not parsed)", ii); Net_LogPrintf (" %d (bits not parsed)", ii);
for (i = 0; i < ii; i++) { for (i = 0; i < ii; i++) {
for (iii=0;iii<6;iii++) MSG_ReadByte(); for (iii = 0; iii < 6; iii++)
MSG_ReadByte ();
} }
break; break;
case svc_chokecount: case svc_chokecount:
@ -606,50 +680,72 @@ void Parse_Server_Packet()
Net_LogPrintf ("start %d", ii); Net_LogPrintf ("start %d", ii);
for (i = ii; i < 256; i++) { for (i = ii; i < 256; i++) {
s = MSG_ReadString (); s = MSG_ReadString ();
if (msg_badread) break; if (msg_badread)
if (!s) break; break;
if (strlen(s)==0) break; if (!s)
break;
if (strlen (s) == 0)
break;
Net_LogPrintf ("\n\tModel %d: %s", i, s); Net_LogPrintf ("\n\tModel %d: %s", i, s);
} }
i = MSG_ReadByte (); i = MSG_ReadByte ();
if (i) Net_LogPrintf("\n\tnext at %d",i); if (i)
else Net_LogPrintf("\n\t*End of modellist*"); Net_LogPrintf ("\n\tnext at %d", i);
else
Net_LogPrintf ("\n\t*End of modellist*");
break; break;
case svc_soundlist: case svc_soundlist:
ii = MSG_ReadByte (); ii = MSG_ReadByte ();
Net_LogPrintf ("start %d", ii); Net_LogPrintf ("start %d", ii);
for (i = ii; i < 256; i++) { for (i = ii; i < 256; i++) {
s = MSG_ReadString (); s = MSG_ReadString ();
if (msg_badread) break; if (msg_badread)
if (!s) break; break;
if (strlen(s)==0) break; if (!s)
break;
if (strlen (s) == 0)
break;
Net_LogPrintf ("\n\tSound %d: %s", i, s); Net_LogPrintf ("\n\tSound %d: %s", i, s);
} }
i = MSG_ReadByte (); i = MSG_ReadByte ();
if (i) Net_LogPrintf("\n\tnext at %d",i); if (i)
else Net_LogPrintf("\n\t*End of sound list*"); Net_LogPrintf ("\n\tnext at %d", i);
else
Net_LogPrintf ("\n\t*End of sound list*");
break; break;
case svc_packetentities: case svc_packetentities:
Net_LogPrintf ("Not parsed (parser broken ;-)"); Net_LogPrintf ("Not parsed (parser broken ;-)");
return; return;
while ((mask1=MSG_ReadShort())) while ((mask1 = MSG_ReadShort ())) {
{ if (msg_badread)
if (msg_badread) break; break;
Net_LogPrintf ("\n\t"); Net_LogPrintf ("\n\t");
if(mask1 & 0x8000) mask1|=MSG_ReadByte(); if (mask1 & 0x8000)
mask1 |= MSG_ReadByte ();
if(mask1 & U_MODEL) Net_LogPrintf(" Mdl: %d",MSG_ReadByte()); if (mask1 & U_MODEL)
if(mask1 & U_FRAME) Net_LogPrintf(" Frame: %d",MSG_ReadByte()); Net_LogPrintf (" Mdl: %d", MSG_ReadByte ());
if(mask1 & U_COLORMAP) Net_LogPrintf(" Colormap:%d",MSG_ReadByte()); if (mask1 & U_FRAME)
if(mask1 & U_SKIN) Net_LogPrintf(" Skin: %d",MSG_ReadByte()); Net_LogPrintf (" Frame: %d", MSG_ReadByte ());
if(mask1 & U_EFFECTS) Net_LogPrintf(" Effects: %d",MSG_ReadByte()); if (mask1 & U_COLORMAP)
if(mask1 & U_ORIGIN1) Net_LogPrintf(" X: %f",MSG_ReadCoord()); Net_LogPrintf (" Colormap:%d", MSG_ReadByte ());
if(mask1 & U_ANGLE1) Net_LogPrintf(" Pitch: %d",MSG_ReadAngle()); if (mask1 & U_SKIN)
if(mask1 & U_ORIGIN2) Net_LogPrintf(" Y: %f",MSG_ReadCoord()); Net_LogPrintf (" Skin: %d", MSG_ReadByte ());
if(mask1 & U_ANGLE2) Net_LogPrintf(" Yaw: %d",MSG_ReadAngle()); if (mask1 & U_EFFECTS)
if(mask1 & U_ORIGIN3) Net_LogPrintf(" Z: %f",MSG_ReadCoord()); Net_LogPrintf (" Effects: %d", MSG_ReadByte ());
if(mask1 & U_ANGLE3) Net_LogPrintf(" Roll: %d",MSG_ReadAngle()); if (mask1 & U_ORIGIN1)
Net_LogPrintf (" X: %f", MSG_ReadCoord ());
if (mask1 & U_ANGLE1)
Net_LogPrintf (" Pitch: %d", MSG_ReadAngle ());
if (mask1 & U_ORIGIN2)
Net_LogPrintf (" Y: %f", MSG_ReadCoord ());
if (mask1 & U_ANGLE2)
Net_LogPrintf (" Yaw: %d", MSG_ReadAngle ());
if (mask1 & U_ORIGIN3)
Net_LogPrintf (" Z: %f", MSG_ReadCoord ());
if (mask1 & U_ANGLE3)
Net_LogPrintf (" Roll: %d", MSG_ReadAngle ());
// if(mask1 & U_SOLID) return; // if(mask1 & U_SOLID) return;
} }
break; break;
@ -669,10 +765,12 @@ void Parse_Server_Packet()
Net_LogPrintf ("Value: %s", MSG_ReadString ()); Net_LogPrintf ("Value: %s", MSG_ReadString ());
break; break;
case svc_serverinfo: case svc_serverinfo:
Net_LogPrintf("Name: %s Value: %s",MSG_ReadString(),MSG_ReadString()); Net_LogPrintf ("Name: %s Value: %s", MSG_ReadString (),
MSG_ReadString ());
break; break;
case svc_updatepl: case svc_updatepl:
Net_LogPrintf("Player: %d Ploss: %d",MSG_ReadByte(),MSG_ReadByte()); Net_LogPrintf ("Player: %d Ploss: %d", MSG_ReadByte (),
MSG_ReadByte ());
break; break;
default: default:
Net_LogPrintf ("**UNKNOWN**: [%d]", c); Net_LogPrintf ("**UNKNOWN**: [%d]", c);
@ -683,7 +781,8 @@ void Parse_Server_Packet()
} }
} }
void Analyze_Client_Packet(byte *data,int len) void
Analyze_Client_Packet (byte * data, int len)
{ {
// fixme quick-hack // fixme quick-hack
net_message.data = data; net_message.data = data;
@ -693,23 +792,23 @@ void Analyze_Client_Packet(byte *data,int len)
net_message.data = net_message_buffer; net_message.data = net_message_buffer;
} }
void Parse_Client_Packet(void) void
Parse_Client_Packet (void)
{ {
int i, c, ii; int i, c, ii;
long seq1, seq2; long seq1, seq2;
int mask; int mask;
seq1 = MSG_ReadLong (); seq1 = MSG_ReadLong ();
if(seq1==-1) if (seq1 == -1) {
{
Net_LogPrintf ("Special: %s\n", MSG_ReadString ()); Net_LogPrintf ("Special: %s\n", MSG_ReadString ());
return; return;
} else } else {
{
// fixme display seqs right when reliable // fixme display seqs right when reliable
seq2 = MSG_ReadLong (); seq2 = MSG_ReadLong ();
Net_LogPrintf("\nSeq: %ld Ack: %ld ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
seq2 & 0x7FFFFFFF);
/* /*
if ((seq1 >>31) &0x01) Net_LogPrintf("CL_REL "); if ((seq1 >>31) &0x01) Net_LogPrintf("CL_REL ");
if ((seq2 >>31) &0x01) Net_LogPrintf("CL_RELACK "); if ((seq2 >>31) &0x01) Net_LogPrintf("CL_RELACK ");
@ -717,17 +816,18 @@ void Parse_Client_Packet(void)
Net_LogPrintf ("QP: %u\n", MSG_ReadShort ()); Net_LogPrintf ("QP: %u\n", MSG_ReadShort ());
while (1) while (1) {
{ if (msg_badread)
if (msg_badread) break; break;
c = MSG_ReadByte (); c = MSG_ReadByte ();
if (c == -1) break; if (c == -1)
break;
// Net_LogPrintf("<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); // Net_LogPrintf("<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF);
Net_LogPrintf ("\n<%06x> [0x%02x] ", MSG_GetReadCount (), c); Net_LogPrintf ("\n<%06x> [0x%02x] ", MSG_GetReadCount (), c);
if (c<8) Net_LogPrintf("%s: ",clc_string[c]); if (c < 8)
Net_LogPrintf ("%s: ", clc_string[c]);
switch(c) switch (c) {
{
case clc_nop: case clc_nop:
break; break;
case clc_delta: case clc_delta:
@ -740,14 +840,22 @@ void Parse_Client_Packet(void)
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
mask = MSG_ReadByte (); mask = MSG_ReadByte ();
Net_LogPrintf ("\n\t(%d) mask = %02x", i, mask); Net_LogPrintf ("\n\t(%d) mask = %02x", i, mask);
if(mask & 0x01) Net_LogPrintf(" Tilt: %f",MSG_ReadAngle16()); if (mask & 0x01)
if(mask & 0x80) Net_LogPrintf(" Yaw: %f",MSG_ReadAngle16()); Net_LogPrintf (" Tilt: %f", MSG_ReadAngle16 ());
if(mask & 0x02) Net_LogPrintf(" Roll: %f",MSG_ReadAngle16()); if (mask & 0x80)
if(mask & 0x04) Net_LogPrintf(" Fwd: %d",MSG_ReadShort()); Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16 ());
if(mask & 0x08) Net_LogPrintf(" Right: %d",MSG_ReadShort()); if (mask & 0x02)
if(mask & 0x10) Net_LogPrintf(" Up: %d",MSG_ReadShort()); Net_LogPrintf (" Roll: %f", MSG_ReadAngle16 ());
if(mask & 0x20) Net_LogPrintf(" Flags: %d",MSG_ReadByte()); if (mask & 0x04)
if(mask & 0x40) Net_LogPrintf(" Impulse: %d",MSG_ReadByte()); Net_LogPrintf (" Fwd: %d", MSG_ReadShort ());
if (mask & 0x08)
Net_LogPrintf (" Right: %d", MSG_ReadShort ());
if (mask & 0x10)
Net_LogPrintf (" Up: %d", MSG_ReadShort ());
if (mask & 0x20)
Net_LogPrintf (" Flags: %d", MSG_ReadByte ());
if (mask & 0x40)
Net_LogPrintf (" Impulse: %d", MSG_ReadByte ());
Net_LogPrintf (" Msec: %d", MSG_ReadByte ()); Net_LogPrintf (" Msec: %d", MSG_ReadByte ());
} }
break; break;
@ -755,12 +863,14 @@ void Parse_Client_Packet(void)
Net_LogPrintf ("%s", MSG_ReadString ()); Net_LogPrintf ("%s", MSG_ReadString ());
break; break;
case clc_tmove: case clc_tmove:
for (i=0;i<3;i++) Net_LogPrintf("%f ",MSG_ReadCoord()); for (i = 0; i < 3; i++)
Net_LogPrintf ("%f ", MSG_ReadCoord ());
break; break;
case clc_upload: case clc_upload:
ii = MSG_ReadShort (); ii = MSG_ReadShort ();
Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte ()); Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte ());
for (i=0;i<ii;i++) MSG_ReadByte(); for (i = 0; i < ii; i++)
MSG_ReadByte ();
break; break;
default: default:
Net_LogPrintf ("**UNKNOWN**: [%d]", c); Net_LogPrintf ("**UNKNOWN**: [%d]", c);
@ -772,9 +882,11 @@ void Parse_Client_Packet(void)
} }
} }
int Net_Log_Init(void) int
Net_Log_Init (void)
{ {
netlogger=Cvar_Get("net_logger","1",CVAR_NONE,"Packet logging/parsing"); netlogger =
Cvar_Get ("net_logger", "1", CVAR_NONE, "Packet logging/parsing");
// 0 = no logging // 0 = no logging
// 1 = hex dump only // 1 = hex dump only
@ -782,7 +894,8 @@ int Net_Log_Init(void)
// 3 = just parse // 3 = just parse
// 4 = parse/hexdump, skip movement/empty messages // 4 = parse/hexdump, skip movement/empty messages
netloglevel=Cvar_Get("net_loglevel","2",CVAR_NONE,"Packet logging/parsing"); netloglevel =
Cvar_Get ("net_loglevel", "2", CVAR_NONE, "Packet logging/parsing");
Net_LogStart ("QFPACKET.LOG"); Net_LogStart ("QFPACKET.LOG");
return 0; return 0;