From 80e25417be92abff3053a4d8f209349a16e6d334 Mon Sep 17 00:00:00 2001 From: tma Date: Mon, 7 Jul 2008 22:31:39 +0000 Subject: * Rename voip cvar to cl_voip * s/#if USE_VOIP/#ifdef USE_VOIP/ * Add generalised runtime cvar range checking, currently on [sv|cl]_voip, dedicated and a bunch of r_ variables git-svn-id: svn://svn.icculus.org/quake3/trunk@1420 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/client/cl_cgame.c | 2 +- code/client/cl_input.c | 10 +++++----- code/client/cl_main.c | 36 +++++++++++++++++------------------- code/client/cl_parse.c | 10 +++++----- code/client/cl_scrn.c | 6 +++--- code/client/client.h | 12 ++++++------ code/client/snd_dma.c | 4 ++-- code/client/snd_local.h | 2 +- code/client/snd_main.c | 4 ++-- code/client/snd_openal.c | 10 +++++----- code/client/snd_public.h | 2 +- 11 files changed, 48 insertions(+), 50 deletions(-) (limited to 'code/client') diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c index 12c1171..615884f 100644 --- a/code/client/cl_cgame.c +++ b/code/client/cl_cgame.c @@ -917,7 +917,7 @@ void CL_FirstSnapshot( void ) { } #endif -#if USE_VOIP +#ifdef USE_VOIP if (!clc.speexInitialized) { int i; speex_bits_init(&clc.speexEncoderBits); diff --git a/code/client/cl_input.c b/code/client/cl_input.c index a17a662..077d689 100644 --- a/code/client/cl_input.c +++ b/code/client/cl_input.c @@ -52,7 +52,7 @@ kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright; kbutton_t in_strafe, in_speed; kbutton_t in_up, in_down; -#if USE_VOIP +#ifdef USE_VOIP kbutton_t in_voiprecord; #endif @@ -220,7 +220,7 @@ void IN_SpeedUp(void) {IN_KeyUp(&in_speed);} void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);} void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);} -#if USE_VOIP +#ifdef USE_VOIP void IN_VoipRecordDown(void) { IN_KeyDown(&in_voiprecord); @@ -759,7 +759,7 @@ void CL_WritePacket( void ) { Com_Printf("MAX_PACKET_USERCMDS\n"); } - #if USE_VOIP +#ifdef USE_VOIP if (clc.voipOutgoingDataSize > 0) { // only send if data. // Move cl_voipSendTarget from a string to the bitmasks if needed. if (cl_voipSendTarget->modified) { @@ -841,7 +841,7 @@ void CL_WritePacket( void ) { clc.voipOutgoingDataSize = 0; clc.voipOutgoingDataFrames = 0; } else - #endif +#endif if ( count >= 1 ) { if ( cl_showSend->integer ) { @@ -1000,7 +1000,7 @@ void CL_InitInput( void ) { Cmd_AddCommand ("+mlook", IN_MLookDown); Cmd_AddCommand ("-mlook", IN_MLookUp); -#if USE_VOIP +#ifdef USE_VOIP Cmd_AddCommand ("+voiprecord", IN_VoipRecordDown); Cmd_AddCommand ("-voiprecord", IN_VoipRecordUp); #endif diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 2d3a2d4..b54efc1 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -33,7 +33,7 @@ cvar_t *cl_useMumble; cvar_t *cl_mumbleScale; #endif -#if USE_VOIP +#ifdef USE_VOIP cvar_t *cl_voipUseVAD; cvar_t *cl_voipVADThreshold; cvar_t *cl_voipSend; @@ -41,7 +41,7 @@ cvar_t *cl_voipSendTarget; cvar_t *cl_voipGainDuringCapture; cvar_t *cl_voipCaptureMult; cvar_t *cl_voipShowMeter; -cvar_t *voip; +cvar_t *cl_voip; #endif cvar_t *cl_nodelta; @@ -179,7 +179,7 @@ void CL_UpdateMumble(void) #endif -#if USE_VOIP +#ifdef USE_VOIP static void CL_UpdateVoipIgnore(const char *idstr, qboolean ignore) { @@ -304,7 +304,7 @@ void CL_CaptureVoip(void) dontCapture = qtrue; // single player game. else if (clc.demoplaying) dontCapture = qtrue; // playing back a demo. - else if ( voip->integer == 0 ) + else if ( cl_voip->integer == 0 ) dontCapture = qtrue; // client has VoIP support disabled. else if ( audioMult == 0.0f ) dontCapture = qtrue; // basically silenced incoming audio. @@ -1162,7 +1162,7 @@ void CL_Disconnect( qboolean showMainMenu ) { } #endif -#if USE_VOIP +#ifdef USE_VOIP if (cl_voipSend->integer) { int tmp = cl_voipUseVAD->integer; cl_voipUseVAD->integer = 0; // disable this for a moment. @@ -1219,7 +1219,7 @@ void CL_Disconnect( qboolean showMainMenu ) { // not connected to a pure server anymore cl_connectedToPureServer = qfalse; -#if USE_VOIP +#ifdef USE_VOIP // not connected to voip server anymore. cl_connectedToVoipServer = qfalse; #endif @@ -2640,7 +2640,7 @@ void CL_Frame ( int msec ) { // update audio S_Update(); -#if USE_VOIP +#ifdef USE_VOIP CL_CaptureVoip(); #endif @@ -2812,6 +2812,7 @@ void CL_InitRef( void ) { ri.FS_FileExists = FS_FileExists; ri.Cvar_Get = Cvar_Get; ri.Cvar_Set = Cvar_Set; + ri.Cvar_CheckRange = Cvar_CheckRange; // cinematic stuff @@ -2978,7 +2979,7 @@ CL_Init void CL_Init( void ) { Com_Printf( "----- Client Initialization -----\n" ); - Con_Init (); + Con_Init (); CL_ClearState (); @@ -3035,7 +3036,7 @@ void CL_Init( void ) { cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0); #ifdef MACOS_X - // In game video is REALLY slow in Mac OS X right now due to driver slowness + // In game video is REALLY slow in Mac OS X right now due to driver slowness cl_inGameVideo = Cvar_Get ("r_inGameVideo", "0", CVAR_ARCHIVE); #else cl_inGameVideo = Cvar_Get ("r_inGameVideo", "1", CVAR_ARCHIVE); @@ -3052,7 +3053,7 @@ void CL_Init( void ) { m_forward = Cvar_Get ("m_forward", "0.25", CVAR_ARCHIVE); m_side = Cvar_Get ("m_side", "0.25", CVAR_ARCHIVE); #ifdef MACOS_X - // Input is jittery on OS X w/o this + // Input is jittery on OS X w/o this m_filter = Cvar_Get ("m_filter", "1", CVAR_ARCHIVE); #else m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE); @@ -3091,7 +3092,7 @@ void CL_Init( void ) { cl_mumbleScale = Cvar_Get ("cl_mumbleScale", "0.0254", CVAR_ARCHIVE); #endif -#if USE_VOIP +#ifdef USE_VOIP cl_voipSend = Cvar_Get ("cl_voipSend", "0", 0); cl_voipSendTarget = Cvar_Get ("cl_voipSendTarget", "all", 0); cl_voipGainDuringCapture = Cvar_Get ("cl_voipGainDuringCapture", "0.2", CVAR_ARCHIVE); @@ -3099,24 +3100,21 @@ void CL_Init( void ) { cl_voipUseVAD = Cvar_Get ("cl_voipUseVAD", "0", CVAR_ARCHIVE); cl_voipVADThreshold = Cvar_Get ("cl_voipVADThreshold", "0.25", CVAR_ARCHIVE); cl_voipShowMeter = Cvar_Get ("cl_voipShowMeter", "1", CVAR_ARCHIVE); - voip = Cvar_Get ("voip", "1", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_LATCH); // This is a protocol version number. - if ( (voip->integer < 0) || (voip->integer > 1) ) { - Com_Printf("WARNING: voip cvar must be 0 or 1. Setting to 1."); - Cvar_Set ("voip", "1"); - } + cl_voip = Cvar_Get ("cl_voip", "1", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_LATCH); + Cvar_CheckRange( cl_voip, 0, 1, qtrue ); // If your data rate is too low, you'll get Connection Interrupted warnings // when VoIP packets arrive, even if you have a broadband connection. // This might work on rates lower than 25000, but for safety's sake, we'll // just demand it. Who doesn't have at least a DSL line now, anyhow? If // you don't, you don't need VoIP. :) - if ((voip->integer) && (Cvar_VariableIntegerValue("rate") < 25000)) { + if ((cl_voip->integer) && (Cvar_VariableIntegerValue("rate") < 25000)) { Com_Printf("Your network rate is too slow for VoIP.\n"); Com_Printf("Set 'Data Rate' to 'LAN/Cable/xDSL' in 'Setup/System/Network' and restart.\n"); Com_Printf("Until then, VoIP is disabled.\n"); - Cvar_Set("voip", "0"); + Cvar_Set("cl_voip", "0"); } #endif @@ -3161,7 +3159,7 @@ void CL_Init( void ) { Cvar_Set( "cl_running", "1" ); - CL_GenerateQKey(); + CL_GenerateQKey(); Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM ); CL_UpdateGUID( NULL, 0 ); diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index 2219529..3c4b4fb 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -330,7 +330,7 @@ void CL_ParseSnapshot( msg_t *msg ) { int cl_connectedToPureServer; int cl_connectedToCheatServer; -#if USE_VOIP +#ifdef USE_VOIP int cl_connectedToVoipServer; #endif @@ -362,7 +362,7 @@ void CL_SystemInfoChanged( void ) { return; } -#if USE_VOIP +#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" ); @@ -635,11 +635,11 @@ void CL_ParseDownload ( msg_t *msg ) { } } -#if USE_VOIP +#ifdef USE_VOIP static qboolean CL_ShouldIgnoreVoipSender(int sender) { - if (!voip->integer) + if (!cl_voip->integer) return qtrue; // VoIP is disabled. else if ((sender == clc.clientNum) && (!clc.demoplaying)) return qtrue; // ignore own voice (unless playing back a demo). @@ -900,7 +900,7 @@ void CL_ParseServerMessage( msg_t *msg ) { CL_ParseDownload( msg ); break; case svc_voip: -#if USE_VOIP +#ifdef USE_VOIP CL_ParseVoip( msg ); #endif break; diff --git a/code/client/cl_scrn.c b/code/client/cl_scrn.c index 31b3df4..ecf47a5 100644 --- a/code/client/cl_scrn.c +++ b/code/client/cl_scrn.c @@ -365,7 +365,7 @@ void SCR_DrawVoipMeter( void ) { return; // single player game. else if (clc.demoplaying) return; // playing back a demo. - else if (!voip->integer) + else if (!cl_voip->integer) return; // client has VoIP support disabled. limit = (int) (clc.voipPower * 10.0f); @@ -528,9 +528,9 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) { // always supply STEREO_CENTER as vieworg offset is now done by the engine. CL_CGameRendering(stereoFrame); SCR_DrawDemoRecording(); - #if USE_VOIP +#ifdef USE_VOIP SCR_DrawVoipMeter(); - #endif +#endif break; } } diff --git a/code/client/client.h b/code/client/client.h index 42d4b0a..b380999 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_curl.h" #endif /* USE_CURL */ -#if USE_VOIP +#ifdef USE_VOIP #include "speex/speex.h" #include "speex/speex_preprocess.h" #endif @@ -230,7 +230,7 @@ typedef struct { int timeDemoMaxDuration; // maximum frame duration unsigned char timeDemoDurations[ MAX_TIMEDEMO_DURATIONS ]; // log of frame durations -#if USE_VOIP +#ifdef USE_VOIP qboolean speexInitialized; int speexFrameSize; int speexSampleRate; @@ -407,7 +407,7 @@ extern cvar_t *cl_useMumble; extern cvar_t *cl_mumbleScale; #endif -#if USE_VOIP +#ifdef USE_VOIP // cl_voipSendTarget is a string: "all" to broadcast to everyone, "none" to // send to no one, or a comma-separated list of client numbers: // "0,7,2,23" ... an empty string is treated like "all". @@ -418,7 +418,7 @@ extern cvar_t *cl_voipSendTarget; extern cvar_t *cl_voipGainDuringCapture; extern cvar_t *cl_voipCaptureMult; extern cvar_t *cl_voipShowMeter; -extern cvar_t *voip; +extern cvar_t *cl_voip; #endif //================================================= @@ -475,7 +475,7 @@ extern kbutton_t in_mlook, in_klook; extern kbutton_t in_strafe; extern kbutton_t in_speed; -#if USE_VOIP +#ifdef USE_VOIP extern kbutton_t in_voiprecord; #endif @@ -500,7 +500,7 @@ void Key_SetCatcher( int catcher ); extern int cl_connectedToPureServer; extern int cl_connectedToCheatServer; -#if USE_VOIP +#ifdef USE_VOIP extern int cl_connectedToVoipServer; void CL_Voip_f( void ); #endif diff --git a/code/client/snd_dma.c b/code/client/snd_dma.c index 0848fe4..3058281 100644 --- a/code/client/snd_dma.c +++ b/code/client/snd_dma.c @@ -121,7 +121,7 @@ void S_Base_SoundInfo(void) { } -#if USE_VOIP +#ifdef USE_VOIP static void S_Base_StartCapture( void ) { @@ -1530,7 +1530,7 @@ qboolean S_Base_Init( soundInterface_t *si ) { si->SoundInfo = S_Base_SoundInfo; si->SoundList = S_Base_SoundList; -#if USE_VOIP +#ifdef USE_VOIP si->StartCapture = S_Base_StartCapture; si->AvailableCaptureSamples = S_Base_AvailableCaptureSamples; si->Capture = S_Base_Capture; diff --git a/code/client/snd_local.h b/code/client/snd_local.h index 1a8b5dc..86c7d4a 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -140,7 +140,7 @@ typedef struct void (*ClearSoundBuffer)( void ); void (*SoundInfo)( void ); void (*SoundList)( void ); -#if USE_VOIP +#ifdef USE_VOIP void (*StartCapture)( void ); int (*AvailableCaptureSamples)( void ); void (*Capture)( int samples, byte *data ); diff --git a/code/client/snd_main.c b/code/client/snd_main.c index 3da9fd0..2f48117 100644 --- a/code/client/snd_main.c +++ b/code/client/snd_main.c @@ -62,7 +62,7 @@ static qboolean S_ValidSoundInterface( soundInterface_t *si ) if( !si->SoundInfo ) return qfalse; if( !si->SoundList ) return qfalse; -#if USE_VOIP +#ifdef USE_VOIP if( !si->StartCapture ) return qfalse; if( !si->AvailableCaptureSamples ) return qfalse; if( !si->Capture ) return qfalse; @@ -313,7 +313,7 @@ void S_SoundList( void ) } -#if USE_VOIP +#ifdef USE_VOIP /* ================= S_StartCapture diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index 1cb48b8..6147131 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -1696,7 +1696,7 @@ void S_AL_MusicUpdate( void ) static ALCdevice *alDevice; static ALCcontext *alContext; -#if USE_VOIP +#ifdef USE_VOIP static ALCdevice *alCaptureDevice; static cvar_t *s_alCapture; #endif @@ -1844,7 +1844,7 @@ void S_AL_SoundList( void ) { } -#if USE_VOIP +#ifdef USE_VOIP static void S_AL_StartCapture( void ) { @@ -1925,7 +1925,7 @@ void S_AL_Shutdown( void ) qalcDestroyContext(alContext); qalcCloseDevice(alDevice); -#if USE_VOIP +#ifdef USE_VOIP if (alCaptureDevice != NULL) { qalcCaptureStop(alCaptureDevice); qalcCaptureCloseDevice(alCaptureDevice); @@ -2067,7 +2067,7 @@ qboolean S_AL_Init( soundInterface_t *si ) qalDopplerFactor( s_alDopplerFactor->value ); qalDopplerVelocity( s_alDopplerSpeed->value ); -#if USE_VOIP +#ifdef USE_VOIP // !!! FIXME: some of these alcCaptureOpenDevice() values should be cvars. // !!! FIXME: add support for capture device enumeration. // !!! FIXME: add some better error reporting. @@ -2122,7 +2122,7 @@ qboolean S_AL_Init( soundInterface_t *si ) si->SoundInfo = S_AL_SoundInfo; si->SoundList = S_AL_SoundList; -#if USE_VOIP +#ifdef USE_VOIP si->StartCapture = S_AL_StartCapture; si->AvailableCaptureSamples = S_AL_AvailableCaptureSamples; si->Capture = S_AL_Capture; diff --git a/code/client/snd_public.h b/code/client/snd_public.h index e1c2309..1587f33 100644 --- a/code/client/snd_public.h +++ b/code/client/snd_public.h @@ -72,7 +72,7 @@ void SNDDMA_Activate( void ); void S_UpdateBackgroundTrack( void ); -#if USE_VOIP +#ifdef USE_VOIP void S_StartCapture( void ); int S_AvailableCaptureSamples( void ); void S_Capture( int samples, byte *data ); -- cgit v1.2.3