X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=4b62e341fbd0e8d7d3029df0d8ab82ec3913b0cd;hp=5d0817a33e0ce9558520a9623fd0ae0e4569ce52;hb=696d50b659131ba46ea7f4c44ca4d29475e8cb4f;hpb=0a85e6bd82e4c5c495be7201f672f788123dcb84 diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 5d0817a3..4b62e341 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1233,6 +1233,7 @@ static SoundInfo *Load_WAV(char *filename) static void LoadCustomSound(SoundInfo **snd_info, char *basename) { char *filename = getCustomSoundFilename(basename); + ListNode *node; if (filename == NULL) /* (should never happen) */ { @@ -1251,12 +1252,16 @@ static void LoadCustomSound(SoundInfo **snd_info, char *basename) and a fallback to the existing sound is done. */ #if 1 - printf("[sound '%s' already exists]\n", filename); + printf("[sound '%s' already exists (same list entry)]\n", filename); #endif return; } +#if 1 + printf("[decrementing reference counter of sound '%s']\n", filename_old); +#endif + if (--(*snd_info)->num_references <= 0) { #if 1 @@ -1270,6 +1275,20 @@ static void LoadCustomSound(SoundInfo **snd_info, char *basename) } } + /* check if this sound already exists in the list of sounds */ + node = getNodeFromKey(SoundFileList, filename); + if (node) + { +#if 1 + printf("[sound '%s' already exists (other list entry)]\n", filename); +#endif + + *snd_info = (SoundInfo *)node->content; + (*snd_info)->num_references++; + + return; + } + *snd_info = Load_WAV(filename); (*snd_info)->num_references = 1; @@ -1636,7 +1655,8 @@ void dumpList(ListNode *node_first) while (node) { - printf("['%s']\n", node->key); + printf("['%s' (%d)]\n", node->key, + ((SoundInfo *)node->content)->num_references); node = node->next; }