Skip to content

Commit

Permalink
Fixed an issue where disabling music would make the program hang.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitl committed Oct 6, 2018
1 parent 3c9ebc3 commit a672182
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 104 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions Build/Enhanced-Changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Black Shades Enhanced v1.1.1
- Fixed an issue where disabling music would make the program hang.

Black Shades Enhanced v1.1
- Fixed a bug where the mouse sometimes clips out of the window in windowed mode.
- Added a new FOV setting.
Expand Down
Binary file modified Build/blackshades.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ But recently I figured out a way to compile it, and thus the Black Shades Enhanc

**What is included?**

As of v1.1.0:
As of v1.1.1:
- Increased the FPS limit from 90 to 300.
- Allows the user to set the FPS limit in the config.txt
- Allows the user to run the game in windowed mode.
Expand All @@ -26,6 +26,7 @@ As of v1.1.0:
- Changed the Sniper Rifle's FOV to 22.50 due to the equation used for calculating user-defined FOV.
- Fixed all compiler warnings!
- Includes the soundtrack!
- Fixed an issue where disabling music would make the program hang.

All the new settings can be set in the config.txt the game generates.

Expand Down
26 changes: 13 additions & 13 deletions blackshades/Source/GameInitDispose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,19 +1713,19 @@ void Game::InitGame()
if(environment!=rainy_environment)alSourcePause(enviro);



whichsong=mainmenusong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);



//redundant!
alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcePlay(music);
if(musictoggle)
{
whichsong=mainmenusong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

//redundant!
alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcePlay(music);
}
}


Expand Down
15 changes: 9 additions & 6 deletions blackshades/Source/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,18 @@ void Game::EventLoop( void )

alSourceStop(SoundFX::inst()->getVisionSource());

whichsong = mainmenusong;
if(musictoggle)
{
whichsong = mainmenusong;


ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1.0);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1.0);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);

alSourcePlay(music);
alSourcePlay(music);
}

}

Expand Down
189 changes: 105 additions & 84 deletions blackshades/Source/GameTick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,26 @@ void Game::Tick(){
alSourcePause(env);
}

ALuint music = SoundFX::inst()->getMusicSource();
if(musictoggle)
{
ALuint music = SoundFX::inst()->getMusicSource();

alSourceStop(music);
alSourcef(music, AL_MIN_GAIN, 0);
alSourcef(music, AL_MAX_GAIN, 0);
alSourceStop(music);
alSourcef(music, AL_MIN_GAIN, 0);
alSourcef(music, AL_MAX_GAIN, 0);

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun==knife)whichsong=knifesong;

if(person[0].whichgun!=knife)whichsong=shootsong;
if(person[0].whichgun!=knife)whichsong=shootsong;

if(type==zombie_type)whichsong=zombiesong;
if(type==zombie_type)whichsong=zombiesong;

alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

flashamount=1;

Expand Down Expand Up @@ -240,25 +243,28 @@ void Game::Tick(){
if(environment==rainy_environment)alSourcePlay(enviro);

if(environment!=rainy_environment)alSourcePause(enviro);

if(musictoggle)
{
//alSourceStop(gSourceID[src_songslot]);
//alSourcef(gSourceID[src_songslot], AL_MIN_GAIN, 0);
//alSourcef(gSourceID[src_songslot], AL_MAX_GAIN, 0);

//alSourceStop(gSourceID[src_songslot]);
//alSourcef(gSourceID[src_songslot], AL_MIN_GAIN, 0);
//alSourcef(gSourceID[src_songslot], AL_MAX_GAIN, 0);
if(person[0].whichgun==knife)whichsong=knifesong;

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;

if(person[0].whichgun!=knife)whichsong=shootsong;
if(type==zombie_type)whichsong=zombiesong;

if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

//alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
//alSourcef(gSourceID[src_songslot], AL_PITCH, 1);
//alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
//alSourcef(gSourceID[src_songslot], AL_PITCH, 1);

alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcePlay(music);
}

//}

Expand Down Expand Up @@ -404,22 +410,24 @@ void Game::Tick(){
alSourceStop(SoundFX::inst()->getVisionSource());


if(musictoggle)
{
//alSourceStop(music);
//alSourcef(music, AL_MIN_GAIN, 0);
//alSourcef(music, AL_MAX_GAIN, 0);

//alSourceStop(music);
//alSourcef(music, AL_MIN_GAIN, 0);
//alSourcef(music, AL_MAX_GAIN, 0);
whichsong=mainmenusong;

whichsong=mainmenusong;
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
//alSourceStop(gSourceID[src_songslot]);

//alSourceStop(gSourceID[src_songslot]);

alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcei(music, AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

if(score>highscore){

Expand Down Expand Up @@ -465,19 +473,21 @@ void Game::Tick(){
alSourceStop(SoundFX::inst()->getVisionSource());



if(musictoggle)
{

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;
if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;

if(type==zombie_type)whichsong=zombiesong;
if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

}

Expand All @@ -495,16 +505,19 @@ void Game::Tick(){

InitGame();

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;
if(type==zombie_type)whichsong=zombiesong;
if(musictoggle)
{
if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;
if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

float gLoc[3];
getAuralCameraPosition(gLoc);
Expand Down Expand Up @@ -3582,24 +3595,28 @@ void Game::Tick(){

soundscalefactor=soundscalefactordefault;

/*
ALuint music = SoundFX::inst()->getMusicSource();
alSourceStop(music);
alSourcef(music, AL_MIN_GAIN, 0);
alSourcef(music, AL_MAX_GAIN, 0);
*/

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;
if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

//alSourcei(gSourceID[src_songslot], AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
if(musictoggle)
{

/*
ALuint music = SoundFX::inst()->getMusicSource();
alSourceStop(music);
alSourcef(music, AL_MIN_GAIN, 0);
alSourcef(music, AL_MAX_GAIN, 0);
*/

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun!=knife)whichsong=shootsong;
if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

//alSourcei(gSourceID[src_songslot], AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

slomo=0;

Expand Down Expand Up @@ -4912,23 +4929,27 @@ void Game::Tick(){

soundscalefactor=soundscalefactordefault;

//alSourceStop(gSourceID[src_songslot]);
//alSourcef(gSourceID[src_songslot], AL_MIN_GAIN, 0);
//alSourcef(gSourceID[src_songslot], AL_MAX_GAIN, 0);
if(musictoggle)
{

//alSourceStop(gSourceID[src_songslot]);
//alSourcef(gSourceID[src_songslot], AL_MIN_GAIN, 0);
//alSourcef(gSourceID[src_songslot], AL_MAX_GAIN, 0);

if(person[0].whichgun==knife)whichsong=knifesong;
if(person[0].whichgun==knife)whichsong=knifesong;

if(person[0].whichgun!=knife)whichsong=shootsong;
if(person[0].whichgun!=knife)whichsong=shootsong;

if(type==zombie_type)whichsong=zombiesong;
if(type==zombie_type)whichsong=zombiesong;

ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);
ALuint music = SoundFX::inst()->getMusicSource(gSampleSet[whichsong]);

//alSourcei(gSourceID[src_songslot], AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
//alSourcei(gSourceID[src_songslot], AL_BUFFER, gSampleSet[whichsong]);
alSourcef(music, AL_PITCH, 1);
alSourcePlay(music);
alSourcef(music, AL_MIN_GAIN, 1);
alSourcef(music, AL_MAX_GAIN, 1);
}

slomo=0;

Expand Down

0 comments on commit a672182

Please sign in to comment.