From: Holger Schemel Date: Wed, 13 Mar 2019 19:25:02 +0000 (+0100) Subject: added support for more event types for global animations (yet to be added) X-Git-Tag: 4.1.3.0~40 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=897c46a2720672a49ce6d0803b08eed23fd2dd90;p=rocksndiamonds.git added support for more event types for global animations (yet to be added) --- diff --git a/src/anim.c b/src/anim.c index 49f346ee..48393eb3 100644 --- a/src/anim.c +++ b/src/anim.c @@ -992,16 +992,15 @@ static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part) static boolean checkGlobalAnimEvent(int anim_event, int mask) { - int trigger_mask = ANIM_EVENT_ANIM_MASK | ANIM_EVENT_PART_MASK; - int mask_anim_only = mask & ANIM_EVENT_ANIM_MASK; + int mask_anim_only = mask & ~ANIM_EVENT_PART_MASK; if (mask & ANIM_EVENT_ANY) return (anim_event & ANIM_EVENT_ANY); else if (mask & ANIM_EVENT_SELF) return (anim_event & ANIM_EVENT_SELF); else - return ((anim_event & trigger_mask) == mask || - (anim_event & trigger_mask) == mask_anim_only); + return (anim_event == mask || + anim_event == mask_anim_only); } static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask) @@ -1618,7 +1617,7 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) // check if this click is defined to trigger other animations int gic_anim_nr = part->old_anim_nr + 1; // X as in "anim_X" int gic_part_nr = part->old_nr + 1; // Y as in "part_Y" - int mask = gic_anim_nr << ANIM_EVENT_ANIM_BIT; + int mask = ANIM_EVENT_CLICK | (gic_anim_nr << ANIM_EVENT_ANIM_BIT); if (!part->is_base) mask |= gic_part_nr << ANIM_EVENT_PART_BIT; diff --git a/src/files.c b/src/files.c index be19967a..9f20487f 100644 --- a/src/files.c +++ b/src/files.c @@ -10064,17 +10064,35 @@ static boolean string_has_parameter(char *s, char *s_contained) static int get_anim_parameter_value(char *s) { - char *pattern_1 = "click:anim_"; + int event_value[] = + { + ANIM_EVENT_CLICK + }; + char *pattern_1[] = + { + "click:anim_" + }; char *pattern_2 = ".part_"; char *matching_char = NULL; char *s_ptr = s; + int pattern_1_len = 0; int result = ANIM_EVENT_NONE; + int i; + + for (i = 0; i < ARRAY_SIZE(event_value); i++) + { + matching_char = strstr(s_ptr, pattern_1[i]); + pattern_1_len = strlen(pattern_1[i]); + result = event_value[i]; + + if (matching_char != NULL) + break; + } - matching_char = strstr(s_ptr, pattern_1); if (matching_char == NULL) return ANIM_EVENT_NONE; - s_ptr = matching_char + strlen(pattern_1); + s_ptr = matching_char + pattern_1_len; // check for main animation number ("anim_X" or "anim_XX") if (*s_ptr >= '0' && *s_ptr <= '9') diff --git a/src/libgame/system.h b/src/libgame/system.h index 7b45b057..d0584d4b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -357,7 +357,10 @@ #define ANIM_EVENT_NONE 0 #define ANIM_EVENT_SELF (1 << 16) #define ANIM_EVENT_ANY (1 << 17) +#define ANIM_EVENT_CLICK (1 << 18) +// anim number: bits 0-7 +// part number: bits 8-15 #define ANIM_EVENT_ANIM_BIT 0 #define ANIM_EVENT_PART_BIT 8