summaryrefslogtreecommitdiff
path: root/src/client/cl_main.c
diff options
context:
space:
mode:
authorBen Millwood <thebenmachine@gmail.com>2009-10-07 18:15:07 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:42 +0000
commita4d08a353df06cfc5e638369ed639e4aedf54ad0 (patch)
tree3226bf0033cbf5ab37acb19445b5e20b496443ec /src/client/cl_main.c
parentd68a029e908b1989a3af7788e04009368da9f85d (diff)
* Parse "team" in cl_voipSendTarget using a new cgame vmcall
Diffstat (limited to 'src/client/cl_main.c')
-rw-r--r--src/client/cl_main.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index a891e5a3..738347ea 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -214,6 +214,58 @@ void CL_UpdateVoipGain(const char *idstr, float gain)
}
}
+/*
+================
+CL_VoipParseTargets
+
+Sets clc.voipTarget{1,2,3} by asking the cgame to produce a string and then
+parsing it as a series of client numbers
+Perhaps it would be better to allow the cgame to set the three integers
+directly, but this way we can change the net protocol without changing the
+vmcall
+================
+*/
+static void CL_VoipParseTargets( void )
+{
+ const char *target = cl_voipSendTarget->string;
+ intptr_t p = VM_Call( cgvm, CG_VOIP_STRING );
+
+ if( p )
+ target = VM_ExplicitArgPtr( cgvm, p );
+
+ if( !target[ 0 ] || Q_stricmp( target, "all" ) == 0 )
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0x7FFFFFFF;
+ else if( Q_stricmp( target, "none" ) == 0 )
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0;
+ else
+ {
+ char *end;
+ int val;
+ clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0;
+
+ while( 1 )
+ {
+ while( *target && !isdigit( *target ) )
+ target++;
+ if( !*target )
+ break;
+
+ val = strtol( target, &end, 10 );
+ assert( target != end );
+ if( val < 0 || val >= MAX_CLIENTS )
+ Com_Printf( S_COLOR_YELLOW "WARNING: VoIP target %d is not a valid "
+ "client number\n", val );
+ else if( val < 31 )
+ clc.voipTarget1 |= 1 << val;
+ else if( ( val -= 31 ) < 31 )
+ clc.voipTarget2 |= 1 << val;
+ else if( ( val -= 31 ) < 31 )
+ clc.voipTarget3 |= 1 << val;
+ target = end;
+ }
+ }
+}
+
void CL_Voip_f( void )
{
const char *cmd = Cmd_Argv(1);
@@ -348,6 +400,7 @@ void CL_CaptureVoip(void)
S_MasterGain(cl_voipGainDuringCapture->value);
S_StartCapture();
CL_VoipNewGeneration();
+ CL_VoipParseTargets();
}
if ((cl_voipSend->integer) || (finalFrame)) { // user wants to capture audio?