From 9076c2bc92fef1fd65a20117317619ce70db5b56 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Wed, 13 Sep 2017 06:57:00 +0200 Subject: [PATCH 1/2] Do not stop the jingles sounds (win and lost) when ending a game It uses a list of sounds to skip. The fade is apply on all other sounds. - It concerns the issue #9. --- src/event.cxx | 6 +++++- src/sound.cxx | 5 ++++- src/sound.h | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/event.cxx b/src/event.cxx index 32f8d3a..6aa45d3 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -3031,7 +3032,10 @@ CEvent::ChangePhase (Uint32 phase) // FIXME: pause is better if the game is not stop but just interrupted if (m_phase == EV_PHASE_PLAY && m_phase != phase) - m_pSound->StopAllSounds (false); + { + static const std::set except = {SOUND_WIN, SOUND_LOST}; + m_pSound->StopAllSounds (false, &except); + } m_phase = phase; // change de phase m_index = index; diff --git a/src/sound.cxx b/src/sound.cxx index 676545e..7040dee 100644 --- a/src/sound.cxx +++ b/src/sound.cxx @@ -28,13 +28,16 @@ // Stops all sounds. bool -CSound::StopAllSounds (bool immediat) +CSound::StopAllSounds (bool immediat, const std::set * except) { for (Sint32 i = 0; i < MAXSOUND; i++) { if (!m_lpSDL[i]) continue; + if (except && except->find (i) != except->end ()) + continue; + if (Mix_Playing (i + 1) == SDL_TRUE) { if (immediat) diff --git a/src/sound.h b/src/sound.h index e238b2a..056ee97 100644 --- a/src/sound.h +++ b/src/sound.h @@ -20,11 +20,13 @@ #pragma once -#include +#include #include #include #include +#include + #include "blupi.h" #define MAXSOUND 100 @@ -63,7 +65,7 @@ public: bool IsStoppedOnDemand (); void AdaptVolumeMusic (); void SetSuspendSkip (Sint32 nb); - bool StopAllSounds (bool immediat); + bool StopAllSounds (bool immediat, const std::set * except = nullptr); protected: bool m_bState; From 513e94a6226015e813a9ff935733bf8c33abbc8a Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Wed, 13 Sep 2017 06:58:48 +0200 Subject: [PATCH 2/2] Cosmetic --- src/sound.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sound.h b/src/sound.h index 056ee97..1237c37 100644 --- a/src/sound.h +++ b/src/sound.h @@ -80,5 +80,3 @@ protected: Sint32 m_lastMidiVolume; Sint32 m_nbSuspendSkip; }; - -/////////////////////////////////////////////////////////////////////////////