From 21d9467607c119bb2cdea7c7c27cb1300ccbe50b Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Sat, 8 Jul 2006 18:50:24 +0000 Subject: [PATCH] Fixed idle time counting. --- golded3/geutil.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/golded3/geutil.cpp b/golded3/geutil.cpp index 6345b9c..67de64f 100644 --- a/golded3/geutil.cpp +++ b/golded3/geutil.cpp @@ -654,12 +654,19 @@ void call_help() { // ------------------------------------------------------------------ -void CheckTick(gkey quitkey) { +void CheckTick(gkey quitkey) +{ + Clock idle_secs = gkbd.tickvalue - gkbd.tickpress; - Clock idle_secs = gkbd.tickvalue > gkbd.tickpress? (gkbd.tickvalue - gkbd.tickpress / 10L) : 0; + if (gkbd.tickvalue < gkbd.tickpress) + idle_secs = gkbd.tickpress - gkbd.tickvalue; - if(CFG->timeout) { - if(idle_secs >= CFG->timeout) { + idle_secs /= 10; + + if (CFG->timeout) + { + if (idle_secs >= CFG->timeout) + { kbput(quitkey); return; } @@ -693,11 +700,16 @@ void CheckTick(gkey quitkey) { // ------------------------------------------------------------------ -void IdleCheckSemaphores() { - +void IdleCheckSemaphores() +{ // I don't like this solution either... :( static Clock last_secs = 0; - Clock idle_secs = (gkbd.tickvalue - gkbd.tickpress) / 10L; + Clock idle_secs = gkbd.tickvalue - gkbd.tickpress; + + if (gkbd.tickvalue < gkbd.tickpress) + idle_secs = gkbd.tickpress - gkbd.tickvalue; + + idle_secs /= 10; // Make sure the stuff below is only run once in a second if(not idle_secs or (idle_secs - last_secs == 0))