Ejemplo n.º 1
0
    def getGRFInfo(self, grfs, addr=None):
        p = DataPacket(0, const.PACKET_UDP_CLIENT_GET_NEWGRFS)
        p.send_uint8(len(grfs))
        for grf in grfs:
            p.send_something('4s16s', grf)
        self.sendMsg_UDP(p.command, p.data, addr=addr)
        p = self.receiveMsg_UDP(True, useaddr=not addr is None)
        if p is None:
            LOG.debug("unable to receive UDP packet")
            return None
        newgrfs = []
        if p.command == const.PACKET_UDP_SERVER_NEWGRFS:
            reply_count = p.recv_uint8()
            for i in range(0, reply_count):
                [grfid, md5sum] = p.recv_something('4s16s')
                grfname = p.recv_str()
                newgrfs.append([grfid, md5sum, grfname])

            LOG.debug("Got reply to grf request with %d grfs:" % reply_count)
            for grf in newgrfs:
                LOG.debug(" %s - %s - %s" % (grf[0].encode("hex"), grf[1].encode("hex"), grf[2]))
            
            if not addr is None:
                return p.addr, newgrfs
            else:
                return newgrfs
        else:
            raise _error.UnexpectedResponse("PACKET_UDP_CLIENT_GET_NEWGRFS", str(p.command))
Ejemplo n.º 2
0
    def getGRFInfo(self, grfs, addr=None):
        p = DataPacket(0, const.PACKET_UDP_CLIENT_GET_NEWGRFS)
        p.send_uint8(len(grfs))
        for grf in grfs:
            p.send_something('4s16s', grf)
        self.sendMsg_UDP(p.command, p.data, addr=addr)
        p = self.receiveMsg_UDP(True, useaddr=not addr is None)
        if p is None:
            LOG.debug("unable to receive UDP packet")
            return None
        newgrfs = []
        if p.command == const.PACKET_UDP_SERVER_NEWGRFS:
            reply_count = p.recv_uint8()
            for i in range(0, reply_count):
                [grfid, md5sum] = p.recv_something('4s16s')
                grfname = p.recv_str()
                newgrfs.append([grfid, md5sum, grfname])

            LOG.debug("Got reply to grf request with %d grfs:" % reply_count)
            for grf in newgrfs:
                LOG.debug(" %s - %s - %s" %
                          (grf[0].encode("hex"), grf[1].encode("hex"), grf[2]))

            if not addr is None:
                return p.addr, newgrfs
            else:
                return newgrfs
        else:
            raise _error.UnexpectedResponse("PACKET_UDP_CLIENT_GET_NEWGRFS",
                                            str(p.command))
Ejemplo n.º 3
0
 def ContentList_Request(self, type):
     if type == const.ContentType['END']:
         for t in const.ContentType:
             if t == 'BEGIN' or t == 'END': continue
             self.ContentList_Request(const.ContentType[t])
         return
     p = DataPacket(0, const.PACKET_CONTENT_CLIENT_INFO_LIST)
     p.send_uint8(type)
     p.send_uint32(version.generate_newgrf_version(1,1,0,False,0)) # XXX find better way?
     self.sendMsg_TCP(p.command, p.data)
Ejemplo n.º 4
0
 def ContentList_Request(self, type):
     if type == const.ContentType['END']:
         for t in const.ContentType:
             if t == 'BEGIN' or t == 'END': continue
             self.ContentList_Request(const.ContentType[t])
         return
     p = DataPacket(0, const.PACKET_CONTENT_CLIENT_INFO_LIST)
     p.send_uint8(type)
     p.send_uint32(version.generate_newgrf_version(
         1, 1, 0, False, 0))  # XXX find better way?
     self.sendMsg_TCP(p.command, p.data)