mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 21:51:09 +00:00
* sv_minRate (from R1CH)
* [cl|sv]_packetdelay (from tjw)
This commit is contained in:
parent
394c09fa26
commit
7d657ba62f
8 changed files with 90 additions and 2 deletions
|
@ -77,6 +77,8 @@ cvar_t *com_buildScript; // for automated data building scripts
|
|||
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 @@ int Com_EventLoop( void ) {
|
|||
MSG_Init( &buf, bufData, sizeof( bufData ) );
|
||||
|
||||
while ( 1 ) {
|
||||
NET_FlushPacketQueue();
|
||||
ev = Com_GetEvent();
|
||||
|
||||
// if no more events are available
|
||||
|
@ -2477,6 +2480,8 @@ void Com_Init( char *commandLine ) {
|
|||
|
||||
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 );
|
||||
|
|
|
@ -615,6 +615,62 @@ void NET_SendLoopPacket (netsrc_t sock, int length, const void *data, netadr_t t
|
|||
|
||||
//=============================================================================
|
||||
|
||||
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 ) {
|
||||
|
||||
|
@ -634,7 +690,15 @@ void NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to )
|
|||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -159,7 +159,7 @@ void NET_Init( void );
|
|||
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 *com_altivec;
|
|||
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;
|
||||
|
|
|
@ -238,6 +238,7 @@ extern cvar_t *sv_killserver;
|
|||
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;
|
||||
|
|
|
@ -901,6 +901,12 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
|
|||
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;
|
||||
|
|
|
@ -582,6 +582,7 @@ void SV_Init (void) {
|
|||
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 );
|
||||
|
|
|
@ -44,6 +44,7 @@ cvar_t *sv_killserver; // menu system can set to 1 to shut server down
|
|||
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;
|
||||
|
|
|
@ -551,6 +551,13 @@ static int SV_RateMsec( client_t *client, int messageSize ) {
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue