diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-15 18:35:48 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-15 18:35:48 +0000 |
| commit | b84b59153c587248ca8a6a94a6d93977e851233f (patch) | |
| tree | e13b33f09ee6ac130bb6045626618b1c5fc4d787 /src/myTimer.c | |
| parent | 6038f9434f1eb40caf7992ece9a3972e95a9fc11 (diff) | |
- moznost skompilovat public server bez GUI ( pomocou Makefile-publicServer )
port sa nastavuje ako ./publicserver --port <port>
- jeto iba prvotna verzia treba to este odladit a zostabilnit
git-svn-id: http://opensvn.csie.org/tuxanci_ng@18 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/myTimer.c')
| -rw-r--r-- | src/myTimer.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/myTimer.c b/src/myTimer.c index 1a73384..04abef0 100644 --- a/src/myTimer.c +++ b/src/myTimer.c @@ -2,12 +2,17 @@ #include <time.h> #include <assert.h> #include <stdlib.h> +#include <sys/time.h> +#include <signal.h> #include "main.h" -#include "interface.h" #include "list.h" #include "myTimer.h" +#ifndef BUBLIC_SERVER +#include "interface.h" +#endif + static list_t *listTime; static bool_t isTimerInit = FALSE; @@ -19,19 +24,37 @@ bool_t isMyTimerInicialized() void initTimer() { - assert( isInterfaceInicialized() == TRUE ); - listTime = newList(); isTimerInit = TRUE; } -int addTimer(void (*fce)(void *p), void *arg, int my_time) +my_time_t getMyTime() +{ + static struct timeval start; + struct timeval now; + static char first = '0'; + my_time_t ticks; + + if( first == '0' ) + { + gettimeofday(&start, NULL); + first = 'x'; + } + + gettimeofday(&now, NULL); + + ticks = (now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000; + + return ticks; +} + +int addTimer(void (*fce)(void *p), void *arg, my_time_t my_time) { static int new_id = 0; my_timer_t *new; - Uint32 currentTime; + my_time_t currentTime; - currentTime = SDL_GetTicks(); + currentTime = getMyTime(); new = malloc( sizeof(my_timer_t) ); assert( new != NULL ); @@ -50,9 +73,9 @@ void eventTimer() { int i; my_timer_t *thisTimer; - Uint32 currentTime; + my_time_t currentTime; - currentTime = SDL_GetTicks(); + currentTime = getMyTime(); for( i = 0 ; i < listTime->count ; i++ ) { |