From: Holger Schemel Date: Wed, 29 Dec 2021 14:57:38 +0000 (+0100) Subject: added range check for checking sound and music loops X-Git-Tag: 4.3.1.0~1 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=28efd33e1ab0ff432871d8845eed025893cdabc8 added range check for checking sound and music loops This fixes a bug when playing music on the music info screen that is not configured in "musicinfo.conf", therefore getting a negative ID, which caused an illegal array access when checking for music loop. (The added range check takes into account that the default loop mode for sounds is "false", but is "true" for music, if not specified.) --- diff --git a/src/main.h b/src/main.h index 5ff5558a..3a3dc8af 100644 --- a/src/main.h +++ b/src/main.h @@ -932,8 +932,8 @@ #define IS_NEW_FRAME(f, g) (IS_ANIMATED(g) && IS_NEW_DELAY(f, g)) #define IS_NEXT_FRAME(f, g) (IS_NEW_FRAME(f, g) && (f) > 0) -#define IS_LOOP_SOUND(s) (sound_info[s].loop) -#define IS_LOOP_MUSIC(s) (music_info[s].loop) +#define IS_LOOP_SOUND(s) ((s) >= 0 && sound_info[s].loop) +#define IS_LOOP_MUSIC(s) ((s) < 0 || music_info[s].loop) #define IS_SPECIAL_GFX_ARG(a) ((a) >= 0 && (a) < NUM_SPECIAL_GFX_ARGS)