Skip to content

Commit 228df8a

Browse files
committed
Fix bounding conditional in Audio_GetSound
1 parent 63d0b1b commit 228df8a

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

scripts/functions/Function_Sound.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,32 +1181,22 @@ function getFreeVoice(_props)
11811181
return null;
11821182
}
11831183

1184-
function Audio_GetSound(soundid)
1185-
{
1186-
var pSound = null;
1187-
if(soundid>=0 && soundid<=audio_sampledata.length )
1188-
{
1189-
pSound = audio_sampledata[soundid];
1190-
}
1191-
else
1192-
{
1193-
var bufferSoundId = soundid - BASE_BUFFER_SOUND_INDEX;
1194-
if( bufferSoundId >=0 && bufferSoundId < g_bufferSoundCount)
1195-
{
1196-
pSound = buffer_sampledata[bufferSoundId];
1197-
}
1198-
else
1199-
{
1200-
var queueSoundId = soundid - BASE_QUEUE_SOUND_INDEX;
1184+
function Audio_GetSound(soundid) {
1185+
if (soundid >= 0 && soundid < audio_sampledata.length) {
1186+
return audio_sampledata[soundid];
1187+
}
12011188

1202-
if (queueSoundId >= 0 && queueSoundId < g_queueSoundCount)
1203-
{
1204-
pSound = queue_sampledata[queueSoundId];
1205-
}
1206-
}
1207-
}
1189+
const bufferSoundId = soundid - BASE_BUFFER_SOUND_INDEX;
1190+
if (bufferSoundId >= 0 && bufferSoundId < g_bufferSoundCount) {
1191+
return buffer_sampledata[bufferSoundId];
1192+
}
1193+
1194+
const queueSoundId = soundid - BASE_QUEUE_SOUND_INDEX;
1195+
if (queueSoundId >= 0 && queueSoundId < g_queueSoundCount) {
1196+
return queue_sampledata[queueSoundId];
1197+
}
12081198

1209-
return pSound;
1199+
return null;
12101200
}
12111201

12121202
function Audio_GetEmitterOrThrow(_emitterIndex) {

0 commit comments

Comments
 (0)