mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
except for packet logging, netchan is much cleaner (no more cls in the
server!)
This commit is contained in:
parent
35e29b8f1d
commit
fa58b795f2
8 changed files with 26 additions and 45 deletions
|
@ -106,6 +106,7 @@ typedef struct
|
||||||
|
|
||||||
netadr_t remote_address;
|
netadr_t remote_address;
|
||||||
int qport;
|
int qport;
|
||||||
|
int flags;
|
||||||
|
|
||||||
// bandwidth estimator
|
// bandwidth estimator
|
||||||
double cleartime; // if realtime > nc->cleartime, free to go
|
double cleartime; // if realtime > nc->cleartime, free to go
|
||||||
|
@ -135,6 +136,8 @@ typedef struct
|
||||||
} netchan_t;
|
} netchan_t;
|
||||||
|
|
||||||
extern int net_drop; // packets dropped before this one
|
extern int net_drop; // packets dropped before this one
|
||||||
|
extern int net_nochoke; // don't choke packets
|
||||||
|
extern int net_blocksend; // don't send packets (used by client for demos)
|
||||||
|
|
||||||
void Netchan_Init (void);
|
void Netchan_Init (void);
|
||||||
void Netchan_Init_Cvars (void);
|
void Netchan_Init_Cvars (void);
|
||||||
|
@ -142,7 +145,10 @@ void Netchan_Transmit (netchan_t *chan, int length, byte *data);
|
||||||
void Netchan_OutOfBand (netadr_t adr, int length, byte *data);
|
void Netchan_OutOfBand (netadr_t adr, int length, byte *data);
|
||||||
void Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...) __attribute__((format(printf,2,3)));
|
void Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...) __attribute__((format(printf,2,3)));
|
||||||
qboolean Netchan_Process (netchan_t *chan);
|
qboolean Netchan_Process (netchan_t *chan);
|
||||||
void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
|
void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport, int flags);
|
||||||
|
|
||||||
|
#define NC_SEND_QPORT 0x01
|
||||||
|
#define NC_READ_QPORT 0x02
|
||||||
|
|
||||||
qboolean Netchan_CanPacket (netchan_t *chan);
|
qboolean Netchan_CanPacket (netchan_t *chan);
|
||||||
qboolean Netchan_CanReliable (netchan_t *chan);
|
qboolean Netchan_CanReliable (netchan_t *chan);
|
||||||
|
|
|
@ -104,6 +104,8 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int net_drop;
|
int net_drop;
|
||||||
|
int net_nochoke;
|
||||||
|
int net_blocksend;
|
||||||
cvar_t *showpackets;
|
cvar_t *showpackets;
|
||||||
cvar_t *showdrop;
|
cvar_t *showdrop;
|
||||||
cvar_t *qport;
|
cvar_t *qport;
|
||||||
|
@ -155,10 +157,7 @@ Netchan_OutOfBand (netadr_t adr, int length, byte * data)
|
||||||
|
|
||||||
// send the datagram
|
// send the datagram
|
||||||
// zoid, no input in demo playback mode
|
// zoid, no input in demo playback mode
|
||||||
if (!is_server) {
|
if (!net_blocksend)
|
||||||
if (!cls.demoplayback)
|
|
||||||
Netchan_SendPacket (send.cursize, send.data, adr);
|
|
||||||
} else
|
|
||||||
Netchan_SendPacket (send.cursize, send.data, adr);
|
Netchan_SendPacket (send.cursize, send.data, adr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...)
|
||||||
called to open a channel to a remote system
|
called to open a channel to a remote system
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Netchan_Setup (netchan_t *chan, netadr_t adr, int qport)
|
Netchan_Setup (netchan_t *chan, netadr_t adr, int qport, int flags)
|
||||||
{
|
{
|
||||||
memset (chan, 0, sizeof (*chan));
|
memset (chan, 0, sizeof (*chan));
|
||||||
|
|
||||||
|
@ -201,6 +200,7 @@ Netchan_Setup (netchan_t *chan, netadr_t adr, int qport)
|
||||||
chan->message.maxsize = sizeof (chan->message_buf);
|
chan->message.maxsize = sizeof (chan->message_buf);
|
||||||
|
|
||||||
chan->qport = qport;
|
chan->qport = qport;
|
||||||
|
chan->flags = flags;
|
||||||
|
|
||||||
chan->rate = 1.0 / 2500.0;
|
chan->rate = 1.0 / 2500.0;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ Netchan_CanReliable (netchan_t *chan)
|
||||||
0 length will still generate a packet and deal with the reliable messages.
|
0 length will still generate a packet and deal with the reliable messages.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Netchan_Transmit (netchan_t *chan, int length, byte * data)
|
Netchan_Transmit (netchan_t *chan, int length, byte *data)
|
||||||
{
|
{
|
||||||
byte send_buf[MAX_MSGLEN + PACKET_HEADER];
|
byte send_buf[MAX_MSGLEN + PACKET_HEADER];
|
||||||
int i;
|
int i;
|
||||||
|
@ -286,8 +286,8 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
|
||||||
MSG_WriteLong (&send, w2);
|
MSG_WriteLong (&send, w2);
|
||||||
|
|
||||||
// send the qport if we are a client
|
// send the qport if we are a client
|
||||||
if (!is_server)
|
if (chan->flags & NC_SEND_QPORT)
|
||||||
MSG_WriteShort (&send, cls.qport);
|
MSG_WriteShort (&send, chan->qport);
|
||||||
|
|
||||||
// copy the reliable message to the packet first
|
// copy the reliable message to the packet first
|
||||||
if (send_reliable) {
|
if (send_reliable) {
|
||||||
|
@ -304,17 +304,14 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
|
||||||
chan->outgoing_time[i] = realtime;
|
chan->outgoing_time[i] = realtime;
|
||||||
|
|
||||||
// zoid, no input in demo playback mode
|
// zoid, no input in demo playback mode
|
||||||
if (!is_server) {
|
if (!net_blocksend)
|
||||||
if (!cls.demoplayback)
|
|
||||||
Netchan_SendPacket (send.cursize, send.data, chan->remote_address);
|
|
||||||
} else
|
|
||||||
Netchan_SendPacket (send.cursize, send.data, chan->remote_address);
|
Netchan_SendPacket (send.cursize, send.data, chan->remote_address);
|
||||||
|
|
||||||
if (chan->cleartime < realtime)
|
if (chan->cleartime < realtime)
|
||||||
chan->cleartime = realtime + send.cursize * chan->rate;
|
chan->cleartime = realtime + send.cursize * chan->rate;
|
||||||
else
|
else
|
||||||
chan->cleartime += send.cursize * chan->rate;
|
chan->cleartime += send.cursize * chan->rate;
|
||||||
if (ServerPaused ())
|
if (net_nochoke)
|
||||||
chan->cleartime = realtime;
|
chan->cleartime = realtime;
|
||||||
|
|
||||||
if (showpackets->int_val)
|
if (showpackets->int_val)
|
||||||
|
@ -335,13 +332,9 @@ Netchan_Process (netchan_t *chan)
|
||||||
int qport;
|
int qport;
|
||||||
unsigned int reliable_ack, reliable_message, sequence, sequence_ack;
|
unsigned int reliable_ack, reliable_message, sequence, sequence_ack;
|
||||||
|
|
||||||
if (is_server) {
|
if (!net_blocksend)
|
||||||
if (!NET_CompareAdr (net_from, chan->remote_address))
|
if (!NET_CompareAdr (net_from, chan->remote_address))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
if (!cls.demoplayback &&
|
|
||||||
!NET_CompareAdr (net_from, chan->remote_address)) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get sequence numbers
|
// get sequence numbers
|
||||||
MSG_BeginReading (net_message);
|
MSG_BeginReading (net_message);
|
||||||
|
@ -349,7 +342,7 @@ Netchan_Process (netchan_t *chan)
|
||||||
sequence_ack = MSG_ReadLong (net_message);
|
sequence_ack = MSG_ReadLong (net_message);
|
||||||
|
|
||||||
// read the qport if we are a server
|
// read the qport if we are a server
|
||||||
if (is_server)
|
if (chan->flags & NC_READ_QPORT)
|
||||||
qport = MSG_ReadShort (net_message);
|
qport = MSG_ReadShort (net_message);
|
||||||
|
|
||||||
reliable_message = sequence >> 31;
|
reliable_message = sequence >> 31;
|
||||||
|
|
|
@ -50,23 +50,17 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
|
||||||
#include "netchan.h"
|
#include "netchan.h"
|
||||||
|
|
||||||
#include "../../qw/include/client.h" //FIXME ick, netchan is so incestuous
|
|
||||||
|
|
||||||
SERVER_PLUGIN_PROTOS
|
SERVER_PLUGIN_PROTOS
|
||||||
static plugin_list_t server_plugin_list[] = {
|
static plugin_list_t server_plugin_list[] = {
|
||||||
SERVER_PLUGIN_LIST
|
SERVER_PLUGIN_LIST
|
||||||
};
|
};
|
||||||
|
|
||||||
qboolean is_server = true;
|
|
||||||
double realtime;
|
double realtime;
|
||||||
cvar_t *net_packetlog;
|
cvar_t *net_packetlog;
|
||||||
client_static_t cls;
|
|
||||||
void Log_Outgoing_Packet (const char *p, int len, int has_sequence);
|
void Log_Outgoing_Packet (const char *p, int len, int has_sequence);
|
||||||
void Log_Incoming_Packet (const char *p, int len, int has_sequence);
|
void Log_Incoming_Packet (const char *p, int len, int has_sequence);
|
||||||
qboolean ServerPaused (void);
|
|
||||||
void Log_Outgoing_Packet (const char *p, int len, int has_sequence) { }
|
void Log_Outgoing_Packet (const char *p, int len, int has_sequence) { }
|
||||||
void Log_Incoming_Packet (const char *p, int len, int has_sequence) { }
|
void Log_Incoming_Packet (const char *p, int len, int has_sequence) { }
|
||||||
qboolean ServerPaused (void) { return 0; }
|
|
||||||
|
|
||||||
|
|
||||||
cbuf_t *qtv_cbuf;
|
cbuf_t *qtv_cbuf;
|
||||||
|
|
|
@ -119,6 +119,7 @@ CL_StopPlayback (void)
|
||||||
cls.demoplayback = 0;
|
cls.demoplayback = 0;
|
||||||
cls.demoplayback2 = 0;
|
cls.demoplayback2 = 0;
|
||||||
demotime_cached = 0;
|
demotime_cached = 0;
|
||||||
|
net_blocksend = 0;
|
||||||
|
|
||||||
if (cls.timedemo)
|
if (cls.timedemo)
|
||||||
CL_FinishTimeDemo ();
|
CL_FinishTimeDemo ();
|
||||||
|
@ -896,6 +897,7 @@ CL_StartDemo (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.demoplayback = true;
|
cls.demoplayback = true;
|
||||||
|
net_blocksend = 1;
|
||||||
if (strequal (QFS_FileExtension (name), ".mvd")) {
|
if (strequal (QFS_FileExtension (name), ".mvd")) {
|
||||||
cls.demoplayback2 = true;
|
cls.demoplayback2 = true;
|
||||||
Con_Printf ("mvd\n");
|
Con_Printf ("mvd\n");
|
||||||
|
@ -903,7 +905,7 @@ CL_StartDemo (void)
|
||||||
Con_Printf ("qwd\n");
|
Con_Printf ("qwd\n");
|
||||||
}
|
}
|
||||||
CL_SetState (ca_demostart);
|
CL_SetState (ca_demostart);
|
||||||
Netchan_Setup (&cls.netchan, net_from, 0);
|
Netchan_Setup (&cls.netchan, net_from, 0, NC_SEND_QPORT);
|
||||||
realtime = 0;
|
realtime = 0;
|
||||||
cls.findtrack = true;
|
cls.findtrack = true;
|
||||||
cls.lasttype = 0;
|
cls.lasttype = 0;
|
||||||
|
|
|
@ -845,7 +845,7 @@ CL_ConnectionlessPacket (void)
|
||||||
Con_Printf ("Dup connect received. Ignored.\n");
|
Con_Printf ("Dup connect received. Ignored.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Netchan_Setup (&cls.netchan, net_from, cls.qport);
|
Netchan_Setup (&cls.netchan, net_from, cls.qport, NC_SEND_QPORT);
|
||||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||||
MSG_WriteString (&cls.netchan.message, "new");
|
MSG_WriteString (&cls.netchan.message, "new");
|
||||||
CL_SetState (ca_connected);
|
CL_SetState (ca_connected);
|
||||||
|
@ -1820,9 +1820,3 @@ Host_Shutdown (void)
|
||||||
if (host_basepal)
|
if (host_basepal)
|
||||||
VID_Shutdown ();
|
VID_Shutdown ();
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean
|
|
||||||
ServerPaused (void)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
#include "bothdefs.h"
|
#include "bothdefs.h"
|
||||||
#include "buildnum.h"
|
#include "buildnum.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "client.h" //FIXME needed by cls below (for netchan)
|
|
||||||
#include "crudefile.h"
|
#include "crudefile.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "netchan.h"
|
#include "netchan.h"
|
||||||
|
@ -102,7 +101,6 @@ cbuf_t *sv_cbuf;
|
||||||
cbuf_args_t *sv_args;
|
cbuf_args_t *sv_args;
|
||||||
|
|
||||||
client_t *host_client; // current client
|
client_t *host_client; // current client
|
||||||
client_static_t cls; //FIXME needed by netchan :/
|
|
||||||
entity_state_t cl_entities[MAX_CLIENTS][UPDATE_BACKUP+1][MAX_PACKET_ENTITIES]; // client entities
|
entity_state_t cl_entities[MAX_CLIENTS][UPDATE_BACKUP+1][MAX_PACKET_ENTITIES]; // client entities
|
||||||
|
|
||||||
double sv_frametime;
|
double sv_frametime;
|
||||||
|
@ -214,13 +212,6 @@ const char *client_info_filters[] = { // Info keys needed by client
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
qboolean
|
|
||||||
ServerPaused (void)
|
|
||||||
{
|
|
||||||
return sv.paused;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Master_Shutdown
|
Master_Shutdown
|
||||||
|
|
||||||
|
@ -905,7 +896,7 @@ SVC_DirectConnect (void)
|
||||||
|
|
||||||
Netchan_OutOfBandPrint (adr, "%c", S2C_CONNECTION);
|
Netchan_OutOfBandPrint (adr, "%c", S2C_CONNECTION);
|
||||||
|
|
||||||
Netchan_Setup (&newcl->netchan, adr, qport);
|
Netchan_Setup (&newcl->netchan, adr, qport, NC_READ_QPORT);
|
||||||
|
|
||||||
newcl->state = cs_connected;
|
newcl->state = cs_connected;
|
||||||
newcl->prespawned = false;
|
newcl->prespawned = false;
|
||||||
|
|
|
@ -1823,7 +1823,7 @@ PF_SV_AllocClient (progs_t *pr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//XXX netchan? Netchan_Setup (&newcl->netchan, adr, qport);
|
//XXX netchan? Netchan_Setup (&newcl->netchan, adr, qport, NC_READ_QPORT);
|
||||||
cl->state = cs_server;
|
cl->state = cs_server;
|
||||||
cl->spectator = 0;
|
cl->spectator = 0;
|
||||||
cl->connection_started = realtime;
|
cl->connection_started = realtime;
|
||||||
|
|
|
@ -944,6 +944,7 @@ SV_TogglePause (const char *msg)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sv.paused ^= 1;
|
sv.paused ^= 1;
|
||||||
|
net_nochoke = sv.paused;
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
SV_BroadcastPrintf (PRINT_HIGH, "%s", msg);
|
SV_BroadcastPrintf (PRINT_HIGH, "%s", msg);
|
||||||
|
|
Loading…
Reference in a new issue