summaryrefslogtreecommitdiff
path: root/src/client/interface.c
diff options
context:
space:
mode:
authorDusan Durech <dusan.d@centrum.sk>2008-11-02 00:19:32 +0100
committerDusan Durech <dusan.d@centrum.sk>2008-11-02 00:19:32 +0100
commite5373f92249cc2b8d2c8357ed514dcd26dc43969 (patch)
tree79312bef40d4c5abb845a493d155bad3aab3b86d /src/client/interface.c
parent4c77447a924530f5bad212e39535adb373d5bcf4 (diff)
Automatic filtration of short intervals going after long intervals (in timer)
Diffstat (limited to 'src/client/interface.c')
-rw-r--r--src/client/interface.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/client/interface.c b/src/client/interface.c
index 75efca9..f9fd0d5 100644
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -117,7 +117,6 @@ int initSDL()
srand((unsigned) time(NULL));
isInterfaceInit = TRUE;
- isSlowHack = FALSE;
return 0;
}
@@ -194,31 +193,46 @@ static void action_esc()
}
*/
-void activeSlowHack()
-{
- isSlowHack = TRUE;
-}
-
-static void slowHackRoutine()
+int hack_slow()
{
static time_t lastTime = 0;
+ static bool_t isSlowHack = FALSE;
+ time_t currentTime;
+
+ currentTime = getMyTime();
if( lastTime == 0 )
{
+ lastTime = currentTime;
+ return 0;
+ }
+
+ //printf("DEBUG: time interval %d\n", currentTime - lastTime);
+
+ if( isSlowHack == FALSE && currentTime - lastTime >= 100 )
+ {
+ printf("start slow hack (%d)\n", currentTime - lastTime);
+ isSlowHack = TRUE;
lastTime = getMyTime();
- return;
+ return 1;
}
- if( getMyTime() - lastTime >= 50 )
+ if( isSlowHack == TRUE && currentTime - lastTime >= 50 )
{
- lastTime = 0;
+ printf("stop slow hack (%d)\n", currentTime - lastTime);
isSlowHack = FALSE;
- return;
+ lastTime = getMyTime();
+ return 0;
}
- //printf("SLOW HACK : %d\n", (getMyTime() - lastTime));
+ if( isSlowHack == TRUE )
+ {
+ printf("hack time interval %d\n", currentTime - lastTime);
+ }
lastTime = getMyTime();
+
+ return isSlowHack;
}
int eventAction()
@@ -252,12 +266,11 @@ int eventAction()
case SDL_USEREVENT:
switch (event.user.code) {
case USR_EVT_TIMER:
- if( isSlowHack )
+ if( hack_slow() )
{
- slowHackRoutine();
break;
}
-
+
drawScreen();
eventScreen();
eventHotKey();