Commits

Anonymous committed 568490d

Upgraded cupoftee to the latest TeeWorlds protocol changes

Comments (0)

Files changed (2)

examples/cupoftee/application.py

     def update_master(self):
         wait = self.interval
         while 1:
-            time.sleep(wait)
             if self.master.sync():
                 wait = self.interval
             else:
                 wait = self.interval // 2
+            time.sleep(wait)
 
     def dispatch_request(self, request):
         url_adapter = url_map.bind_to_environ(request.environ)

examples/cupoftee/network.py

 from cupoftee.utils import unicodecmp
 
 
-GAMETYPES = dict(enumerate(('dm', 'tdm', 'ctf')))
-
-
 class ServerError(Exception):
     pass
 
         to_delete = set(self.servers)
         for x in xrange(1, 17):
             addr = ('master%d.teeworlds.com' % x, 8300)
+            print addr
             try:
                 self._sync_master(addr, to_delete)
-            except (socket.error, socket.timeout, IOError):
+            except (socket.error, socket.timeout, IOError), e:
                 continue
         for server_id in to_delete:
             self.servers.pop(server_id, None)
         self.version, server_name, map_name = bits[:3]
         self.name = server_name.decode('latin1')
         self.map = map_name.decode('latin1')
-        self.gametype_id, self.flags, self.progression, player_count, \
-            self.max_players = map(int, bits[3:8])
-        self.gametype = GAMETYPES.get(self.gametype_id, 'unknown')
+        self.gametype = bits[3]
+        self.flags, self.progression, player_count, \
+            self.max_players = map(int, bits[4:8])
 
         # sync the player stats
         players = dict((p.name, p) for p in self.players)