diff options
author | Florian Jung <flo@windfisch.org> | 2015-09-01 18:04:04 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-09-01 18:04:04 +0200 |
commit | ccd6387920432c9a8263a2b9813d552642e6546a (patch) | |
tree | 88e7d588af56e9bd6c71b608df07a1d0c49cee1f /subscriber.py | |
parent | 4251e85c172f57c39bdfa244e945578eb450926d (diff) |
FancyClient has latency detection and rates motion steadyness
Diffstat (limited to 'subscriber.py')
-rw-r--r-- | subscriber.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/subscriber.py b/subscriber.py index b89a6a9..6c2bcce 100644 --- a/subscriber.py +++ b/subscriber.py @@ -2,6 +2,8 @@ from log import log from collections import deque import sys import mechanics +import time +import math class DummySubscriber: def on_connect_error(self,s): @@ -114,6 +116,16 @@ class EnhancingSubscriber(DummySubscriber): if self.time % 100 == 0: self.cleanup_victims() + + + try: + angle = math.atan2(self.c.current_target[1] - self.c.player.center.y, self.c.current_target[0] - self.c.player.center.x) + except: + angle = 0 + + self.c.anglelog.append(angle) + + # create and purge poslog history, movement and movement_angle for cid in self.history: self.history[cid].stale = True @@ -135,6 +147,7 @@ class EnhancingSubscriber(DummySubscriber): if not hasattr(cell, "spawntime"): cell.spawntime = self.c.world.time + cell.spawnrealtime = time.time() try: oldpos = cell.poslog[-3-1] @@ -197,6 +210,9 @@ class EnhancingSubscriber(DummySubscriber): cell.shoot_vec = None cell.calmed_down = False + if cell.parent != None and cell.parent in self.c.player.own_cells: + # we have split. use this for lag calculation + self.c.report_actual_event("split", cell.spawnrealtime) elif cell.is_virus: try: if cell.parent == None and cell.movement.len() > 0: @@ -246,6 +262,11 @@ class EnhancingSubscriber(DummySubscriber): except: cell.shoot_vec = None cell.calmed_down = False + + if cell.parent != None and cell.parent in self.c.player.own_cells: + # we ejected mass. use this for lag calculation + self.c.report_actual_event("shoot", cell.spawnrealtime) + except ValueError: # if no possible parents are found, min will raise a ValueError. ignore that. pass |