]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Allow version-specific gametype support.
authorAnt Zucaro <azucaro@gmail.com>
Fri, 25 Jan 2013 22:41:38 +0000 (17:41 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Fri, 25 Jan 2013 22:41:38 +0000 (17:41 -0500)
It often happens when a gametype can't be supported because of
some random bug in the server code. This presents a problem
for when the bug is fixed, but servers still use the old code. We
can now specify that a game type is supported only after a certain
time by using version number restrictions. For example, CA is
supported, but only if the stats submission version is >= 5. Older
servers still having versions <= 5 won't record CA b/c they would
not pass this restriction.

xonstat/views/submission.py

index 56fa1fc7b10de588f361615d584daa5c76a41a45..8607a865d0065185b33e374450e540e9da2b657a 100644 (file)
@@ -95,15 +95,39 @@ def get_remote_addr(request):
         return request.remote_addr\r
 \r
 \r
-def is_supported_gametype(gametype):\r
+def is_supported_gametype(gametype, version):\r
     """Whether a gametype is supported or not"""\r
-    supported_game_types = ('duel', 'dm', 'ca', 'ctf', 'tdm', 'kh',\r
-            'ka', 'ft', 'freezetag', 'nb', 'nexball', 'lms')\r
+    is_supported = False\r
+\r
+    # if the type can be supported, but with version constraints, uncomment\r
+    # here and add the restriction for a specific version below\r
+    supported_game_types = (\r
+            'as',\r
+            'ca',\r
+            # 'cq',\r
+            # 'cts',\r
+            'dm',\r
+            'dom',\r
+            'ft', 'freezetag',\r
+            'ka', 'keepaway',\r
+            'kh',\r
+            # 'lms',\r
+            'nb', 'nexball',\r
+            # 'rc',\r
+            'rune',\r
+            'tdm',\r
+        )\r
 \r
     if gametype in supported_game_types:\r
-        return True\r
+        is_supported = True\r
     else:\r
-        return False\r
+        is_supported = False\r
+\r
+    # some game types were buggy before revisions, thus this additional filter\r
+    if gametype == 'ca' and version <= 5:\r
+        is_supported = False\r
+\r
+    return is_supported\r
 \r
 \r
 def verify_request(request):\r
@@ -137,14 +161,20 @@ def verify_request(request):
 def do_precondition_checks(request, game_meta, raw_players):\r
     """Precondition checks for ALL gametypes.\r
        These do not require a database connection."""\r
-    if not is_supported_gametype(game_meta['G']):\r
-        log.debug("ERROR: Unsupported gametype")\r
-        raise pyramid.httpexceptions.HTTPOk("OK")\r
-\r
     if not has_required_metadata(game_meta):\r
         log.debug("ERROR: Required game meta missing")\r
         raise pyramid.httpexceptions.HTTPUnprocessableEntity("Missing game meta")\r
 \r
+    try:\r
+        version = int(game_meta['V'])\r
+    except:\r
+        log.debug("ERROR: Required game meta invalid")\r
+        raise pyramid.httpexceptions.HTTPUnprocessableEntity("Invalid game meta")\r
+\r
+    if not is_supported_gametype(game_meta['G'], version):\r
+        log.debug("ERROR: Unsupported gametype")\r
+        raise pyramid.httpexceptions.HTTPOk("OK")\r
+\r
     if not has_minimum_real_players(request.registry.settings, raw_players):\r
         log.debug("ERROR: Not enough real players")\r
         raise pyramid.httpexceptions.HTTPOk("OK")\r