- Fixed: Attempting to load 0-length sounds caused a crash.

SVN r1100 (trunk)
This commit is contained in:
Randy Heit 2008-07-31 23:09:58 +00:00
parent fb40f5f711
commit bb0759f575
2 changed files with 15 additions and 1 deletions

View file

@ -1,4 +1,5 @@
July 31, 2008 July 31, 2008
- Fixed: Attempting to load 0-length sounds caused a crash.
- Removed filename-lowercasing from zipdir. - Removed filename-lowercasing from zipdir.
- Fixed: The ouch face fix was lost when SBARINFO mugshot became the only - Fixed: The ouch face fix was lost when SBARINFO mugshot became the only
mugshot present. mugshot present.

View file

@ -99,6 +99,8 @@ EXTERN_CVAR (Int, snd_samplerate)
EXTERN_CVAR (Bool, snd_pitched) EXTERN_CVAR (Bool, snd_pitched)
EXTERN_CVAR (Int, snd_channels) EXTERN_CVAR (Int, snd_channels)
extern int sfx_empty;
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
ReverbContainer *ForcedEnvironment; ReverbContainer *ForcedEnvironment;
@ -1991,6 +1993,7 @@ void FMODSoundRenderer::DoLoad(void **slot, sfxinfo_t *sfx)
errcount = 0; errcount = 0;
while (errcount < 2) while (errcount < 2)
{ {
sample = NULL;
if (sfxdata != NULL) if (sfxdata != NULL)
{ {
delete[] sfxdata; delete[] sfxdata;
@ -2052,6 +2055,11 @@ void FMODSoundRenderer::DoLoad(void **slot, sfxinfo_t *sfx)
{ {
exinfo.length = size; exinfo.length = size;
} }
if (exinfo.length == 0)
{
DPrintf("Sample has a length of 0\n");
break;
}
result = Sys->createSound((char *)sfxstart, samplemode, &exinfo, &sample); result = Sys->createSound((char *)sfxstart, samplemode, &exinfo, &sample);
if (result != FMOD_OK) if (result != FMOD_OK)
{ {
@ -2094,7 +2102,7 @@ void FMODSoundRenderer::getsfx(sfxinfo_t *sfx)
// If the sound doesn't exist, replace it with the empty sound. // If the sound doesn't exist, replace it with the empty sound.
if (sfx->lumpnum == -1) if (sfx->lumpnum == -1)
{ {
sfx->lumpnum = Wads.GetNumForName("dsempty", ns_sounds); sfx->lumpnum = sfx_empty;
} }
// See if there is another sound already initialized with this lump. If so, // See if there is another sound already initialized with this lump. If so,
@ -2109,6 +2117,11 @@ void FMODSoundRenderer::getsfx(sfxinfo_t *sfx)
} }
} }
DoLoad(&sfx->data, sfx); DoLoad(&sfx->data, sfx);
// If the sound failed to load, make it the empty sound.
if (sfx->data == NULL)
{
sfx->lumpnum = sfx_empty;
}
} }
//========================================================================== //==========================================================================