Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9923/src Modified Files: input.c sound.c Log Message: Remove unused music_toggle, instead use sound_toggle for music playback, fixes bug where geno music would still play with sound turned off. New volume raise/lower function for SDL sound, which changes sound playback volume without changing Windows WAV volume. Index: input.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- input.c 13 Dec 2006 00:00:00 -0000 1.19 +++ input.c 11 Feb 2007 03:20:58 -0000 1.20 @@ -2847,7 +2847,10 @@ Key86 (void) { #ifdef SOUND - ChangeVolume (1); + if (newSound) + ChangeNewsoundVolume (1); + else + ChangeVolume (1); #else emptyKey (); #endif @@ -3322,7 +3325,10 @@ Key118 (W_Event * data) { #ifdef SOUND - ChangeVolume (-1); + if (newSound) + ChangeNewsoundVolume (-1); + else + ChangeVolume (-1); #else emptyKey (); #endif Index: sound.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- sound.c 7 Feb 2007 23:04:57 -0000 1.22 +++ sound.c 11 Feb 2007 03:20:58 -0000 1.23 @@ -222,8 +222,7 @@ sound_toggle = 1; loadSounds(); - /* Toggle on music, load music files, and play random intro music */ - music_toggle = 1; + /* Load music files, and play random intro music */ loadMusic(); i = RANDOM() % MUSIC_OFFSET; Play_Music(i); @@ -361,7 +360,7 @@ /* Only works with SDL, i.e. newSound */ extern void Play_Music (int type) { - if (!sound_init || !newSound || !newSoundMusic || !music_toggle) + if (!sound_init || !sound_toggle || !newSound || !newSoundMusic) return; if ((type >= NUM_MUSIC) || (type < 0)) @@ -382,7 +381,7 @@ { int i; - if (!sound_init || !newSound || !newSoundMusic || !newSoundMusicBkgd|| !music_toggle) + if (!sound_init || !sound_toggle || !newSound || !newSoundMusic || !newSoundMusicBkgd) return; if (Mix_PlayingMusic()) @@ -437,6 +436,28 @@ } } +/* Only works with SDL, i.e. newSound */ +extern void ChangeNewsoundVolume (int vol) +{ + int mvolume, volume; + + // Get current average sound volume and music volume + volume = Mix_Volume(-1, -1); + mvolume = Mix_VolumeMusic(-1); + + // Change sound volume for all channels, range is 0 to 128 + volume = volume + 10*vol; + if (volume < 0) + volume = 0; + Mix_Volume(-1,volume); + + // Change music volume, range is 0 to 128 + mvolume = mvolume + 10*vol; + if (mvolume < 0) + mvolume = 0; + Mix_VolumeMusic(mvolume); +} + extern void Abort_Sound (int type) { if ((current_sound != NO_SOUND) && (type == current_sound))