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
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