fixed handling global animation click events (finally)
[rocksndiamonds.git] / src / anim.c
index 9ab9f6dcf4356b4d9ec45300daed590a5103fa37..1e155f9eeacec35859e67fc38087bb8a54f8cb30 100644 (file)
@@ -1164,7 +1164,7 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part,
       if (isClickablePart(part2, mask))
       {
        part2->triggered = TRUE;
-       *click_consumed = clickConsumed(part);          // click was on "part"!
+       *click_consumed |= clickConsumed(part);         // click was on "part"!
 
 #if DEBUG_ANIM_EVENTS
        printf("::: => %d.%d TRIGGERED BY %s OF %d.%d\n",
@@ -1760,6 +1760,7 @@ static void InitGlobalAnim_Clickable(void)
 static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
 {
   boolean click_consumed = FALSE;
+  boolean anything_clicked = FALSE;
   boolean any_part_clicked = FALSE;
   boolean any_event_action = FALSE;
   int mode_nr;
@@ -1803,8 +1804,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
                 part->old_anim_nr + 1, part->old_nr + 1);
 #endif
 
-         part->clicked = TRUE;
-         click_consumed = clickConsumed(part);
+         anything_clicked = part->clicked = TRUE;
+         click_consumed |= clickConsumed(part);
        }
 
        // always handle "unclick:any" events (releasing anywhere on screen) ...
@@ -1816,8 +1817,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
                 part->old_anim_nr + 1, part->old_nr + 1);
 #endif
 
-         part->clicked = TRUE;
-         click_consumed = clickConsumed(part);
+         anything_clicked = part->clicked = TRUE;
+         click_consumed |= clickConsumed(part);
        }
 
        // ... but only handle the first (topmost) clickable animation
@@ -1837,7 +1838,7 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
            any_event_action = TRUE;
 
          // determine if mouse clicks should be blocked from other animations
-         any_part_clicked = clickConsumed(part);
+         any_part_clicked |= clickConsumed(part);
 
          if (isClickablePart(part, ANIM_EVENT_SELF))
          {
@@ -1846,8 +1847,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
                   part->old_anim_nr + 1, part->old_nr + 1);
 #endif
 
-           part->clicked = TRUE;
-           click_consumed = clickConsumed(part);
+           anything_clicked = part->clicked = TRUE;
+           click_consumed |= clickConsumed(part);
          }
 
          // check if this click is defined to trigger other animations
@@ -1858,13 +1859,16 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
     }
   }
 
-  if (click_consumed)
+  if (anything_clicked)
   {
     handle_click = TRUE;
 
     HandleGlobalAnim(ANIM_CONTINUE, game_status);
 
     handle_click = FALSE;
+
+    // prevent ignoring release event if processed within same game frame
+    StopProcessingEvents();
   }
 
   return (click_consumed || any_event_action);