summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/cl_input.c96
-rw-r--r--src/client/cl_main.c43
-rw-r--r--src/client/client.h2
-rw-r--r--src/client/snd_dma.c13
-rw-r--r--src/client/snd_local.h1
-rw-r--r--src/client/snd_main.c41
-rw-r--r--src/client/snd_mix.c5
-rw-r--r--src/client/snd_openal.c47
8 files changed, 192 insertions, 56 deletions
diff --git a/src/client/cl_input.c b/src/client/cl_input.c
index 49551662..19bdb95a 100644
--- a/src/client/cl_input.c
+++ b/src/client/cl_input.c
@@ -436,52 +436,88 @@ void CL_JoystickMove( usercmd_t *cmd ) {
CL_MouseMove
=================
*/
-void CL_MouseMove( usercmd_t *cmd ) {
- float mx, my;
- float accelSensitivity;
- float rate;
+
+void CL_MouseMove(usercmd_t *cmd)
+{
+ float mx, my;
// allow mouse smoothing
- if ( m_filter->integer ) {
- mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
- my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
- } else {
+ if (m_filter->integer)
+ {
+ mx = (cl.mouseDx[0] + cl.mouseDx[1]) * 0.5f;
+ my = (cl.mouseDy[0] + cl.mouseDy[1]) * 0.5f;
+ }
+ else
+ {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
+
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
- rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
- accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
-
- // scale by FOV
- accelSensitivity *= cl.cgameSensitivity;
-
- if ( rate && cl_showMouseRate->integer ) {
- Com_Printf( "%f : %f\n", rate, accelSensitivity );
- }
-
- mx *= accelSensitivity;
- my *= accelSensitivity;
-
- if (!mx && !my) {
+ if (mx == 0.0f && my == 0.0f)
return;
+
+ if (cl_mouseAccel->value != 0.0f)
+ {
+ if(cl_mouseAccelStyle->integer == 0)
+ {
+ float accelSensitivity;
+ float rate;
+
+ rate = sqrt(mx * mx + my * my) / (float) frame_msec;
+
+ accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
+ mx *= accelSensitivity;
+ my *= accelSensitivity;
+
+ if(cl_showMouseRate->integer)
+ Com_Printf("rate: %f, accelSensitivity: %f\n", rate, accelSensitivity);
+ }
+ else
+ {
+ float rate[2];
+ float power[2];
+
+ // sensitivity remains pretty much unchanged at low speeds
+ // cl_mouseAccel is a power value to how the acceleration is shaped
+ // cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplification
+ // NOTE: decouple the config cvars for independent acceleration setup along X and Y?
+
+ rate[0] = fabs(mx) / (float) frame_msec;
+ rate[1] = fabs(my) / (float) frame_msec;
+ power[0] = powf(rate[0] / cl_mouseAccelOffset->value, cl_mouseAccel->value);
+ power[1] = powf(rate[1] / cl_mouseAccelOffset->value, cl_mouseAccel->value);
+
+ mx = cl_sensitivity->value * (mx + ((mx < 0) ? -power[0] : power[0]) * cl_mouseAccelOffset->value);
+ my = cl_sensitivity->value * (my + ((my < 0) ? -power[1] : power[1]) * cl_mouseAccelOffset->value);
+
+ if(cl_showMouseRate->integer)
+ Com_Printf("ratex: %f, ratey: %f, powx: %f, powy: %f\n", rate[0], rate[1], power[0], power[1]);
+ }
}
+ else
+ {
+ mx *= cl_sensitivity->value;
+ my *= cl_sensitivity->value;
+ }
+
+ // ingame FOV
+ mx *= cl.cgameSensitivity;
+ my *= cl.cgameSensitivity;
// add mouse X/Y movement to cmd
- if ( in_strafe.active ) {
- cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
- } else {
+ if(in_strafe.active)
+ cmd->rightmove = ClampChar(cmd->rightmove + m_side->value * mx);
+ else
cl.viewangles[YAW] -= m_yaw->value * mx;
- }
- if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
+ if ((in_mlooking || cl_freelook->integer) && !in_strafe.active)
cl.viewangles[PITCH] += m_pitch->value * my;
- } else {
- cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
- }
+ else
+ cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward->value * my);
}
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index 4c8ded12..ff86ee2f 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -74,6 +74,8 @@ cvar_t *cl_freelook;
cvar_t *cl_sensitivity;
cvar_t *cl_mouseAccel;
+cvar_t *cl_mouseAccelOffset;
+cvar_t *cl_mouseAccelStyle;
cvar_t *cl_showMouseRate;
cvar_t *m_pitch;
@@ -977,7 +979,7 @@ void CL_PlayDemo_f( void ) {
char retry[MAX_OSPATH];
if (Cmd_Argc() != 2) {
- Com_Printf ("playdemo <demoname>\n");
+ Com_Printf ("demo <demoname>\n");
return;
}
@@ -985,14 +987,17 @@ void CL_PlayDemo_f( void ) {
// 2 means don't force disconnect of local client
Cvar_Set( "sv_killserver", "2" );
- CL_Disconnect( qtrue );
-
// open the demo file
arg = Cmd_Argv(1);
+ CL_Disconnect( qtrue );
+
// check for an extension .dm_?? (?? is protocol)
ext_test = arg + strlen(arg) - 6;
- if ((strlen(arg) > 6) && (ext_test[0] == '.') && ((ext_test[1] == 'd') || (ext_test[1] == 'D')) && ((ext_test[2] == 'm') || (ext_test[2] == 'M')) && (ext_test[3] == '_'))
+ if ((strlen(arg) > 6) && (ext_test[0] == '.') &&
+ ((ext_test[1] == 'd') || (ext_test[1] == 'D')) &&
+ ((ext_test[2] == 'm') || (ext_test[2] == 'M')) &&
+ (ext_test[3] == '_'))
{
protocol = atoi(ext_test+4);
i=0;
@@ -1343,6 +1348,9 @@ void CL_Disconnect( qboolean showMainMenu ) {
CL_WritePacket();
}
+ // Remove pure paks
+ FS_PureServerSetLoadedPaks("", "");
+
CL_ClearState ();
// wipe the client connection
@@ -1752,17 +1760,29 @@ void CL_Vid_Restart_f( void ) {
/*
=================
-CL_Snd_Restart_f
+CL_Snd_Restart
Restart the sound subsystem
-The cgame and game must also be forced to restart because
-handles will be invalid
=================
*/
-void CL_Snd_Restart_f( void ) {
+void CL_Snd_Restart(void)
+{
S_Shutdown();
S_Init();
+}
+/*
+=================
+CL_Snd_Restart_f
+
+Restart the sound subsystem
+The cgame and game must also be forced to restart because
+handles will be invalid
+=================
+*/
+void CL_Snd_Restart_f(void)
+{
+ CL_Snd_Restart();
CL_Vid_Restart_f();
}
@@ -3337,6 +3357,13 @@ void CL_Init( void ) {
cl_mouseAccel = Cvar_Get ("cl_mouseAccel", "0", CVAR_ARCHIVE);
cl_freelook = Cvar_Get( "cl_freelook", "1", CVAR_ARCHIVE );
+ // 0: legacy mouse acceleration
+ // 1: new implementation
+ cl_mouseAccelStyle = Cvar_Get( "cl_mouseAccelStyle", "0", CVAR_ARCHIVE );
+ // offset for the power function (for style 1, ignored otherwise)
+ // this should be set to the max rate value
+ cl_mouseAccelOffset = Cvar_Get( "cl_mouseAccelOffset", "5", CVAR_ARCHIVE );
+
cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE);
diff --git a/src/client/client.h b/src/client/client.h
index 1e18a9ad..0dc2490e 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -387,6 +387,8 @@ extern cvar_t *cl_sensitivity;
extern cvar_t *cl_freelook;
extern cvar_t *cl_mouseAccel;
+extern cvar_t *cl_mouseAccelOffset;
+extern cvar_t *cl_mouseAccelStyle;
extern cvar_t *cl_showMouseRate;
extern cvar_t *m_pitch;
diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c
index 472af0d8..ad6193c8 100644
--- a/src/client/snd_dma.c
+++ b/src/client/snd_dma.c
@@ -34,10 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "snd_codec.h"
#include "client.h"
-void S_Play_f(void);
-void S_SoundList_f(void);
-void S_Music_f(void);
-
void S_Update_( void );
void S_Base_StopAllSounds(void);
void S_Base_StopBackgroundTrack( void );
@@ -953,7 +949,10 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
}
rawsamples = s_rawsamples[stream];
- intVolume = 256 * volume * s_volume->value;
+ if(s_muted->integer)
+ intVolume = 0;
+ else
+ intVolume = 256 * volume * s_volume->value;
if ( s_rawend[stream] < s_soundtime ) {
Com_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], s_soundtime );
@@ -1328,7 +1327,9 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
}
Com_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop );
- if ( !intro[0] ) {
+ if(!*intro)
+ {
+ S_Base_StopBackgroundTrack();
return;
}
diff --git a/src/client/snd_local.h b/src/client/snd_local.h
index a926e7f9..24ddc54d 100644
--- a/src/client/snd_local.h
+++ b/src/client/snd_local.h
@@ -195,6 +195,7 @@ extern int s_rawend[MAX_RAW_STREAMS];
extern cvar_t *s_volume;
extern cvar_t *s_musicVolume;
+extern cvar_t *s_muted;
extern cvar_t *s_doppler;
extern cvar_t *s_testsound;
diff --git a/src/client/snd_main.c b/src/client/snd_main.c
index c386cd75..66c3f9e7 100644
--- a/src/client/snd_main.c
+++ b/src/client/snd_main.c
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "snd_public.h"
cvar_t *s_volume;
+cvar_t *s_muted;
cvar_t *s_musicVolume;
cvar_t *s_doppler;
cvar_t *s_backend;
@@ -231,12 +232,25 @@ S_Update
*/
void S_Update( void )
{
- if( ( s_muteWhenMinimized->integer && com_minimized->integer ) ||
- ( s_muteWhenUnfocused->integer && com_unfocused->integer ) ) {
- S_StopAllSounds( );
- return;
+ if(s_muted->integer)
+ {
+ if(!(s_muteWhenMinimized->integer && com_minimized->integer) &&
+ !(s_muteWhenUnfocused->integer && com_unfocused->integer))
+ {
+ s_muted->integer = qfalse;
+ s_muted->modified = qtrue;
+ }
}
-
+ else
+ {
+ if((s_muteWhenMinimized->integer && com_minimized->integer) ||
+ (s_muteWhenUnfocused->integer && com_unfocused->integer))
+ {
+ s_muted->integer = qtrue;
+ s_muted->modified = qtrue;
+ }
+ }
+
if( si.Update ) {
si.Update( );
}
@@ -449,6 +463,20 @@ void S_Music_f( void ) {
}
+/*
+=================
+S_Music_f
+=================
+*/
+void S_StopMusic_f( void )
+{
+ if(!si.StopBackgroundTrack)
+ return;
+
+ si.StopBackgroundTrack();
+}
+
+
//=============================================================================
/*
@@ -465,6 +493,7 @@ void S_Init( void )
s_volume = Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE );
+ s_muted = Cvar_Get("s_muted", "0", CVAR_ROM);
s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE );
s_backend = Cvar_Get( "s_backend", "", CVAR_ROM );
s_muteWhenMinimized = Cvar_Get( "s_muteWhenMinimized", "0", CVAR_ARCHIVE );
@@ -479,6 +508,7 @@ void S_Init( void )
Cmd_AddCommand( "play", S_Play_f );
Cmd_AddCommand( "music", S_Music_f );
+ Cmd_AddCommand( "stopmusic", S_StopMusic_f );
Cmd_AddCommand( "s_list", S_SoundList );
Cmd_AddCommand( "s_stop", S_StopAllSounds );
Cmd_AddCommand( "s_info", S_SoundInfo );
@@ -525,6 +555,7 @@ void S_Shutdown( void )
Cmd_RemoveCommand( "play" );
Cmd_RemoveCommand( "music");
+ Cmd_RemoveCommand( "stopmusic");
Cmd_RemoveCommand( "s_list" );
Cmd_RemoveCommand( "s_stop" );
Cmd_RemoveCommand( "s_info" );
diff --git a/src/client/snd_mix.c b/src/client/snd_mix.c
index fa2a841d..a9d4c794 100644
--- a/src/client/snd_mix.c
+++ b/src/client/snd_mix.c
@@ -638,7 +638,10 @@ void S_PaintChannels( int endtime ) {
int ltime, count;
int sampleOffset;
- snd_vol = s_volume->value*255;
+ if(s_muted->integer)
+ snd_vol = 0;
+ else
+ snd_vol = s_volume->value*255;
//Com_Printf ("%i to %i\n", s_paintedtime, endtime);
while ( s_paintedtime < endtime ) {
diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c
index 96068075..12df259c 100644
--- a/src/client/snd_openal.c
+++ b/src/client/snd_openal.c
@@ -581,6 +581,21 @@ static void _S_AL_SanitiseVector( vec3_t v, int line )
/*
=================
+S_AL_Gain
+Set gain to 0 if muted, otherwise set it to given value.
+=================
+*/
+
+static void S_AL_Gain(ALuint source, float gainval)
+{
+ if(s_muted->integer)
+ qalSourcef(source, AL_GAIN, 0.0f);
+ else
+ qalSourcef(source, AL_GAIN, gainval);
+}
+
+/*
+=================
S_AL_ScaleGain
Adapt the gain if necessary to get a quicker fadeout when the source is too far away.
=================
@@ -609,13 +624,13 @@ static void S_AL_ScaleGain(src_t *chksrc, vec3_t origin)
if(chksrc->scaleGain != scaleFactor);
{
chksrc->scaleGain = scaleFactor;
- qalSourcef(chksrc->alSource, AL_GAIN, chksrc->scaleGain);
+ S_AL_Gain(chksrc->alSource, chksrc->scaleGain);
}
}
else if(chksrc->scaleGain != chksrc->curGain)
{
chksrc->scaleGain = chksrc->curGain;
- qalSourcef(chksrc->alSource, AL_GAIN, chksrc->scaleGain);
+ S_AL_Gain(chksrc->alSource, chksrc->scaleGain);
}
}
@@ -757,7 +772,7 @@ static void S_AL_SrcSetup(srcHandle_t src, sfxHandle_t sfx, alSrcPriority_t prio
// Set up OpenAL source
qalSourcei(curSource->alSource, AL_BUFFER, buffer);
qalSourcef(curSource->alSource, AL_PITCH, 1.0f);
- qalSourcef(curSource->alSource, AL_GAIN, curSource->curGain);
+ S_AL_Gain(curSource->alSource, curSource->curGain);
qalSourcefv(curSource->alSource, AL_POSITION, vec3_origin);
qalSourcefv(curSource->alSource, AL_VELOCITY, vec3_origin);
qalSourcei(curSource->alSource, AL_LOOPING, AL_FALSE);
@@ -1615,6 +1630,10 @@ static void S_AL_AllocateStreamChannel( int stream )
S_AL_SrcLock(streamSourceHandles[stream]);
streamSources[stream] = S_AL_SrcGet(streamSourceHandles[stream]);
+ // make sure that after unmuting the S_AL_Gain in S_Update() does not turn
+ // volume up prematurely for this source
+ srcList[streamSourceHandles[stream]].scaleGain = 0.0f;
+
// Set some streamSource parameters
qalSourcei (streamSources[stream], AL_BUFFER, 0 );
qalSourcei (streamSources[stream], AL_LOOPING, AL_FALSE );
@@ -1678,7 +1697,7 @@ void S_AL_RawSamples(int stream, int samples, int rate, int width, int channels,
qalSourceQueueBuffers(streamSources[stream], 1, &buffer);
// Volume
- qalSourcef (streamSources[stream], AL_GAIN, volume * s_volume->value * s_alGain->value);
+ S_AL_Gain (streamSources[stream], volume * s_volume->value * s_alGain->value);
}
/*
@@ -1792,6 +1811,10 @@ static void S_AL_MusicSourceGet( void )
S_AL_SrcLock(musicSourceHandle);
musicSource = S_AL_SrcGet(musicSourceHandle);
+ // make sure that after unmuting the S_AL_Gain in S_Update() does not turn
+ // volume up prematurely for this source
+ srcList[musicSourceHandle].scaleGain = 0.0f;
+
// Set some musicSource parameters
qalSource3f(musicSource, AL_POSITION, 0.0, 0.0, 0.0);
qalSource3f(musicSource, AL_VELOCITY, 0.0, 0.0, 0.0);
@@ -1995,7 +2018,7 @@ void S_AL_StartBackgroundTrack( const char *intro, const char *loop )
qalSourceQueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers);
// Set the initial gain property
- qalSourcef(musicSource, AL_GAIN, s_alGain->value * s_musicVolume->value);
+ S_AL_Gain(musicSource, s_alGain->value * s_musicVolume->value);
// Start playing
qalSourcePlay(musicSource);
@@ -2038,7 +2061,7 @@ void S_AL_MusicUpdate( void )
}
// Set the gain property
- qalSourcef(musicSource, AL_GAIN, s_alGain->value * s_musicVolume->value);
+ S_AL_Gain(musicSource, s_alGain->value * s_musicVolume->value);
}
@@ -2117,6 +2140,18 @@ void S_AL_Update( void )
{
int i;
+ if(s_muted->modified)
+ {
+ // muted state changed. Let S_AL_Gain turn up all sources again.
+ for(i = 0; i < srcCount; i++)
+ {
+ if(srcList[i].isActive)
+ S_AL_Gain(srcList[i].alSource, srcList[i].scaleGain);
+ }
+
+ s_muted->modified = qfalse;
+ }
+
// Update SFX channels
S_AL_SrcUpdate();