From: Holger Schemel Date: Sat, 19 Mar 2016 14:24:20 +0000 (+0100) Subject: improved synchronization of main game loop X-Git-Tag: 4.0.0.0-rc1~48 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5d3436c34268fb35d378a39d9d825def453afbec;p=rocksndiamonds.git improved synchronization of main game loop --- diff --git a/src/events.c b/src/events.c index 7a03f33f..4c71dca0 100644 --- a/src/events.c +++ b/src/events.c @@ -161,8 +161,13 @@ void EventLoop(void) { if (PendingEvent()) /* got event */ { + // use separate frame delay counter to not reset main delay counter + unsigned int sync_frame_delay2 = 0; + unsigned int sync_frame_delay_value2 = sync_frame_delay_value; Event event; + ResetDelayCounter(&sync_frame_delay2); + while (NextValidEvent(&event)) { switch (event.type) @@ -209,11 +214,13 @@ void EventLoop(void) break; } - if (DelayReached(&sync_frame_delay, sync_frame_delay_value)) - BackToFront(); + // do not handle events for longer than standard frame delay period + if (DelayReached(&sync_frame_delay2, sync_frame_delay_value2)) + break; } } - else + + // always handle non-event game actions for every game frame interval { if (game_status == GAME_MODE_TITLE) {