From: Holger Schemel Date: Wed, 12 Sep 2018 19:08:08 +0000 (+0200) Subject: fixed bug with expiring loop sounds for global animations when playing X-Git-Tag: 4.1.1.0~37 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=efcd338d72a50e7972c3d28fe37b925c2cf7434f;hp=ad93f89279233a6adfa0dc0ebe3570c4c614cedb fixed bug with expiring loop sounds for global animations when playing When playing the game, loop sounds are automatically expired if they are not "refreshed" at regular intervals (to prevent playing sounds for game elements that do not exist on the playfield anymore). However, this also affects loop sounds for global animations played during the game, so special care has to be taken to prevent them from accidentally being expired, too. --- diff --git a/src/anim.c b/src/anim.c index 1623cdc4..fbc88c35 100644 --- a/src/anim.c +++ b/src/anim.c @@ -959,6 +959,28 @@ static void StopGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part) StopGlobalAnimMusic(part); } +static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part) +{ + // when drawing animations to fading buffer, do not play sounds + if (drawing_to_fading_buffer) + return; + + // loop sounds only expire when playing + if (game_status != GAME_MODE_PLAYING) + return; + + // check if any sound is defined for this animation part + if (part->sound == SND_UNDEFINED) + return; + + // normal (non-loop) sounds do not expire when playing + if (!IS_LOOP_SOUND(part->sound)) + return; + + // prevent expiring loop sounds when playing + PlayGlobalAnimSound(part); +} + static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask) { struct GraphicInfo *c = &part->control_info; @@ -1229,6 +1251,9 @@ int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, int state) return ANIM_STATE_WAITING; } + // special case to prevent expiring loop sounds when playing + PlayGlobalAnimSoundIfLoop(part); + if (!DelayReachedExt(&part->step_delay, part->step_delay_value, anim_sync_frame)) return ANIM_STATE_RUNNING;