mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user