mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +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.ubVolumeSSA = iniReader.ReadInteger("Sound Settings", "VOLUME_SSA", 50, 1, 127);
|
||||
gGameExternalOptions.fNWSS = iniReader.ReadBoolean("Sound Settings", "NWSS", false, false);
|
||||
gGameExternalOptions.fLimitSimultaneousSound = iniReader.ReadBoolean("Sound Settings", "LIMIT_SIMULTANEOUS_SOUND", true, false);
|
||||
|
||||
//################# Tactical Interface Settings #################
|
||||
|
||||
|
||||
@@ -529,6 +529,7 @@ typedef struct
|
||||
BOOLEAN fDebugSSA;
|
||||
UINT8 ubVolumeSSA;
|
||||
BOOLEAN fNWSS;
|
||||
BOOLEAN fLimitSimultaneousSound;
|
||||
|
||||
// WDS - Option to turn off stealing
|
||||
BOOLEAN fStealingDisabled;
|
||||
|
||||
@@ -6843,6 +6843,9 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
|
||||
|
||||
RemoveLoadingScreenProgressBar();
|
||||
|
||||
// sevenfm: reset sound map
|
||||
ResetSoundMap();
|
||||
|
||||
//if( SaveGameHeader.fWorldLoaded )
|
||||
//{
|
||||
#ifdef NEWMUSIC
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
// sevenfm
|
||||
#include "message.h"
|
||||
#include "Sound Control.h"
|
||||
//#include "english.h"
|
||||
//#include "input.h"
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
// 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 uiSample, uiChannel;
|
||||
@@ -296,6 +301,22 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
||||
{
|
||||
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 ((uiChannel = SoundGetFreeChannel()) != SOUND_ERROR)
|
||||
@@ -328,6 +349,10 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms)
|
||||
return(SOUND_ERROR);
|
||||
}
|
||||
|
||||
void ResetSoundMap(void)
|
||||
{
|
||||
gSoundMap.clear();
|
||||
}
|
||||
|
||||
//*******************************************************************************
|
||||
// SoundPlayStreamedFile
|
||||
|
||||
@@ -79,6 +79,9 @@ extern UINT32 SoundPlayRandom(STR pFilename, RANDOMPARMS *pParms);
|
||||
extern BOOLEAN SoundServiceStreams(void);
|
||||
extern BOOLEAN SoundServiceRandom(void);
|
||||
|
||||
// sevenfm
|
||||
void ResetSoundMap(void);
|
||||
|
||||
// Sound instance manipulation functions
|
||||
extern BOOLEAN SoundStopAll(void);
|
||||
extern BOOLEAN SoundStopAllRandom(void);
|
||||
|
||||
Reference in New Issue
Block a user