Commit f871c698 authored by NY00123's avatar NY00123
Browse files

Duke3D: Check that the sound index is nonnegative in S_SoundIsValid.

This fixes a crash when pressing on a switch with a negative hitag.
parent a7ab79e6
......@@ -77,7 +77,7 @@ extern int32_t MusicIsWaveform, MusicVoice;
static FORCE_INLINE bool S_SoundIsValid(int soundNum)
{
return soundNum <= g_highestSoundIdx && g_sounds[soundNum] && g_sounds[soundNum] != &nullsound && g_sounds[soundNum]->ptr;
return soundNum >= 0 && soundNum <= g_highestSoundIdx && g_sounds[soundNum] && g_sounds[soundNum] != &nullsound && g_sounds[soundNum]->ptr;
}
static FORCE_INLINE bool S_IsAmbientSFX(int const spriteNum) { return (sprite[spriteNum].picnum == MUSICANDSFX && sprite[spriteNum].lotag < 999); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment