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/server/sv_main.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/server/sv_main.c')
-rw-r--r-- | src/server/sv_main.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/server/sv_main.c b/src/server/sv_main.c index f746c180..166e2241 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -1139,5 +1139,52 @@ void SV_Frame( int msec ) { SV_MasterHeartbeat(sv_heartbeat->string); } -//============================================================================ +/* +==================== +SV_RateMsec + +Return the number of msec until another message can be sent to +a client based on its rate settings +==================== +*/ + +#define UDPIP_HEADER_SIZE 28 +#define UDPIP6_HEADER_SIZE 48 +int SV_RateMsec(client_t *client) +{ + int rate, rateMsec; + int messageSize; + + messageSize = client->netchan.lastSentSize; + rate = client->rate; + + if(sv_maxRate->integer) + { + if(sv_maxRate->integer < 1000) + Cvar_Set( "sv_MaxRate", "1000" ); + if(sv_maxRate->integer < rate) + 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(client->netchan.remoteAddress.type == NA_IP6) + messageSize += UDPIP6_HEADER_SIZE; + else + messageSize += UDPIP_HEADER_SIZE; + + rateMsec = messageSize * 1000 / ((int) (rate * com_timescale->value)); + rate = Sys_Milliseconds() - client->netchan.lastSentTime; + + if(rate > rateMsec) + return 0; + else + return rateMsec - rate; +} |