From: Ant Zucaro Date: Sat, 28 Jan 2017 15:15:48 +0000 (-0500) Subject: Compute the number of real players during parsing. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8dc2c56824fdc1208f1609aef2d2d559b2fde63c;p=xonotic%2Fxonstat.git Compute the number of real players during parsing. --- diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 81e639e..6fa7340 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -38,6 +38,9 @@ class Submission(object): # distinct weapons that we have seen fired self.weapons = set() + # number of real players in the match + self.real_players = 0 + # the parsing deque (we use this to allow peeking) self.q = collections.deque(self.body.split("\n")) @@ -46,6 +49,8 @@ class Submission(object): try: items = self.q.popleft().strip().split(' ', 1) if len(items) == 1: + # Some keys won't have values, like 'L' records where the server isn't actually + # participating in any ladders. These can be safely ignored. return None, None else: return items @@ -87,6 +92,9 @@ class Submission(object): self.q.appendleft("{} {}".format(key, value)) break + if is_real_player(player) and played_in_game(player): + self.real_players += 1 + self.players.append(player) def parse_team(self, key, tid):