mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
New option LIMIT_SIMULTANEOUS_SOUND prevents sound system from multiple playing same sound at the same time.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9378 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -1190,6 +1190,7 @@ void LoadGameExternalOptions()
|
|||||||
gGameExternalOptions.fDebugSSA = iniReader.ReadBoolean("Sound Settings", "DEBUG_SSA", false, false);
|
gGameExternalOptions.fDebugSSA = iniReader.ReadBoolean("Sound Settings", "DEBUG_SSA", false, false);
|
||||||
gGameExternalOptions.ubVolumeSSA = iniReader.ReadInteger("Sound Settings", "VOLUME_SSA", 50, 1, 127);
|
gGameExternalOptions.ubVolumeSSA = iniReader.ReadInteger("Sound Settings", "VOLUME_SSA", 50, 1, 127);
|
||||||
gGameExternalOptions.fNWSS = iniReader.ReadBoolean("Sound Settings", "NWSS", false, false);
|
gGameExternalOptions.fNWSS = iniReader.ReadBoolean("Sound Settings", "NWSS", false, false);
|
||||||
|
gGameExternalOptions.fLimitSimultaneousSound = iniReader.ReadBoolean("Sound Settings", "LIMIT_SIMULTANEOUS_SOUND", true, false);
|
||||||
|
|
||||||
//################# Tactical Interface Settings #################
|
//################# Tactical Interface Settings #################
|
||||||
|
|
||||||
|
|||||||
@@ -529,6 +529,7 @@ typedef struct
|
|||||||
BOOLEAN fDebugSSA;
|
BOOLEAN fDebugSSA;
|
||||||
UINT8 ubVolumeSSA;
|
UINT8 ubVolumeSSA;
|
||||||
BOOLEAN fNWSS;
|
BOOLEAN fNWSS;
|
||||||
|
BOOLEAN fLimitSimultaneousSound;
|
||||||
|
|
||||||
// WDS - Option to turn off stealing
|
// WDS - Option to turn off stealing
|
||||||
BOOLEAN fStealingDisabled;
|
BOOLEAN fStealingDisabled;
|
||||||
|
|||||||
@@ -6843,6 +6843,9 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
|
|||||||
|
|
||||||
RemoveLoadingScreenProgressBar();
|
RemoveLoadingScreenProgressBar();
|
||||||
|
|
||||||
|
// sevenfm: reset sound map
|
||||||
|
ResetSoundMap();
|
||||||
|
|
||||||
//if( SaveGameHeader.fWorldLoaded )
|
//if( SaveGameHeader.fWorldLoaded )
|
||||||
//{
|
//{
|
||||||
#ifdef NEWMUSIC
|
#ifdef NEWMUSIC
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
// sevenfm
|
// sevenfm
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Sound Control.h"
|
#include "Sound Control.h"
|
||||||
|
//#include "english.h"
|
||||||
|
//#include "input.h"
|
||||||
|
#include <ctime>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Uncomment this to disable the startup of sound hardware
|
// Uncomment this to disable the startup of sound hardware
|
||||||
@@ -288,6 +291,8 @@ void ShutdownSoundManager(void)
|
|||||||
//
|
//
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
|
|
||||||
|
std::map<std::string, std::time_t, std::less<>> gSoundMap;
|
||||||
|
|
||||||
UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
||||||
{
|
{
|
||||||
UINT32 uiSample, uiChannel;
|
UINT32 uiSample, uiChannel;
|
||||||
@@ -296,6 +301,22 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
|||||||
{
|
{
|
||||||
if (!SoundPlayStreamed(pFilename))
|
if (!SoundPlayStreamed(pFilename))
|
||||||
{
|
{
|
||||||
|
// sevenfm: limit simultaneous sound playing
|
||||||
|
if (gGameExternalOptions.fLimitSimultaneousSound)
|
||||||
|
//!_KeyDown(SHIFT))
|
||||||
|
{
|
||||||
|
std::time_t curtime = std::time(0);
|
||||||
|
std::string filename(pFilename);
|
||||||
|
|
||||||
|
if (gSoundMap[filename] > curtime)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set delay for this sound type
|
||||||
|
gSoundMap[filename] = curtime + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((uiSample = SoundLoadSample(pFilename)) != NO_SAMPLE)
|
if ((uiSample = SoundLoadSample(pFilename)) != NO_SAMPLE)
|
||||||
{
|
{
|
||||||
if ((uiChannel = SoundGetFreeChannel()) != SOUND_ERROR)
|
if ((uiChannel = SoundGetFreeChannel()) != SOUND_ERROR)
|
||||||
@@ -328,6 +349,10 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
|||||||
return(SOUND_ERROR);
|
return(SOUND_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetSoundMap(void)
|
||||||
|
{
|
||||||
|
gSoundMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
// SoundPlayStreamedFile
|
// SoundPlayStreamedFile
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ extern UINT32 SoundPlayRandom(STR pFilename, RANDOMPARMS *pParms);
|
|||||||
extern BOOLEAN SoundServiceStreams(void);
|
extern BOOLEAN SoundServiceStreams(void);
|
||||||
extern BOOLEAN SoundServiceRandom(void);
|
extern BOOLEAN SoundServiceRandom(void);
|
||||||
|
|
||||||
|
// sevenfm
|
||||||
|
void ResetSoundMap(void);
|
||||||
|
|
||||||
// Sound instance manipulation functions
|
// Sound instance manipulation functions
|
||||||
extern BOOLEAN SoundStopAll(void);
|
extern BOOLEAN SoundStopAll(void);
|
||||||
extern BOOLEAN SoundStopAllRandom(void);
|
extern BOOLEAN SoundStopAllRandom(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user