Пример #1
0
 def add_client(self, client):
     try:
         existing_clients = self.clients.values()
         
         self.clients[client.cn] = client
         
         self.gamemode.on_client_connected(self, client)
         
         # Connect up all the client signals
         client.connect_all_instance_signals(self, "on_client_")
         
         # Tell the client about the status of the room
         with client.sendbuffer(1, True) as cds: 
             swh.put_welcome(cds, self.hasmap)
             
             if self.map_name != None:
                 swh.put_mapchange(cds, self.map_name, self.mode_num, self.hasitems)
                 
                 if self.gamemode.timed and self.match_end_time is not None:
                     swh.put_timeup(cds, self.timeleft)
                     
             if self.gamemode.hasitems and self.hasitems:
                 swh.put_itemlist(cds, self.items)
             
             swh.put_resume(cds, existing_clients)
             swh.put_initclients(cds, existing_clients)
         
         # Tell the other clients about the newcomer
         with self.broadcastbuffer(1, True, [client]) as cds:
             swh.put_resume(cds, [client])
             swh.put_initclients(cds, [client])
         
         if len(existing_clients) > 0:
             client.send_spawn_state(self.gamemode)
         
     except:
         traceback.print_exc()