+struct FileInfo *getMusicListEntry(int pos)
+{
+ int num_list_entries = music_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+
+ return (pos < num_list_entries ? &music_info->file_list[list_pos] :
+ &music_info->dynamic_file_list[list_pos]);
+}
+
+static SoundInfo *getSoundInfoEntryFromSoundID(int pos)
+{
+ int num_list_entries = sound_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+ SoundInfo **snd_info =
+ (SoundInfo **)(pos < num_list_entries ? sound_info->artwork_list :
+ sound_info->dynamic_artwork_list);
+
+ return snd_info[list_pos];
+}
+
+static MusicInfo *getMusicInfoEntryFromMusicID(int pos)
+{
+ int num_list_entries = music_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+ MusicInfo **mus_info =
+ (MusicInfo **)(pos < num_list_entries ? music_info->artwork_list :
+ music_info->dynamic_artwork_list);
+
+ return mus_info[list_pos];
+}
+
+int getSoundListPropertyMappingSize()
+{
+ return sound_info->num_property_mapping_entries;
+}
+
+int getMusicListPropertyMappingSize()
+{
+ return music_info->num_property_mapping_entries;
+}
+
+struct PropertyMapping *getSoundListPropertyMapping()
+{
+ return sound_info->property_mapping;
+}
+
+struct PropertyMapping *getMusicListPropertyMapping()
+{
+ return music_info->property_mapping;
+}
+
+void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries,
+ struct ConfigTypeInfo *config_suffix_list,
+ char **base_prefixes, char **ext1_suffixes,
+ char **ext2_suffixes, char **ext3_suffixes,
+ char **ignore_tokens)
+{
+ int i;
+
+ sound_info = checked_calloc(sizeof(struct ArtworkListInfo));
+ sound_info->type = ARTWORK_TYPE_SOUNDS;
+
+ /* ---------- initialize file list and suffix lists ---------- */
+
+ sound_info->num_file_list_entries = num_file_list_entries;
+ sound_info->num_dynamic_file_list_entries = 0;
+
+ sound_info->file_list =
+ getFileListFromConfigList(config_list, config_suffix_list, ignore_tokens,
+ num_file_list_entries);
+ sound_info->dynamic_file_list = NULL;
+
+ sound_info->num_suffix_list_entries = 0;
+ for (i = 0; config_suffix_list[i].token != NULL; i++)
+ sound_info->num_suffix_list_entries++;
+
+ sound_info->suffix_list = config_suffix_list;
+
+ /* ---------- initialize base prefix and suffixes lists ---------- */
+
+ sound_info->num_base_prefixes = 0;
+ for (i = 0; base_prefixes[i] != NULL; i++)
+ sound_info->num_base_prefixes++;
+
+ sound_info->num_ext1_suffixes = 0;
+ for (i = 0; ext1_suffixes[i] != NULL; i++)
+ sound_info->num_ext1_suffixes++;
+
+ sound_info->num_ext2_suffixes = 0;
+ for (i = 0; ext2_suffixes[i] != NULL; i++)
+ sound_info->num_ext2_suffixes++;
+
+ sound_info->num_ext3_suffixes = 0;
+ for (i = 0; ext3_suffixes[i] != NULL; i++)
+ sound_info->num_ext3_suffixes++;
+
+ sound_info->num_ignore_tokens = 0;
+ for (i = 0; ignore_tokens[i] != NULL; i++)
+ sound_info->num_ignore_tokens++;
+
+ sound_info->base_prefixes = base_prefixes;
+ sound_info->ext1_suffixes = ext1_suffixes;
+ sound_info->ext2_suffixes = ext2_suffixes;
+ sound_info->ext3_suffixes = ext3_suffixes;
+ sound_info->ignore_tokens = ignore_tokens;
+
+ sound_info->num_property_mapping_entries = 0;
+
+ sound_info->property_mapping = NULL;
+
+ /* ---------- initialize artwork reference and content lists ---------- */
+
+ sound_info->sizeof_artwork_list_entry = sizeof(SoundInfo *);
+
+ sound_info->artwork_list =
+ checked_calloc(num_file_list_entries * sizeof(SoundInfo *));
+ sound_info->dynamic_artwork_list = NULL;
+
+ sound_info->content_list = NULL;
+
+ /* ---------- initialize artwork loading/freeing functions ---------- */
+
+ sound_info->load_artwork = Load_WAV;
+ sound_info->free_artwork = FreeSound;
+}
+
+void InitMusicList(struct ConfigInfo *config_list, int num_file_list_entries,
+ struct ConfigTypeInfo *config_suffix_list,
+ char **base_prefixes, char **ext1_suffixes,
+ char **ext2_suffixes, char **ext3_suffixes,
+ char **ignore_tokens)
+{
+ int i;
+
+ music_info = checked_calloc(sizeof(struct ArtworkListInfo));
+ music_info->type = ARTWORK_TYPE_MUSIC;
+
+ /* ---------- initialize file list and suffix lists ---------- */
+
+ music_info->num_file_list_entries = num_file_list_entries;
+ music_info->num_dynamic_file_list_entries = 0;
+
+ music_info->file_list =
+ getFileListFromConfigList(config_list, config_suffix_list, ignore_tokens,
+ num_file_list_entries);
+ music_info->dynamic_file_list = NULL;
+
+ music_info->num_suffix_list_entries = 0;
+ for (i = 0; config_suffix_list[i].token != NULL; i++)
+ music_info->num_suffix_list_entries++;
+
+ music_info->suffix_list = config_suffix_list;
+
+ /* ---------- initialize base prefix and suffixes lists ---------- */
+
+ music_info->num_base_prefixes = 0;
+ for (i = 0; base_prefixes[i] != NULL; i++)
+ music_info->num_base_prefixes++;
+
+ music_info->num_ext1_suffixes = 0;
+ for (i = 0; ext1_suffixes[i] != NULL; i++)
+ music_info->num_ext1_suffixes++;
+
+ music_info->num_ext2_suffixes = 0;
+ for (i = 0; ext2_suffixes[i] != NULL; i++)
+ music_info->num_ext2_suffixes++;
+
+ music_info->num_ext3_suffixes = 0;
+ for (i = 0; ext3_suffixes[i] != NULL; i++)
+ music_info->num_ext3_suffixes++;
+
+ music_info->num_ignore_tokens = 0;
+ for (i = 0; ignore_tokens[i] != NULL; i++)
+ music_info->num_ignore_tokens++;
+
+ music_info->base_prefixes = base_prefixes;
+ music_info->ext1_suffixes = ext1_suffixes;
+ music_info->ext2_suffixes = ext2_suffixes;
+ music_info->ext3_suffixes = ext3_suffixes;
+ music_info->ignore_tokens = ignore_tokens;
+
+ music_info->num_property_mapping_entries = 0;
+
+ music_info->property_mapping = NULL;
+
+ /* ---------- initialize artwork reference and content lists ---------- */
+
+ music_info->sizeof_artwork_list_entry = sizeof(MusicInfo *);
+
+ music_info->artwork_list =
+ checked_calloc(num_file_list_entries * sizeof(MusicInfo *));
+ music_info->dynamic_artwork_list = NULL;
+
+ music_info->content_list = NULL;
+
+ /* ---------- initialize artwork loading/freeing functions ---------- */
+
+ music_info->load_artwork = Load_WAV_or_MOD;
+ music_info->free_artwork = FreeMusic;