]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Compute the number of real players during parsing.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 28 Jan 2017 15:15:48 +0000 (10:15 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 28 Jan 2017 15:15:48 +0000 (10:15 -0500)
xonstat/views/submission.py

index 81e639e531fcf0f0ba0894ad79fce080614a7100..6fa73400ecc5c40d224c3fd2cd57e6cbdc89cf2a 100644 (file)
@@ -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):