diff options
| author | Connor Thomson <blumatrikz@gmail.com> | 2026-09-08 18:27:39 -0700 |
|---|---|---|
| committer | Connor Thomson <blumatrikz@gmail.com> | 2026-09-08 18:27:39 -0700 |
| commit | f1ddc12b68b4e4c8087962de25260470e6df2bea (patch) | |
| tree | 7d0440a6402a9b0ef75ded23fa64b68534255bba /src/base/protect.c | |
| parent | 6025860a61386bf767b29c3ec5fd0d31285f1056 (diff) | |
Add tuxanci2 files
Diffstat (limited to 'src/base/protect.c')
| -rw-r--r-- | src/base/protect.c | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/base/protect.c b/src/base/protect.c deleted file mode 100644 index 754fa26..0000000 --- a/src/base/protect.c +++ /dev/null @@ -1,86 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - -#include "main.h" -#include "myTimer.h" -#include "protect.h" - -protect_t *newProtect() -{ - protect_t *new; - - new = malloc(sizeof(protect_t)); - new->lastMove = timer_get_current_time(); - new->lastPing = timer_get_current_time(); - new->avarage = 0; - new->count = 0; - new->isDown = FALSE; - - return new; -} - -void refreshLastMove(protect_t *p) -{ - my_time_t currentTime; - my_time_t interval; - - currentTime = timer_get_current_time(); - interval = currentTime - p->lastMove; - - p->lastMove = timer_get_current_time(); - p->avarage += interval; - p->count++; - - if (p->count == PROTECT_SPEED_AVARAGE) { - int my_index; - - my_index = p->avarage / PROTECT_SPEED_AVARAGE; - p->avarage = 0; - p->count = 0; - -/* - if (my_index < PROTECT_SPEED_INTERVAL_TIMEOUT) { - p->isDown = TRUE; - } -*/ - - /*printf("speed index = %d\n", my_index);*/ - } -} - -void rereshLastPing(protect_t *p) -{ - /* - my_time_t currentTime; - my_time_t interval; - currentTime = timer_get_current_time(); - interval = currentTime - p->lastPing; - */ - - p->lastPing = timer_get_current_time(); - - /*printf("interval = %d\n", interval);*/ -} - -bool_t isDown(protect_t *p) -{ - my_time_t currentTime; - my_time_t interval; - - currentTime = timer_get_current_time(); - interval = currentTime - p->lastPing; - - if (interval > PROTECT_PING_INTERVAL_TIMEOUT) { - p->isDown = TRUE; - } - - return p->isDown; -} - -void destroyProtect(protect_t *p) -{ - assert(p != NULL); - free(p); -} |