From 777a3a66f0757271651d9da3464d88c069e2cdef Mon Sep 17 00:00:00 2001 From: Uriziel Date: Fri, 29 Jun 2012 16:22:09 +0200 Subject: [PATCH] Better fix for division by 0 problem --- syncplay/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/server.py b/syncplay/server.py index 363b601..83f8489 100644 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -333,7 +333,7 @@ class SyncFactory(Factory): pmax = max(p for p,_ in watcher.time_offset_data) - pmin psum, pweights = 0, 0 for ping, offset in watcher.time_offset_data: - ping = 1-((ping-pmin)/pmax) if(pmax <> 0) else 0 + ping = 1-((ping-pmin)/pmax) if(pmax <> 0) else 1 pweights += ping psum += ping*offset watcher.time_offset = psum/pweights