Fix: Mapping sounds in editor works even when the sound system is disabled

This commit is contained in:
def 2014-10-25 01:23:39 +02:00
parent 1523954333
commit 699fb60532
5 changed files with 7 additions and 7 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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