summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorThilo Schulz <arny@ats.s.bawue.de>2011-07-13 17:11:30 +0000
committerTim Angus <tim@ngus.net>2013-01-10 22:27:30 +0000
commit2bf2118d79994cfd805c3ffb5b421c6a65658b84 (patch)
tree867a9c4ac0d975e7aca4ee20714de8c97646ccde /src/client
parent5038ffeb97413a867d0bdadf761e2ba727781742 (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/client')
-rw-r--r--src/client/cl_input.c54
-rw-r--r--src/client/cl_main.c6
-rw-r--r--src/client/cl_net_chan.c32
-rw-r--r--src/client/cl_parse.c22
-rw-r--r--src/client/cl_scrn.c2
-rw-r--r--src/client/client.h3
6 files changed, 73 insertions, 46 deletions
diff --git a/src/client/cl_input.c b/src/client/cl_input.c
index f9ec9d04..736378ba 100644
--- a/src/client/cl_input.c
+++ b/src/client/cl_input.c
@@ -801,8 +801,46 @@ void CL_WritePacket( void ) {
#ifdef USE_VOIP
if (clc.voipOutgoingDataSize > 0) { // only send if data.
- MSG_WriteByte (&buf, clc_EOF); // placate legacy servers.
- MSG_WriteByte (&buf, clc_extension);
+ // Move cl_voipSendTarget from a string to the bitmasks if needed.
+ if (cl_voipSendTarget->modified) {
+ char buffer[32];
+ const char *target = cl_voipSendTarget->string;
+
+ if (Q_stricmp(target, "attacker") == 0) {
+ int player = VM_Call( cgvm, CG_LAST_ATTACKER );
+ Com_sprintf(buffer, sizeof (buffer), "%d", player);
+ target = buffer;
+ } else if (Q_stricmp(target, "crosshair") == 0) {
+ int player = VM_Call( cgvm, CG_CROSSHAIR_PLAYER );
+ Com_sprintf(buffer, sizeof (buffer), "%d", player);
+ target = buffer;
+ }
+
+ if ((*target == '\0') || (Q_stricmp(target, "all") == 0)) {
+ const int all = 0x7FFFFFFF;
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = all;
+ } else if (Q_stricmp(target, "none") == 0) {
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0;
+ } else {
+ const char *ptr = target;
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0;
+ do {
+ if ((*ptr == ',') || (*ptr == '\0')) {
+ const int val = atoi(target);
+ target = ptr + 1;
+ if ((val >= 0) && (val < 31)) {
+ clc.voipTarget1 |= (1 << (val-0));
+ } else if ((val >= 31) && (val < 62)) {
+ clc.voipTarget2 |= (1 << (val-31));
+ } else if ((val >= 62) && (val < 93)) {
+ clc.voipTarget3 |= (1 << (val-62));
+ }
+ }
+ } while (*(ptr++));
+ }
+ cl_voipSendTarget->modified = qfalse;
+ }
+
MSG_WriteByte (&buf, clc_voip);
MSG_WriteByte (&buf, clc.voipOutgoingGeneration);
MSG_WriteLong (&buf, clc.voipOutgoingSequence);
@@ -824,8 +862,6 @@ void CL_WritePacket( void ) {
MSG_Init (&fakemsg, fakedata, sizeof (fakedata));
MSG_Bitstream (&fakemsg);
MSG_WriteLong (&fakemsg, clc.reliableAcknowledge);
- MSG_WriteByte (&fakemsg, svc_EOF);
- MSG_WriteByte (&fakemsg, svc_extension);
MSG_WriteByte (&fakemsg, svc_voip);
MSG_WriteShort (&fakemsg, clc.clientNum);
MSG_WriteByte (&fakemsg, clc.voipOutgoingGeneration);
@@ -889,16 +925,6 @@ void CL_WritePacket( void ) {
}
CL_Netchan_Transmit (&clc.netchan, &buf);
-
- // clients never really should have messages large enough
- // to fragment, but in case they do, fire them all off
- // at once
- // TTimo: this causes a packet burst, which is bad karma for winsock
- // added a WARNING message, we'll see if there are legit situations where this happens
- while ( clc.netchan.unsentFragments ) {
- Com_DPrintf( "WARNING: #462 unsent fragments (not supposed to happen!)\n" );
- CL_Netchan_TransmitNextFragment( &clc.netchan );
- }
}
/*
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index 621d3cd6..1f95b7e0 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -289,7 +289,7 @@ void CL_Voip_f( void )
reason = "Not connected to a server";
else if (!clc.speexInitialized)
reason = "Speex not initialized";
- else if (!cl_connectedToVoipServer)
+ else if (!clc.voipEnabled)
reason = "Server doesn't support VoIP";
if (reason != NULL) {
@@ -383,7 +383,7 @@ void CL_CaptureVoip(void)
qboolean dontCapture = qfalse;
if (clc.state != CA_ACTIVE)
dontCapture = qtrue; // not connected to a server.
- else if (!cl_connectedToVoipServer)
+ else if (!clc.voipEnabled)
dontCapture = qtrue; // server doesn't support VoIP.
else if (clc.demoplaying)
dontCapture = qtrue; // playing back a demo.
@@ -1429,7 +1429,7 @@ void CL_Disconnect( qboolean showMainMenu ) {
#ifdef USE_VOIP
// not connected to voip server anymore.
- cl_connectedToVoipServer = qfalse;
+ clc.voipEnabled = qfalse;
#endif
// Stop recording any video
diff --git a/src/client/cl_net_chan.c b/src/client/cl_net_chan.c
index fbfc4dc9..0d057d1d 100644
--- a/src/client/cl_net_chan.c
+++ b/src/client/cl_net_chan.c
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/qcommon.h"
#include "client.h"
+#ifdef LEGACY_PROTOCOL
/*
==============
CL_Netchan_Encode
@@ -126,14 +127,22 @@ static void CL_Netchan_Decode( msg_t *msg ) {
*(msg->data + i) = *(msg->data + i) ^ key;
}
}
+#endif
/*
=================
CL_Netchan_TransmitNextFragment
=================
*/
-void CL_Netchan_TransmitNextFragment( netchan_t *chan ) {
- Netchan_TransmitNextFragment( chan );
+qboolean CL_Netchan_TransmitNextFragment(netchan_t *chan)
+{
+ if(chan->unsentFragments)
+ {
+ Netchan_TransmitNextFragment(chan);
+ return qtrue;
+ }
+
+ return qfalse;
}
/*
@@ -144,8 +153,18 @@ CL_Netchan_Transmit
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) {
MSG_WriteByte( msg, clc_EOF );
- CL_Netchan_Encode( msg );
- Netchan_Transmit( chan, msg->cursize, msg->data );
+#ifdef LEGACY_PROTOCOL
+ if(chan->compat)
+ CL_Netchan_Encode(msg);
+#endif
+
+ Netchan_Transmit(chan, msg->cursize, msg->data);
+
+ // Transmit all fragments without delay
+ while(CL_Netchan_TransmitNextFragment(chan))
+ {
+ Com_DPrintf("WARNING: #462 unsent fragments (not supposed to happen!)\n");
+ }
}
/*
@@ -160,7 +179,10 @@ qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ) {
if (!ret)
return qfalse;
- CL_Netchan_Decode( msg );
+#ifdef LEGACY_PROTOCOL
+ if(chan->compat)
+ CL_Netchan_Decode(msg);
+#endif
return qtrue;
}
diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c
index 1b0e2802..147c3156 100644
--- a/src/client/cl_parse.c
+++ b/src/client/cl_parse.c
@@ -35,7 +35,6 @@ char *svc_strings[256] = {
"svc_download",
"svc_snapshot",
"svc_EOF",
- "svc_extension",
"svc_voip",
};
@@ -331,10 +330,6 @@ void CL_ParseSnapshot( msg_t *msg ) {
int cl_connectedToPureServer;
int cl_connectedToCheatServer;
-#ifdef USE_VOIP
-int cl_connectedToVoipServer;
-#endif
-
/*
==================
CL_SystemInfoChanged
@@ -364,10 +359,8 @@ void CL_SystemInfoChanged( void ) {
}
#ifdef USE_VOIP
- // in the future, (val) will be a protocol version string, so only
- // accept explicitly 1, not generally non-zero.
s = Info_ValueForKey( systemInfo, "sv_voip" );
- cl_connectedToVoipServer = (atoi( s ) == 1);
+ clc.voipEnabled = atoi(s);
#endif
s = Info_ValueForKey( systemInfo, "sv_cheats" );
@@ -862,19 +855,6 @@ void CL_ParseServerMessage( msg_t *msg ) {
cmd = MSG_ReadByte( msg );
- // See if this is an extension command after the EOF, which means we
- // got data that a legacy client should ignore.
- if ((cmd == svc_EOF) && (MSG_LookaheadByte( msg ) == svc_extension)) {
- SHOWNET( msg, "EXTENSION" );
- MSG_ReadByte( msg ); // throw the svc_extension byte away.
- cmd = MSG_ReadByte( msg ); // something legacy clients can't do!
- // sometimes you get a svc_extension at end of stream...dangling
- // bits in the huffman decoder giving a bogus value?
- if (cmd == -1) {
- cmd = svc_EOF;
- }
- }
-
if (cmd == svc_EOF) {
SHOWNET( msg, "END OF MESSAGE" );
break;
diff --git a/src/client/cl_scrn.c b/src/client/cl_scrn.c
index c616640a..afafea25 100644
--- a/src/client/cl_scrn.c
+++ b/src/client/cl_scrn.c
@@ -343,7 +343,7 @@ void SCR_DrawVoipMeter( void ) {
return; // not recording at the moment.
else if (clc.state != CA_ACTIVE)
return; // not connected to a server.
- else if (!cl_connectedToVoipServer)
+ else if (!clc.voipEnabled)
return; // server doesn't support VoIP.
else if (clc.demoplaying)
return; // playing back a demo.
diff --git a/src/client/client.h b/src/client/client.h
index 3e243df2..3db4e27f 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -237,6 +237,7 @@ typedef struct {
unsigned char timeDemoDurations[ MAX_TIMEDEMO_DURATIONS ]; // log of frame durations
#ifdef USE_VOIP
+ qboolean voipEnabled;
qboolean speexInitialized;
int speexFrameSize;
int speexSampleRate;
@@ -521,7 +522,6 @@ extern int cl_connectedToPureServer;
extern int cl_connectedToCheatServer;
#ifdef USE_VOIP
-extern int cl_connectedToVoipServer;
void CL_Voip_f( void );
#endif
@@ -627,7 +627,6 @@ void LAN_SaveServersToCache( void );
// cl_net_chan.c
//
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg); //int length, const byte *data );
-void CL_Netchan_TransmitNextFragment( netchan_t *chan );
qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg );
//