mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix: Mapping sounds in editor works even when the sound system is disabled
This commit is contained in:
parent
1523954333
commit
699fb60532
|
@ -462,14 +462,14 @@ int CSound::LoadWV(const char *pFilename)
|
|||
return SampleID;
|
||||
}
|
||||
|
||||
int CSound::LoadWVFromMem(const void *pData, unsigned DataSize)
|
||||
int CSound::LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor = false)
|
||||
{
|
||||
// don't waste memory on sound when we are stress testing
|
||||
if(g_Config.m_DbgStress)
|
||||
return -1;
|
||||
|
||||
// no need to load sound when we are running with no sound
|
||||
if(!m_SoundEnabled)
|
||||
if(!m_SoundEnabled && !FromEditor)
|
||||
return -1;
|
||||
|
||||
if(!pData)
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
|
||||
|
||||
virtual int LoadWV(const char *pFilename);
|
||||
virtual int LoadWVFromMem(const void *pData, unsigned DataSize);
|
||||
virtual int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor);
|
||||
virtual void UnloadSample(int SampleID);
|
||||
|
||||
virtual float GetSampleDuration(int SampleID); // in s
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
virtual bool IsSoundEnabled() = 0;
|
||||
|
||||
virtual int LoadWV(const char *pFilename) = 0;
|
||||
virtual int LoadWVFromMem(const void *pData, unsigned DataSize) = 0;
|
||||
virtual int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor = false) = 0;
|
||||
virtual void UnloadSample(int SampleID) = 0;
|
||||
|
||||
virtual float GetSampleDuration(int SampleID) = 0; // in s
|
||||
|
|
|
@ -2927,7 +2927,7 @@ void CEditor::AddSound(const char *pFileName, int StorageType, void *pUser)
|
|||
io_close(SoundFile);
|
||||
|
||||
// load sound
|
||||
int SoundId = pEditor->Sound()->LoadWVFromMem(pData, (unsigned) DataSize);
|
||||
int SoundId = pEditor->Sound()->LoadWVFromMem(pData, (unsigned) DataSize, true);
|
||||
if(SoundId == -1)
|
||||
return;
|
||||
|
||||
|
|
|
@ -660,7 +660,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
io_close(SoundFile);
|
||||
if(pSound->m_DataSize > 0)
|
||||
{
|
||||
pSound->m_SoundID = m_pEditor->Sound()->LoadWVFromMem(pSound->m_pData, pSound->m_DataSize);
|
||||
pSound->m_SoundID = m_pEditor->Sound()->LoadWVFromMem(pSound->m_pData, pSound->m_DataSize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
void *pData = DataFile.GetData(pItem->m_SoundData);
|
||||
pSound->m_pData = mem_alloc(pSound->m_DataSize, 1);
|
||||
mem_copy(pSound->m_pData, pData, pSound->m_DataSize);
|
||||
pSound->m_SoundID = m_pEditor->Sound()->LoadWVFromMem(pSound->m_pData, pSound->m_DataSize);
|
||||
pSound->m_SoundID = m_pEditor->Sound()->LoadWVFromMem(pSound->m_pData, pSound->m_DataSize, true);
|
||||
}
|
||||
|
||||
// copy image name
|
||||
|
|
Loading…
Reference in a new issue