diff options
author | Thilo Schulz <arny@ats.s.bawue.de> | 2011-07-13 17:11:30 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-10 22:27:30 +0000 |
commit | 2bf2118d79994cfd805c3ffb5b421c6a65658b84 (patch) | |
tree | 867a9c4ac0d975e7aca4ee20714de8c97646ccde /src/qcommon/net_chan.c | |
parent | 5038ffeb97413a867d0bdadf761e2ba727781742 (diff) |
- 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
Diffstat (limited to 'src/qcommon/net_chan.c')
-rw-r--r-- | src/qcommon/net_chan.c | 96 |
1 files changed, 9 insertions, 87 deletions
diff --git a/src/qcommon/net_chan.c b/src/qcommon/net_chan.c index d9c6760b..8f2d8de7 100644 --- a/src/qcommon/net_chan.c +++ b/src/qcommon/net_chan.c @@ -96,92 +96,6 @@ void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int chan->challenge = challenge; } -// 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 @@ -219,7 +133,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" @@ -289,6 +207,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 ] |