mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 06:41:58 +00:00
* 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
This commit is contained in:
parent
809c361744
commit
37d664d4b2
24 changed files with 239 additions and 110 deletions
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,7 +528,7 @@ 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
|
||||
break;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -473,10 +473,12 @@ qboolean Com_AddStartupCommands( void ) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// set commands won't override menu startup
|
||||
if ( Q_stricmpn( com_consoleLines[i], "set", 3 ) ) {
|
||||
added = qtrue;
|
||||
// set commands already added with Com_StartupVariable
|
||||
if ( !Q_stricmpn( com_consoleLines[i], "set", 3 ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
added = qtrue;
|
||||
Cbuf_AddText( com_consoleLines[i] );
|
||||
Cbuf_AddText( "\n" );
|
||||
}
|
||||
|
@ -2562,8 +2564,10 @@ void Com_Init( char *commandLine ) {
|
|||
// get dedicated here for proper hunk megs initialization
|
||||
#ifdef DEDICATED
|
||||
com_dedicated = Cvar_Get ("dedicated", "1", CVAR_INIT);
|
||||
Cvar_CheckRange( com_dedicated, 1, 2, qtrue );
|
||||
#else
|
||||
com_dedicated = Cvar_Get ("dedicated", "0", CVAR_LATCH);
|
||||
Cvar_CheckRange( com_dedicated, 0, 2, qtrue );
|
||||
#endif
|
||||
// allocate the stack based hunk allocator
|
||||
Com_InitHunkMemory();
|
||||
|
|
|
@ -189,6 +189,109 @@ void Cvar_CommandCompletion( void(*callback)(const char *s) ) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Validate
|
||||
============
|
||||
*/
|
||||
static const char *Cvar_Validate( cvar_t *var,
|
||||
const char *value, qboolean warn )
|
||||
{
|
||||
static char s[ MAX_CVAR_VALUE_STRING ];
|
||||
float valuef;
|
||||
qboolean changed = qfalse;
|
||||
|
||||
if( !var->validate )
|
||||
return value;
|
||||
|
||||
if( !value )
|
||||
return value;
|
||||
|
||||
if( Q_isanumber( value ) )
|
||||
{
|
||||
valuef = atof( value );
|
||||
|
||||
if( var->integral )
|
||||
{
|
||||
if( !Q_isintegral( valuef ) )
|
||||
{
|
||||
if( warn )
|
||||
Com_Printf( "WARNING: cvar '%s' must be integral", var->name );
|
||||
|
||||
valuef = (int)valuef;
|
||||
changed = qtrue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( warn )
|
||||
Com_Printf( "WARNING: cvar '%s' must be numeric", var->name );
|
||||
|
||||
valuef = atof( var->resetString );
|
||||
changed = qtrue;
|
||||
}
|
||||
|
||||
if( valuef < var->min )
|
||||
{
|
||||
if( warn )
|
||||
{
|
||||
if( changed )
|
||||
Com_Printf( " and is" );
|
||||
else
|
||||
Com_Printf( "WARNING: cvar '%s'", var->name );
|
||||
|
||||
if( Q_isintegral( var->min ) )
|
||||
Com_Printf( " out of range (min %d)", (int)var->min );
|
||||
else
|
||||
Com_Printf( " out of range (min %f)", var->min );
|
||||
}
|
||||
|
||||
valuef = var->min;
|
||||
changed = qtrue;
|
||||
}
|
||||
else if( valuef > var->max )
|
||||
{
|
||||
if( warn )
|
||||
{
|
||||
if( changed )
|
||||
Com_Printf( " and is" );
|
||||
else
|
||||
Com_Printf( "WARNING: cvar '%s'", var->name );
|
||||
|
||||
if( Q_isintegral( var->max ) )
|
||||
Com_Printf( " out of range (max %d)", (int)var->max );
|
||||
else
|
||||
Com_Printf( " out of range (max %f)", var->max );
|
||||
}
|
||||
|
||||
valuef = var->max;
|
||||
changed = qtrue;
|
||||
}
|
||||
|
||||
if( changed )
|
||||
{
|
||||
if( Q_isintegral( valuef ) )
|
||||
{
|
||||
Com_sprintf( s, sizeof( s ), "%d", (int)valuef );
|
||||
|
||||
if( warn )
|
||||
Com_Printf( ", setting to %d\n", (int)valuef );
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_sprintf( s, sizeof( s ), "%f", valuef );
|
||||
|
||||
if( warn )
|
||||
Com_Printf( ", setting to %f\n", valuef );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
|
@ -220,6 +323,8 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
|
|||
|
||||
var = Cvar_FindVar (var_name);
|
||||
if ( var ) {
|
||||
var_value = Cvar_Validate( var, var_value, qfalse );
|
||||
|
||||
// if the C code is now specifying a variable that the user already
|
||||
// set a value for, take the new value as the reset value
|
||||
if ( ( var->flags & CVAR_USER_CREATED ) && !( flags & CVAR_USER_CREATED )
|
||||
|
@ -282,6 +387,7 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
|
|||
var->value = atof (var->string);
|
||||
var->integer = atoi(var->string);
|
||||
var->resetString = CopyString( var_value );
|
||||
var->validate = qfalse;
|
||||
|
||||
// link the variable in
|
||||
var->next = cvar_vars;
|
||||
|
@ -364,6 +470,8 @@ cvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force ) {
|
|||
value = var->resetString;
|
||||
}
|
||||
|
||||
value = Cvar_Validate( var, value, qtrue );
|
||||
|
||||
if((var->flags & CVAR_LATCH) && var->latchedString) {
|
||||
if(!strcmp(value,var->latchedString))
|
||||
return var;
|
||||
|
@ -877,6 +985,22 @@ void Cvar_InfoStringBuffer( int bit, char* buff, int buffsize ) {
|
|||
Q_strncpyz(buff,Cvar_InfoString(bit),buffsize);
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Cvar_CheckRange
|
||||
=====================
|
||||
*/
|
||||
void Cvar_CheckRange( cvar_t *var, float min, float max, qboolean integral )
|
||||
{
|
||||
var->validate = qtrue;
|
||||
var->min = min;
|
||||
var->max = max;
|
||||
var->integral = integral;
|
||||
|
||||
// Force an initial range check
|
||||
Cvar_Set( var->name, var->string );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Cvar_Register
|
||||
|
@ -899,7 +1023,7 @@ void Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultVa
|
|||
|
||||
/*
|
||||
=====================
|
||||
Cvar_Register
|
||||
Cvar_Update
|
||||
|
||||
updates an interpreted modules' version of a cvar
|
||||
=====================
|
||||
|
|
|
@ -726,6 +726,28 @@ char* Q_strrchr( const char* string, int c )
|
|||
return sp;
|
||||
}
|
||||
|
||||
qboolean Q_isanumber( const char *s )
|
||||
{
|
||||
#ifdef Q3_VM
|
||||
//FIXME: implement
|
||||
return qfalse;
|
||||
#else
|
||||
char *p;
|
||||
|
||||
if( *s == '\0' )
|
||||
return qfalse;
|
||||
|
||||
strtof( s, &p );
|
||||
|
||||
return *p == '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
qboolean Q_isintegral( float f )
|
||||
{
|
||||
return (int)f == f;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Q_strncpyz
|
||||
|
|
|
@ -678,6 +678,8 @@ int Q_isprint( int c );
|
|||
int Q_islower( int c );
|
||||
int Q_isupper( int c );
|
||||
int Q_isalpha( int c );
|
||||
qboolean Q_isanumber( const char *s );
|
||||
qboolean Q_isintegral( float f );
|
||||
|
||||
// portable case insensitive compare
|
||||
int Q_stricmp (const char *s1, const char *s2);
|
||||
|
@ -795,6 +797,10 @@ typedef struct cvar_s {
|
|||
int modificationCount; // incremented each time the cvar is changed
|
||||
float value; // atof( string )
|
||||
int integer; // atoi( string )
|
||||
qboolean validate;
|
||||
qboolean integral;
|
||||
float min;
|
||||
float max;
|
||||
struct cvar_s *next;
|
||||
struct cvar_s *hashNext;
|
||||
} cvar_t;
|
||||
|
|
|
@ -528,6 +528,7 @@ char *Cvar_InfoString_Big( int bit );
|
|||
// returns an info string containing all the cvars that have the given bit set
|
||||
// in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc )
|
||||
void Cvar_InfoStringBuffer( int bit, char *buff, int buffsize );
|
||||
void Cvar_CheckRange( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral );
|
||||
|
||||
void Cvar_Restart_f( void );
|
||||
|
||||
|
|
|
@ -159,30 +159,6 @@ int max_polys;
|
|||
cvar_t *r_maxpolyverts;
|
||||
int max_polyverts;
|
||||
|
||||
static void AssertCvarRange( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral )
|
||||
{
|
||||
if ( shouldBeIntegral )
|
||||
{
|
||||
if ( ( int ) cv->value != cv->integer )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' must be integral (%f)\n", cv->name, cv->value );
|
||||
ri.Cvar_Set( cv->name, va( "%d", cv->integer ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( cv->value < minVal )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' out of range (%f < %f)\n", cv->name, cv->value, minVal );
|
||||
ri.Cvar_Set( cv->name, va( "%f", minVal ) );
|
||||
}
|
||||
else if ( cv->value > maxVal )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' out of range (%f > %f)\n", cv->name, cv->value, maxVal );
|
||||
ri.Cvar_Set( cv->name, va( "%f", maxVal ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** InitOpenGL
|
||||
**
|
||||
|
@ -918,7 +894,7 @@ void R_Register( void )
|
|||
r_picmip = ri.Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH );
|
||||
AssertCvarRange( r_picmip, 0, 16, qtrue );
|
||||
ri.Cvar_CheckRange( r_picmip, 0, 16, qtrue );
|
||||
r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_colorbits = ri.Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
|
@ -944,7 +920,7 @@ void R_Register( void )
|
|||
// temporary latched variables that can only change over a restart
|
||||
//
|
||||
r_displayRefresh = ri.Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH );
|
||||
AssertCvarRange( r_displayRefresh, 0, 200, qtrue );
|
||||
ri.Cvar_CheckRange( r_displayRefresh, 0, 200, qtrue );
|
||||
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT );
|
||||
r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH );
|
||||
r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH );
|
||||
|
@ -957,7 +933,7 @@ void R_Register( void )
|
|||
r_lodbias = ri.Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE );
|
||||
r_flares = ri.Cvar_Get ("r_flares", "0", CVAR_ARCHIVE );
|
||||
r_znear = ri.Cvar_Get( "r_znear", "4", CVAR_CHEAT );
|
||||
AssertCvarRange( r_znear, 0.001f, 200, qtrue );
|
||||
ri.Cvar_CheckRange( r_znear, 0.001f, 200, qtrue );
|
||||
r_zproj = ri.Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE );
|
||||
r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE );
|
||||
r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE );
|
||||
|
|
|
@ -131,6 +131,7 @@ typedef struct {
|
|||
|
||||
cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags );
|
||||
void (*Cvar_Set)( const char *name, const char *value );
|
||||
void (*Cvar_CheckRange)( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral );
|
||||
|
||||
void (*Cmd_AddCommand)( const char *name, void(*cmd)(void) );
|
||||
void (*Cmd_RemoveCommand)( const char *name );
|
||||
|
|
|
@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#define MAX_ENT_CLUSTERS 16
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
typedef struct voipServerPacket_s
|
||||
{
|
||||
int generation;
|
||||
|
@ -179,7 +179,7 @@ typedef struct client_s {
|
|||
netchan_buffer_t *netchan_start_queue;
|
||||
netchan_buffer_t **netchan_end_queue;
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
qboolean hasVoip;
|
||||
qboolean muteAllVoip;
|
||||
qboolean ignoreVoipFromClient[MAX_CLIENTS];
|
||||
|
@ -284,7 +284,7 @@ extern cvar_t *sv_strictAuth;
|
|||
extern serverBan_t serverBans[SERVER_MAXBANS];
|
||||
extern int serverBansCount;
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
extern cvar_t *sv_voip;
|
||||
#endif
|
||||
|
||||
|
@ -345,7 +345,7 @@ void SV_ClientThink (client_t *cl, usercmd_t *cmd);
|
|||
|
||||
void SV_WriteDownloadToClient( client_t *cl , msg_t *msg );
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
void SV_WriteVoipToClient( client_t *cl, msg_t *msg );
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1083,7 +1083,7 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
|
|||
}
|
||||
}
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
/*
|
||||
==================
|
||||
SV_WriteVoipToClient
|
||||
|
@ -1378,10 +1378,10 @@ void SV_UserinfoChanged( client_t *cl ) {
|
|||
cl->snapshotMsec = 50;
|
||||
}
|
||||
|
||||
#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.
|
||||
val = Info_ValueForKey (cl->userinfo, "voip");
|
||||
val = Info_ValueForKey (cl->userinfo, "cl_voip");
|
||||
cl->hasVoip = (atoi(val) == 1) ? qtrue : qfalse;
|
||||
#endif
|
||||
|
||||
|
@ -1421,7 +1421,7 @@ static void SV_UpdateUserinfo_f( client_t *cl ) {
|
|||
}
|
||||
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
static
|
||||
void SV_UpdateVoipIgnore(client_t *cl, const char *idstr, qboolean ignore)
|
||||
{
|
||||
|
@ -1468,7 +1468,7 @@ static ucmd_t ucmds[] = {
|
|||
{"stopdl", SV_StopDownload_f},
|
||||
{"donedl", SV_DoneDownload_f},
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
{"voip", SV_Voip_f},
|
||||
#endif
|
||||
|
||||
|
@ -1692,7 +1692,7 @@ static void SV_UserMove( client_t *cl, msg_t *msg, qboolean delta ) {
|
|||
}
|
||||
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
static
|
||||
qboolean SV_ShouldIgnoreVoipSender(const client_t *cl)
|
||||
{
|
||||
|
@ -1922,7 +1922,7 @@ void SV_ExecuteClientMessage( client_t *cl, msg_t *msg ) {
|
|||
} else if ( c == clc_moveNoDelta ) {
|
||||
SV_UserMove( cl, msg, qfalse );
|
||||
} else if ( c == clc_voip ) {
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
SV_UserVoip( cl, msg );
|
||||
#endif
|
||||
} else if ( c != clc_EOF ) {
|
||||
|
|
|
@ -654,12 +654,9 @@ void SV_Init (void) {
|
|||
Cvar_Get ("sv_cheats", "1", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
sv_serverid = Cvar_Get ("sv_serverid", "0", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
sv_pure = Cvar_Get ("sv_pure", "1", CVAR_SYSTEMINFO );
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
sv_voip = Cvar_Get ("sv_voip", "1", CVAR_SYSTEMINFO | CVAR_LATCH);
|
||||
if ( (sv_voip->integer < 0) || (sv_voip->integer > 1) ) {
|
||||
Com_Printf("WARNING: sv_voip must be 0 or 1. Setting to 1.");
|
||||
Cvar_Set ("sv_voip", "1");
|
||||
}
|
||||
Cvar_CheckRange( sv_voip, 0, 1, qtrue );
|
||||
#endif
|
||||
Cvar_Get ("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
Cvar_Get ("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "server.h"
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
cvar_t *sv_voip;
|
||||
#endif
|
||||
|
||||
|
@ -411,9 +411,9 @@ void SVC_Info( netadr_t from ) {
|
|||
Info_SetValueForKey( infostring, "gametype", va("%i", sv_gametype->integer ) );
|
||||
Info_SetValueForKey( infostring, "pure", va("%i", sv_pure->integer ) );
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
if (sv_voip->integer) {
|
||||
Info_SetValueForKey( infostring, "voip", va("%i", sv_voip->integer ) );
|
||||
Info_SetValueForKey( infostring, "cl_voip", va("%i", sv_voip->integer ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -653,7 +653,7 @@ void SV_SendClientSnapshot( client_t *client ) {
|
|||
// Add any download data if the client is downloading
|
||||
SV_WriteDownloadToClient( client, &msg );
|
||||
|
||||
#if USE_VOIP
|
||||
#ifdef USE_VOIP
|
||||
SV_WriteVoipToClient( client, &msg );
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ sv_voip: set to "1" (the default) to enable server-side VoIP support. Set to
|
|||
"0" to disable. Without this, all VoIP packets are refused by the
|
||||
server, which means no one gets to use in-game VoIP.
|
||||
|
||||
voip: set to "1" (the default) to enable client-side VoIP support. Set to "0"
|
||||
cl_voip: set to "1" (the default) to enable client-side VoIP support. Set to "0"
|
||||
to disable. Without this, you will neither be able to transmit voice nor
|
||||
hear other people.
|
||||
|
||||
|
|
Loading…
Reference in a new issue