]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Add a new blank game check for CTS.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 26 Jan 2013 17:06:23 +0000 (12:06 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 26 Jan 2013 17:06:23 +0000 (12:06 -0500)
xonstat/views/submission.py

index 7e19063b2afca570bd8da03a67482389cc45a7e9..482fae5b87c977a702ea6bd6bdb1071924aef50d 100644 (file)
@@ -63,18 +63,24 @@ def parse_stats_submission(body):
     return (game_meta, players)\r
 \r
 \r
-def is_blank_game(players):\r
+def is_blank_game(gametype, players):\r
     """Determine if this is a blank game or not. A blank game is either:\r
 \r
     1) a match that ended in the warmup stage, where accuracy events are not\r
-    present\r
+    present (for non-CTS games)\r
 \r
     2) a match in which no player made a positive or negative score AND was\r
     on the scoreboard\r
+\r
+    ... or for CTS, which doesn't record accuracy events\r
+\r
+    1) a match in which no player made a fastest lap AND was\r
+    on the scoreboard\r
     """\r
     r = re.compile(r'acc-.*-cnt-fired')\r
     flg_nonzero_score = False\r
     flg_acc_events = False\r
+    flg_fastest_lap = False\r
 \r
     for events in players:\r
         if is_real_player(events) and played_in_game(events):\r
@@ -83,8 +89,13 @@ def is_blank_game(players):
                     flg_nonzero_score = True\r
                 if r.search(key):\r
                     flg_acc_events = True\r
+                if key == 'scoreboard-fastest':\r
+                    flg_fastest_lap = True\r
 \r
-    return not (flg_nonzero_score and flg_acc_events)\r
+    if gametype == 'cts':\r
+        return not flg_fastest_lap\r
+    else:\r
+        return not (flg_nonzero_score and flg_acc_events)\r
 \r
 \r
 def get_remote_addr(request):\r
@@ -105,7 +116,7 @@ def is_supported_gametype(gametype, version):
             'as',\r
             'ca',\r
             # 'cq',\r
-            'cts',\r
+            'cts',\r
             'dm',\r
             'dom',\r
             'ft', 'freezetag',\r
@@ -179,7 +190,7 @@ def do_precondition_checks(request, game_meta, raw_players):
         log.debug("ERROR: Not enough real players")\r
         raise pyramid.httpexceptions.HTTPOk("OK")\r
 \r
-    if is_blank_game(raw_players):\r
+    if is_blank_game(game_meta['G'], raw_players):\r
         log.debug("ERROR: Blank game")\r
         raise pyramid.httpexceptions.HTTPOk("OK")\r
 \r