From: Holger Schemel Date: Tue, 30 Apr 2002 21:10:11 +0000 (+0200) Subject: rnd-20020430-3-src X-Git-Tag: 2.1.0^2~40 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=696d50b659131ba46ea7f4c44ca4d29475e8cb4f;p=rocksndiamonds.git rnd-20020430-3-src --- 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; }