r808 - in trunk/code: qcommon server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Jun 17 15:19:35 EDT 2006
Author: tma
Date: 2006-06-17 15:19:34 -0400 (Sat, 17 Jun 2006)
New Revision: 808
Modified:
trunk/code/qcommon/common.c
trunk/code/qcommon/net_chan.c
trunk/code/qcommon/qcommon.h
trunk/code/server/server.h
trunk/code/server/sv_client.c
trunk/code/server/sv_init.c
trunk/code/server/sv_main.c
trunk/code/server/sv_snapshot.c
Log:
* sv_minRate (from R1CH)
* [cl|sv]_packetdelay (from tjw)
Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/qcommon/common.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -77,6 +77,8 @@
cvar_t *com_introPlayed;
cvar_t *cl_paused;
cvar_t *sv_paused;
+cvar_t *cl_packetdelay;
+cvar_t *sv_packetdelay;
cvar_t *com_cameraMode;
#if defined(_WIN32) && defined(_DEBUG)
cvar_t *com_noErrorInterrupt;
@@ -2085,6 +2087,7 @@
MSG_Init( &buf, bufData, sizeof( bufData ) );
while ( 1 ) {
+ NET_FlushPacketQueue();
ev = Com_GetEvent();
// if no more events are available
@@ -2477,6 +2480,8 @@
cl_paused = Cvar_Get ("cl_paused", "0", CVAR_ROM);
sv_paused = Cvar_Get ("sv_paused", "0", CVAR_ROM);
+ cl_packetdelay = Cvar_Get ("cl_packetdelay", "0", CVAR_CHEAT);
+ sv_packetdelay = Cvar_Get ("sv_packetdelay", "0", CVAR_CHEAT);
com_sv_running = Cvar_Get ("sv_running", "0", CVAR_ROM);
com_cl_running = Cvar_Get ("cl_running", "0", CVAR_ROM);
com_buildScript = Cvar_Get( "com_buildScript", "0", 0 );
Modified: trunk/code/qcommon/net_chan.c
===================================================================
--- trunk/code/qcommon/net_chan.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/qcommon/net_chan.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -615,7 +615,63 @@
//=============================================================================
+typedef struct packetQueue_s {
+ struct packetQueue_s *next;
+ int length;
+ byte *data;
+ netadr_t to;
+ int release;
+} packetQueue_t;
+packetQueue_t *packetQueue = NULL;
+
+static void NET_QueuePacket( int length, const void *data, netadr_t to,
+ int offset )
+{
+ packetQueue_t *new, *next = packetQueue;
+
+ if(offset > 999)
+ offset = 999;
+
+ new = S_Malloc(sizeof(packetQueue_t));
+ new->data = S_Malloc(length);
+ Com_Memcpy(new->data, data, length);
+ new->length = length;
+ new->to = to;
+ new->release = Sys_Milliseconds() + offset;
+ new->next = NULL;
+
+ if(!packetQueue) {
+ packetQueue = new;
+ return;
+ }
+ while(next) {
+ if(!next->next) {
+ next->next = new;
+ return;
+ }
+ next = next->next;
+ }
+}
+
+void NET_FlushPacketQueue(void)
+{
+ packetQueue_t *last;
+ int now;
+
+ while(packetQueue) {
+ now = Sys_Milliseconds();
+ if(packetQueue->release >= now)
+ break;
+ Sys_SendPacket(packetQueue->length, packetQueue->data,
+ packetQueue->to);
+ last = packetQueue;
+ packetQueue = packetQueue->next;
+ Z_Free(last->data);
+ Z_Free(last);
+ }
+}
+
void NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to ) {
// sequenced packets are shown in netchan, so just show oob
@@ -634,7 +690,15 @@
return;
}
- Sys_SendPacket( length, data, to );
+ if ( sock == NS_CLIENT && cl_packetdelay->integer > 0 ) {
+ NET_QueuePacket( length, data, to, cl_packetdelay->integer );
+ }
+ else if ( sock == NS_SERVER && sv_packetdelay->integer > 0 ) {
+ NET_QueuePacket( length, data, to, sv_packetdelay->integer );
+ }
+ else {
+ Sys_SendPacket( length, data, to );
+ }
}
/*
Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/qcommon/qcommon.h 2006-06-17 19:19:34 UTC (rev 808)
@@ -159,7 +159,7 @@
void NET_Shutdown( void );
void NET_Restart( void );
void NET_Config( qboolean enableNetworking );
-
+void NET_FlushPacketQueue(void);
void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to);
void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...);
void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len );
@@ -758,6 +758,9 @@
extern cvar_t *cl_paused;
extern cvar_t *sv_paused;
+extern cvar_t *cl_packetdelay;
+extern cvar_t *sv_packetdelay;
+
// com_speeds times
extern int time_game;
extern int time_frontend;
Modified: trunk/code/server/server.h
===================================================================
--- trunk/code/server/server.h 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/server/server.h 2006-06-17 19:19:34 UTC (rev 808)
@@ -238,6 +238,7 @@
extern cvar_t *sv_mapname;
extern cvar_t *sv_mapChecksum;
extern cvar_t *sv_serverid;
+extern cvar_t *sv_minRate;
extern cvar_t *sv_maxRate;
extern cvar_t *sv_minPing;
extern cvar_t *sv_maxPing;
Modified: trunk/code/server/sv_client.c
===================================================================
--- trunk/code/server/sv_client.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/server/sv_client.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -901,6 +901,12 @@
rate = sv_maxRate->integer;
}
}
+ if ( sv_minRate->integer ) {
+ if ( sv_minRate->integer < 1000 )
+ Cvar_Set( "sv_minRate", "1000" );
+ if ( sv_minRate->integer > rate )
+ rate = sv_minRate->integer;
+ }
if (!rate) {
blockspersnap = 1;
Modified: trunk/code/server/sv_init.c
===================================================================
--- trunk/code/server/sv_init.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/server/sv_init.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -582,6 +582,7 @@
sv_hostname = Cvar_Get ("sv_hostname", "noname", CVAR_SERVERINFO | CVAR_ARCHIVE );
sv_maxclients = Cvar_Get ("sv_maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH);
+ sv_minRate = Cvar_Get ("sv_minRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO );
sv_maxRate = Cvar_Get ("sv_maxRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO );
sv_minPing = Cvar_Get ("sv_minPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO );
sv_maxPing = Cvar_Get ("sv_maxPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO );
Modified: trunk/code/server/sv_main.c
===================================================================
--- trunk/code/server/sv_main.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/server/sv_main.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -44,6 +44,7 @@
cvar_t *sv_mapname;
cvar_t *sv_mapChecksum;
cvar_t *sv_serverid;
+cvar_t *sv_minRate;
cvar_t *sv_maxRate;
cvar_t *sv_minPing;
cvar_t *sv_maxPing;
Modified: trunk/code/server/sv_snapshot.c
===================================================================
--- trunk/code/server/sv_snapshot.c 2006-06-17 07:46:19 UTC (rev 807)
+++ trunk/code/server/sv_snapshot.c 2006-06-17 19:19:34 UTC (rev 808)
@@ -551,6 +551,13 @@
rate = sv_maxRate->integer;
}
}
+ if ( sv_minRate->integer ) {
+ if ( sv_minRate->integer < 1000 )
+ Cvar_Set( "sv_minRate", "1000" );
+ if ( sv_minRate->integer > rate )
+ rate = sv_minRate->integer;
+ }
+
rateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / rate;
return rateMsec;
More information about the quake3-commits
mailing list