@@ -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
12121202function Audio_GetEmitterOrThrow ( _emitterIndex ) {
@@ -1509,8 +1499,9 @@ function audio_sound_get_gain(_index)
15091499 else {
15101500 const asset = Audio_GetSound ( _index ) ;
15111501
1512- if ( asset !== undefined )
1502+ if ( asset !== null ) {
15131503 return asset . gain . get ( ) ;
1504+ }
15141505 }
15151506
15161507 return 0 ;
@@ -1643,8 +1634,7 @@ function audio_sound_get_track_position(_soundid)
16431634 {
16441635 const sound_asset = Audio_GetSound ( _soundid ) ;
16451636
1646- if ( sound_asset != undefined )
1647- {
1637+ if ( sound_asset !== null ) {
16481638 return sound_asset . trackPos ;
16491639 }
16501640 }
@@ -1678,8 +1668,7 @@ function audio_sound_set_track_position(_soundid, _time)
16781668 {
16791669 const sampleData = Audio_GetSound ( _soundid ) ;
16801670
1681- if ( sampleData != undefined )
1682- {
1671+ if ( sampleData !== null ) {
16831672 sampleData . trackPos = _time ;
16841673 }
16851674 }
0 commit comments