From 696d50b659131ba46ea7f4c44ca4d29475e8cb4f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 30 Apr 2002 23:10:11 +0200 Subject: [PATCH] rnd-20020430-3-src --- src/libgame/sound.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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; } -- 2.34.1