From 957f3411170ca1d5f30ee2e2c4e25393195cce75 Mon Sep 17 00:00:00 2001 From: Dusan Durech Date: Tue, 11 Nov 2008 23:39:21 +0100 Subject: modification coding stile :) --- src/base/protect.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/base/protect.c') diff --git a/src/base/protect.c b/src/base/protect.c index e06c618..9661e32 100644 --- a/src/base/protect.c +++ b/src/base/protect.c @@ -11,12 +11,14 @@ protect_t *newProtect() { protect_t *new; + new = malloc(sizeof(protect_t)); new->lastMove = getMyTime(); new->lastPing = getMyTime(); new->avarage = 0; new->count = 0; new->isDown = FALSE; + return new; } @@ -27,9 +29,11 @@ void refreshLastMove(protect_t * p) currentTime = getMyTime(); interval = currentTime - p->lastMove; + p->lastMove = getMyTime(); p->avarage += interval; p->count++; + if (p->count == PROTECT_SPEED_AVARAGE) { int index; @@ -62,8 +66,10 @@ bool_t isDown(protect_t * p) currentTime = getMyTime(); interval = currentTime - p->lastPing; + if (interval > PROTECT_PING_INTERVAL_TIMEOUT) p->isDown = TRUE; + return p->isDown; } -- cgit v1.2.3