fixed handling global animation key event actions multiple times
[rocksndiamonds.git] / src / files.c
index be19967a77e4b5a63f03148318e45810ad03903a..cfba947d0c50ac26aa6870d5d87cbb1f48f45d3d 100644 (file)
@@ -10064,17 +10064,43 @@ 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,
+    ANIM_EVENT_INIT,
+    ANIM_EVENT_START,
+    ANIM_EVENT_END,
+    ANIM_EVENT_POST
+  };
+  char *pattern_1[] =
+  {
+    "click:anim_",
+    "init:anim_",
+    "start:anim_",
+    "end:anim_",
+    "post: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')
@@ -10142,6 +10168,9 @@ static int get_anim_parameter_values(char *s)
       string_has_parameter(s, "self"))
     event_value |= ANIM_EVENT_SELF;
 
+  if (string_has_parameter(s, "unclick:any"))
+    event_value |= ANIM_EVENT_UNCLICK_ANY;
+
   // if animation event found, add it to global animation event list
   if (event_value != ANIM_EVENT_NONE)
     list_pos = AddGlobalAnimEventValue(list_pos, event_value);