- Improve snapshot rate and data rate control
- Make server send packet fragments and queued packets when server is idle - Voip protocol detection is tied to com_protocol making past-end-of-message reading unncessary - Use Hunk_AllocateTempMemory() for buffering VOIP packets and fix buffering scheme that ryan hates so much - Disable packet scrambling for new protocol as it is useless now - Get rid of the old packet scrambling functions predating latest point release - Use Hunk_AllocateTempMemory() for netchan packet queue to fix memory leak when client gets disconnected with packets in the queue - Use Hunk_AllocateTempMemory() for download blocks to fix memory leak when client gets disconnected with download blocks in the queue - Fix SV_RateMsec to account for udp/udp6 packet lengths
This commit is contained in:
parent
a844c94af1
commit
ac30d86db0
15 changed files with 345 additions and 356 deletions
|
@ -99,92 +99,6 @@ void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int
|
|||
#endif
|
||||
}
|
||||
|
||||
// TTimo: unused, commenting out to make gcc happy
|
||||
#if 0
|
||||
/*
|
||||
==============
|
||||
Netchan_ScramblePacket
|
||||
|
||||
A probably futile attempt to make proxy hacking somewhat
|
||||
more difficult.
|
||||
==============
|
||||
*/
|
||||
#define SCRAMBLE_START 6
|
||||
static void Netchan_ScramblePacket( msg_t *buf ) {
|
||||
unsigned seed;
|
||||
int i, j, c, mask, temp;
|
||||
int seq[MAX_PACKETLEN];
|
||||
|
||||
seed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );
|
||||
c = buf->cursize;
|
||||
if ( c <= SCRAMBLE_START ) {
|
||||
return;
|
||||
}
|
||||
if ( c > MAX_PACKETLEN ) {
|
||||
Com_Error( ERR_DROP, "MAX_PACKETLEN" );
|
||||
}
|
||||
|
||||
// generate a sequence of "random" numbers
|
||||
for (i = 0 ; i < c ; i++) {
|
||||
seed = (119 * seed + 1);
|
||||
seq[i] = seed;
|
||||
}
|
||||
|
||||
// transpose each character
|
||||
for ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {
|
||||
}
|
||||
mask >>= 1;
|
||||
for (i = SCRAMBLE_START ; i < c ; i++) {
|
||||
j = SCRAMBLE_START + ( seq[i] & mask );
|
||||
temp = buf->data[j];
|
||||
buf->data[j] = buf->data[i];
|
||||
buf->data[i] = temp;
|
||||
}
|
||||
|
||||
// byte xor the data after the header
|
||||
for (i = SCRAMBLE_START ; i < c ; i++) {
|
||||
buf->data[i] ^= seq[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void Netchan_UnScramblePacket( msg_t *buf ) {
|
||||
unsigned seed;
|
||||
int i, j, c, mask, temp;
|
||||
int seq[MAX_PACKETLEN];
|
||||
|
||||
seed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );
|
||||
c = buf->cursize;
|
||||
if ( c <= SCRAMBLE_START ) {
|
||||
return;
|
||||
}
|
||||
if ( c > MAX_PACKETLEN ) {
|
||||
Com_Error( ERR_DROP, "MAX_PACKETLEN" );
|
||||
}
|
||||
|
||||
// generate a sequence of "random" numbers
|
||||
for (i = 0 ; i < c ; i++) {
|
||||
seed = (119 * seed + 1);
|
||||
seq[i] = seed;
|
||||
}
|
||||
|
||||
// byte xor the data after the header
|
||||
for (i = SCRAMBLE_START ; i < c ; i++) {
|
||||
buf->data[i] ^= seq[i];
|
||||
}
|
||||
|
||||
// transpose each character in reverse order
|
||||
for ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {
|
||||
}
|
||||
mask >>= 1;
|
||||
for (i = c-1 ; i >= SCRAMBLE_START ; i--) {
|
||||
j = SCRAMBLE_START + ( seq[i] & mask );
|
||||
temp = buf->data[j];
|
||||
buf->data[j] = buf->data[i];
|
||||
buf->data[i] = temp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
Netchan_TransmitNextFragment
|
||||
|
@ -225,7 +139,11 @@ void Netchan_TransmitNextFragment( netchan_t *chan ) {
|
|||
MSG_WriteData( &send, chan->unsentBuffer + chan->unsentFragmentStart, fragmentLength );
|
||||
|
||||
// send the datagram
|
||||
NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );
|
||||
NET_SendPacket(chan->sock, send.cursize, send.data, chan->remoteAddress);
|
||||
|
||||
// Store send time and size of this packet for rate control
|
||||
chan->lastSentTime = Sys_Milliseconds();
|
||||
chan->lastSentSize = send.cursize;
|
||||
|
||||
if ( showpackets->integer ) {
|
||||
Com_Printf ("%s send %4i : s=%i fragment=%i,%i\n"
|
||||
|
@ -298,6 +216,10 @@ void Netchan_Transmit( netchan_t *chan, int length, const byte *data ) {
|
|||
// send the datagram
|
||||
NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );
|
||||
|
||||
// Store send time and size of this packet for rate control
|
||||
chan->lastSentTime = Sys_Milliseconds();
|
||||
chan->lastSentSize = send.cursize;
|
||||
|
||||
if ( showpackets->integer ) {
|
||||
Com_Printf( "%s send %4i : s=%i ack=%i\n"
|
||||
, netsrcString[ chan->sock ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue