From: Holger Schemel Date: Fri, 31 May 2019 11:53:17 +0000 (+0200) Subject: fixed handling global animation click events (finally) X-Git-Tag: 4.1.4.0~29 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7f849601975c5b19775306326993b1dd6ed888b3;p=rocksndiamonds.git fixed handling global animation click events (finally) Also see commit 4be294f9, which did not fix the problem in all cases, because the next part of a multi-part global animation (activated by a click event) will not be active before the following game frame, so a directly following release event would still just be ignored. Stopping processing of all following events for one game frame after handling a click event lets the animation successfully change to the next part, which can then be triggered by the release event. An example where this might happen is mentioned in the above commit. --- diff --git a/src/anim.c b/src/anim.c index d5b3d74a..1e155f9e 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1866,6 +1866,9 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) 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); diff --git a/src/events.c b/src/events.c index f6442956..1e39b67b 100644 --- a/src/events.c +++ b/src/events.c @@ -40,6 +40,7 @@ static unsigned int special_cursor_delay = 0; static unsigned int special_cursor_delay_value = 1000; static boolean virtual_button_pressed = FALSE; +static boolean stop_processing_events = FALSE; // forward declarations for internal use @@ -182,6 +183,11 @@ boolean NextValidEvent(Event *event) return FALSE; } +void StopProcessingEvents(void) +{ + stop_processing_events = TRUE; +} + static void HandleEvents(void) { Event event; @@ -190,6 +196,8 @@ static void HandleEvents(void) ResetDelayCounter(&event_frame_delay); + stop_processing_events = FALSE; + while (NextValidEvent(&event)) { switch (event.type) @@ -245,6 +253,10 @@ static void HandleEvents(void) // do not handle events for longer than standard frame delay period if (DelayReached(&event_frame_delay, event_frame_delay_value)) break; + + // do not handle any further events if triggered by a special flag + if (stop_processing_events) + break; } } diff --git a/src/events.h b/src/events.h index 3467e767..c061b5d2 100644 --- a/src/events.h +++ b/src/events.h @@ -22,6 +22,7 @@ int FilterMouseMotionEvents(void *, Event *); boolean NextValidEvent(Event *); +void StopProcessingEvents(void); void EventLoop(void); void HandleOtherEvents(Event *);