@@ -425,43 +425,31 @@ void BuildAudioClipArray(const std::vector<String> &assets, std::vector<ScriptAu
425425 int temp_number;
426426 char temp_extension[10 ];
427427
428- // FIXME: use audio type constants instead of obscure numeric literals
429428 for (const String &asset : assets)
430429 {
431430 if (sscanf (asset.GetCStr (), " %5s%d.%3s" , temp_name, &temp_number, temp_extension) != 3 )
432431 continue ;
433432
434- ScriptAudioClip clip;
435- if (ags_stricmp (temp_extension, " mp3" ) == 0 )
436- clip.fileType = eAudioFileMP3;
437- else if (ags_stricmp (temp_extension, " wav" ) == 0 )
438- clip.fileType = eAudioFileWAV;
439- else if (ags_stricmp (temp_extension, " voc" ) == 0 )
440- clip.fileType = eAudioFileVOC;
441- else if (ags_stricmp (temp_extension, " mid" ) == 0 )
442- clip.fileType = eAudioFileMIDI;
443- else if ((ags_stricmp (temp_extension, " mod" ) == 0 ) || (ags_stricmp (temp_extension, " xm" ) == 0 )
444- || (ags_stricmp (temp_extension, " s3m" ) == 0 ) || (ags_stricmp (temp_extension, " it" ) == 0 ))
445- clip.fileType = eAudioFileMOD;
446- else if (ags_stricmp (temp_extension, " ogg" ) == 0 )
447- clip.fileType = eAudioFileOGG;
448- else
433+ AudioFileType file_type = ScriptAudioClip::GetAudioFileTypeFromExt (temp_extension);
434+ if (file_type == eAudioFileUndefined)
449435 continue ;
450436
437+ ScriptAudioClip clip;
438+ clip.fileType = file_type;
451439 if (ags_stricmp (temp_name, " music" ) == 0 )
452440 {
453441 clip.scriptName .Format (" aMusic%d" , temp_number);
454442 clip.fileName .Format (" music%d.%s" , temp_number, temp_extension);
455443 clip.bundlingType = (ags_stricmp (temp_extension, " mid" ) == 0 ) ? kAudioBundle_GamePak : kAudioBundle_AudioVox ;
456- clip.type = 2 ;
444+ clip.type = AUDIOTYPE_LEGACY_MUSIC ;
457445 clip.defaultRepeat = 1 ;
458446 }
459447 else if (ags_stricmp (temp_name, " sound" ) == 0 )
460448 {
461449 clip.scriptName .Format (" aSound%d" , temp_number);
462450 clip.fileName .Format (" sound%d.%s" , temp_number, temp_extension);
463451 clip.bundlingType = kAudioBundle_GamePak ;
464- clip.type = 3 ;
452+ clip.type = AUDIOTYPE_LEGACY_SOUND ;
465453 clip.defaultRepeat = 0 ;
466454 }
467455 else
@@ -719,7 +707,7 @@ void RemapLegacySoundNums(GameSetupStruct &game, std::vector<ViewStruct> &views,
719707 game.scoreClipID = -1 ;
720708 if (game.options [OPT_SCORESOUND] > 0 )
721709 {
722- ScriptAudioClip* clip = GetAudioClipForOldStyleNumber (game, false , game.options [OPT_SCORESOUND]);
710+ const ScriptAudioClip* clip = GetAudioClipForOldStyleNumber (game, false , game.options [OPT_SCORESOUND]);
723711 if (clip)
724712 game.scoreClipID = clip->id ;
725713 }
0 commit comments