- split net_clc.h into net_clc.h and net_clc_qw.h

- move clc_t into net_clc.h from net_protocol.h
- split packet processing stuff from net.h into net_packet.h
- add a is_server arg to Log_{Incoming,Outgoing}_Packet, so libs/net is
  oblivious to if we're running a server or not (except with the arg,
  obviously)
- remove the long obsolete (even in original quake) svc_spawnbinary
  stuff
- make nq use QF/net_svc.h
- make nq link to libQFnet too
- make qw's cl_parse.c use net_svc_qw_any_t instead of net_svc_any_t
This commit is contained in:
Adam Olsen 2001-11-18 11:39:12 +00:00
parent 2994824bc6
commit 7f10b0f237
16 changed files with 157 additions and 83 deletions

View file

@ -34,7 +34,6 @@
#include "QF/sizebuf.h"
#define MAX_MSGLEN 1450
#define MAX_PROJECTILES 32
#define PORT_ANY -1
@ -136,8 +135,8 @@ qboolean Netchan_CanPacket (netchan_t *chan);
qboolean Netchan_CanReliable (netchan_t *chan);
int Net_Log_Init (const char **sound_precache);
void Log_Incoming_Packet (const char *p, int len);
void Log_Outgoing_Packet (const char *p, int len);
void Log_Incoming_Packet (const char *p, int len, qboolean is_server);
void Log_Outgoing_Packet (const char *p, int len, qboolean is_server);
void Net_LogStop (void);
void Analyze_Server_Packet (const byte *data, int len);
void Analyze_Client_Packet (const byte *data, int len);
@ -146,13 +145,4 @@ extern struct cvar_s *net_packetlog;
extern qboolean is_server;
//============================================================================
typedef enum
{
NET_OK,
NET_SHORT,
NET_ERROR
} net_status_t;
#endif // QF_NET_H

View file

@ -26,17 +26,27 @@
$Id$
*/
#ifndef NET_CLC_H
#define NET_CLC_H
#ifndef QF_NET_CLC_H
#define QF_NET_CLC_H
#include "QF/mathlib.h"
#include "QF/msg.h"
#include "QF/net.h"
#include "QF/net_packet.h"
#include "QF/net_protocol.h"
//#include "bothdefs.h"
//#include "net.h"
//#include "pmove.h"
// N means netquake, Q means quakeworld
typedef enum {
clc_bad = 0,
clc_nop = 1, // NQ
clc_disconnect = 2, // N
clc_move = 3, // NQ [usercmd_t]
clc_stringcmd = 4, // NQ [string] message
clc_delta = 5, // Q [byte] sequence number, requests delta
// compression of message
clc_tmove = 6, // Q teleport request, spectator only
clc_upload = 7, // Q teleport request, spectator only
} clc_t;
typedef struct net_clc_nop_s
{
@ -105,4 +115,4 @@ net_status_t NET_CLC_TMove_Parse (net_clc_tmove_t *block, msg_t *msg);
net_status_t NET_CLC_Upload_Emit (net_clc_upload_t *block, sizebuf_t *buf);
net_status_t NET_CLC_Upload_Parse (net_clc_upload_t *block, msg_t *msg);
#endif // NET_CLC_H
#endif // QF_NET_CLC_H

36
include/QF/net_clc_qw.h Normal file
View file

@ -0,0 +1,36 @@
/*
net_clc_qw.h
(description)
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef QF_NET_CLC_QW_H
#define QF_NET_CLC_QW_H
#include "QF/net_clc.h"
#include "QF/net_protocol.h"
#endif // QF_NET_CLC_QW_H

44
include/QF/net_packet.h Normal file
View file

@ -0,0 +1,44 @@
/*
net.h
quake's interface to the networking layer
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef QF_NET_PACKET_H
#define QF_NET_PACKET_H
#include "QF/qdefs.h"
#define MAX_PROJECTILES 32
typedef enum
{
NET_OK,
NET_SHORT,
NET_ERROR
} net_status_t;
#endif // QF_NET_PACKET_H

View file

@ -70,24 +70,6 @@
//==================
//==============================================
//
// client to server
//
typedef enum {
clc_bad = 0,
clc_nop = 1,
// clc_doublemove 2, // NQ only
clc_move = 3, // [usercmd_t]
clc_stringcmd = 4, // [string] message
clc_delta = 5, // [byte] sequence number, requests delta
// compression of message
clc_tmove = 6, // teleport request, spectator only
clc_upload = 7, // teleport request, spectator only
} clc_t;
//==============================================
// playerinfo flags from server

View file

@ -26,11 +26,11 @@
$Id$
*/
#ifndef NET_SVC_H
#define NET_SVC_H
#ifndef QF_NET_SVC_H
#define QF_NET_SVC_H
#include "QF/msg.h"
#include "QF/net.h"
#include "QF/net_packet.h"
// N means netquake, Q means quakeworld
typedef enum {
@ -303,4 +303,4 @@ net_status_t NET_SVC_SellScreen_Parse (net_svc_sellscreen_t *block, msg_t *msg);
net_status_t NET_SVC_SetPause_Emit (net_svc_setpause_t *block, sizebuf_t *buf);
net_status_t NET_SVC_SetPause_Parse (net_svc_setpause_t *block, msg_t *msg);
#endif // NET_SVC_H
#endif // QF_NET_SVC_H

View file

@ -232,6 +232,38 @@ typedef struct net_svc_updatepl_s
byte packetloss;
} net_svc_updatepl_t;
typedef union net_svc_qw_any_u
{
net_svc_any_t common;
net_svc_qwupdatestat_t qwupdatestat;
net_svc_qwsound_t qwsound;
net_svc_qwprint_t qwprint;
net_svc_serverdata_t serverdata;
net_svc_qwtempentity_t qwtempentity;
net_svc_qwintermission_t qwintermission;
net_svc_qwcdtrack_t qwcdtrack;
net_svc_smallkick_t smallkick;
net_svc_bigkick_t bigkick;
net_svc_updateping_t updateping;
net_svc_updateentertime_t updateentertime;
net_svc_updatestatlong_t updatestatlong;
net_svc_muzzleflash_t muzzleflash;
net_svc_updateuserinfo_t updateuserinfo;
net_svc_download_t download;
net_svc_playerinfo_t playerinfo;
net_svc_nails_t nails;
net_svc_chokecount_t chokecount;
net_svc_modellist_t modellist;
net_svc_soundlist_t soundlist;
net_svc_packetentities_t packetentities;
net_svc_deltapacketentities_t deltapacketentities;
net_svc_maxspeed_t maxspeed;
net_svc_entgravity_t entgravity;
net_svc_setinfo_t setinfo;
net_svc_qwserverinfo_t qwserverinfo;
net_svc_updatepl_t updatepl;
} net_svc_qw_any_t;
extern net_svc_emit_t net_svc_qw_emit_jumptable[];
extern int net_svc_qw_emit_count;
extern net_svc_parse_t net_svc_qw_parse_jumptable[];

View file

@ -103,8 +103,7 @@ NET_CLC_Emit (clc_t type, void *block, sizebuf_t *buf)
if (type < 0 ||
type >= sizeof (net_clc_emit_jumptable) / sizeof (net_clc_emit_t) ||
!net_clc_emit_jumptable[type])
// return NET_ERROR;
Sys_Error ("NET_SVC_Emit: invalid type %d\n", type);
return NET_ERROR;
MSG_WriteByte (buf, type);
retval = net_clc_emit_jumptable[type] (block, buf);

View file

@ -52,18 +52,13 @@ static const char rcsid[] =
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/msg.h"
#include "QF/net.h"
#include "QF/net_clc.h"
#include "QF/net_packet.h"
#include "QF/net_protocol.h"
#include "QF/net_svc.h"
#include "QF/va.h"
#include "QF/vfs.h"
//#include "compat.h"
//#include "net.h"
//#include "net_svc.h"
//#include "protocol.h"
//#include "server.h"
cvar_t *net_packetlog;
cvar_t *net_loglevel;
@ -86,19 +81,7 @@ const char *clc_string[] = {
"clc_upload"
};
#ifndef svc_spawnbinary
# define svc_spawnbinary 21
#endif
// Quake1, obsolete for QW
#define svc_time 7 // [float] server time
#define svc_updatename 13 // [byte] [string]
#define svc_version 4 // [long] server version
#define svc_clientdata 15 // <shortbits + data>
#define svc_updatecolors 17 // [byte] [byte]
#define svc_particle 18 // [vec3] <variable>
#define svc_signonnum 25 // [byte] used for the signon
// sequence
static VFile *Net_PacketLog;
static const char **Net_sound_precache;
static sizebuf_t _packet;
@ -187,7 +170,7 @@ ascii_dump_buf (unsigned char *buf, int len)
}
void
Log_Incoming_Packet (const char *p, int len)
Log_Incoming_Packet (const char *p, int len, qboolean is_server)
{
if (!net_loglevel->int_val)
return;
@ -211,7 +194,7 @@ Log_Incoming_Packet (const char *p, int len)
}
void
Log_Outgoing_Packet (const char *p, int len)
Log_Outgoing_Packet (const char *p, int len, qboolean is_server)
{
if (!net_loglevel->int_val)
return;
@ -495,9 +478,6 @@ Parse_Server_Packet ()
Net_LogPrintf ("%f", MSG_ReadAngle (&packet));
}
break;
case svc_spawnbinary:
Net_LogPrintf ("**OBSOLETE**");
break;
case svc_spawnbaseline:
Net_LogPrintf ("%d", MSG_ReadShort (&packet));
Net_LogPrintf (" idx: %d", MSG_ReadByte (&packet));

View file

@ -45,7 +45,7 @@ static const char rcsid[] =
#endif
#include "QF/msg.h"
#include "QF/net.h"
#include "QF/net_packet.h"
#include "QF/net_svc.h"
#include "QF/net_ucmd.h"
#include "QF/sound.h"
@ -186,8 +186,7 @@ NET_SVC_Emit (svc_t type, void *block, sizebuf_t *buf)
if (type < 0 || type >= net_svc_emit_count ||
!net_svc_emit_jumptable[type])
// return NET_ERROR;
Sys_Error ("NET_SVC_Emit: invalid type %d\n", type);
return NET_ERROR;
MSG_WriteByte (buf, type);
retval = net_svc_emit_jumptable[type] (block, buf);

View file

@ -38,14 +38,11 @@ static const char rcsid[] =
#endif
#include "QF/msg.h"
#include "QF/net.h"
#include "QF/net_packet.h"
#include "QF/net_protocol.h"
#include "QF/qendian.h"
#include "QF/sys.h"
//#include "net.h"
//#include "protocol.h"
struct usercmd_s nullcmd;

View file

@ -29,6 +29,7 @@
#ifndef __protocol_h
#define __protocol_h
#include "QF/net_svc.h"
#include "QF/qtypes.h"
#define PROTOCOL_VERSION 15
@ -89,6 +90,7 @@
// also related to svc_strings[] in cl_parse
//==================
/*
//
// server to client
//
@ -141,6 +143,7 @@
#define svc_sellscreen 33
#define svc_cutscene 34
*/
//
// client to server
@ -174,8 +177,6 @@
#define TE_BEAM 17
// PGM 01/21/97
#define MAX_CLIENTS 16
typedef struct entity_state_s
{
vec3_t origin;

View file

@ -76,6 +76,7 @@ common_LIBFILES= \
$(top_builddir)/libs/gamecode/engine/libQFgamecode.la \
$(top_builddir)/libs/gamecode/builtins/libQFgamecode_builtins.la \
$(top_builddir)/libs/gib/libQFgib.la \
$(top_builddir)/libs/net/libQFnet.la \
$(top_builddir)/libs/util/libQFutil.la
client_LIBS= $(client_LIBFILES) $(common_LIBFILES) $(NET_LIBS)

View file

@ -1002,7 +1002,8 @@ CL_ReadPackets (void)
if (cls.demoplayback && net_packetlog->int_val)
Log_Incoming_Packet(net_message->message->data,
net_message->message->cursize);
net_message->message->cursize,
is_server);
// remote command packet
if (*(int *) net_message->message->data == -1) {
@ -1376,7 +1377,7 @@ Host_NetError (const char *message, ...)
if (net_packetlog->int_val)
Cvar_Set (net_packetlog, "0");
Log_Incoming_Packet (net_message->message->data,
net_message->message->cursize);
net_message->message->cursize, is_server);
if (old)
Cvar_SetValue (net_packetlog, old);

View file

@ -1227,7 +1227,7 @@ CL_ParseSetPause (net_svc_setpause_t *block)
}
typedef void (*cl_parse_t) (net_svc_any_t *block);
typedef void (*cl_parse_t) (net_svc_qw_any_t *block);
static cl_parse_t cl_parse_jumptable [] = {
[svc_nop] = (cl_parse_t) CL_ParseNOP,
[svc_disconnect] = (cl_parse_t) CL_ParseDisconnect,
@ -1281,7 +1281,7 @@ CL_ParseServerMessage (void)
{
svc_t cmd;
net_status_t retval;
net_svc_any_t block;
net_svc_qw_any_t block;
cl.last_servermessage = realtime;
CL_ClearProjectiles ();
@ -1314,7 +1314,8 @@ CL_ParseServerMessage (void)
Con_Printf ("%3i:%s\n", net_message->readcount - 1,
NET_SVC_GetString (cmd));
if ((retval = NET_SVC_Parse (&cmd, &block, net_message))) {
if ((retval = NET_SVC_Parse (&cmd, (net_svc_any_t *)&block,
net_message))) {
Host_NetError (retval == NET_SHORT ?
"CL_ParseServerMessage: Truncated Packet" :
"CL_ParseServerMessage: Invalid Packet");

View file

@ -299,7 +299,8 @@ NET_GetPacket (void)
}
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, is_server);
return ret;
}
@ -312,7 +313,7 @@ NET_SendPacket (int length, void *data, netadr_t to)
NetadrToSockadr (&to, &addr);
if (net_packetlog->int_val)
Log_Outgoing_Packet(data,length);
Log_Outgoing_Packet (data, length, is_server);
ret =
sendto (net_socket, data, length, 0, (struct sockaddr *) &addr,