示例#1
0
文件: server.py 项目: freeznet/cuwo
 def feed(self, data):
     self.data += data
     reader = ByteReader(self.data)
     while True:
         pos = reader.tell()
         if pos >= len(self.data):
             break
         try:
             packet = read_packet(reader, self.table)
         except OutOfData:
             break
         self.callback(packet)
     self.data = self.data[pos:]
示例#2
0
文件: packet.py 项目: lilezek/cuwo
 def update_entity(self, entity):
     reader = ByteReader(self.data)
     reader.skip(8)
     read_masked_data(entity, reader)
示例#3
0
文件: packet.py 项目: lilezek/cuwo
 def read(self, reader):
     size = reader.read_uint32()
     self.data = zlib.decompress(reader.read(size))
     reader = ByteReader(self.data)
     self.entity_id = reader.read_uint64()
示例#4
0
文件: packet.py 项目: lilezek/cuwo
 def read(self, reader):
     size = reader.read_uint32()
     self.data = zlib.decompress(reader.read(size))
     reader = ByteReader(self.data)
     items = reader.read_uint32()
示例#5
0
文件: packet.py 项目: CarlosX/cuwo
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = []
        for _ in xrange(reader.read_uint32()):
            item = Packet4Struct1() # 20 bytes
            item.read(reader)
            self.items_1.append(item)

        # on hit?
        self.items_2 = []
        for _ in xrange(reader.read_uint32()):
            
            self.items_2.append(reader.read(72))

        self.items_3 = []
        for _ in xrange(reader.read_uint32()):
            self.items_3.append(reader.read(72))

        # perform attack?
        self.items_4 = []
        for _ in xrange(reader.read_uint32()):
            self.items_4.append(reader.read(24))

        # shoot arrow?
        self.items_5 = []
        for _ in xrange(reader.read_uint32()):
            item = ShootPacket()
            item.read(reader)
            self.items_5.append(item)

        self.items_6 = []
        for _ in xrange(reader.read_uint32()):
            self.items_6.append(reader.read(88))

        self.items_7 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                item = EquipmentData()
                item.read(reader)
                data = reader.read(48)
                sub_items.append((item, data))
            self.items_7.append((something, sub_items))

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        # item picked up
        self.items_9 = []
        for _ in xrange(reader.read_uint32()):
            entity_id = reader.read_uint64()
            item = EquipmentData()
            item.read(reader)
            self.items_9.append((entity_id, item))

        # killed by, gives xp
        self.items_10 = []
        for _ in xrange(reader.read_uint32()):
            entity_id = reader.read_uint64() # killer
            target_id = reader.read_uint64() # killed
            # see below about padding
            reader.skip(4)
            xp_gained = reader.read_int32()
            self.items_10.append((entity_id, target_id, xp_gained))

        # set entity damage
        self.items_11 = []
        for _ in xrange(reader.read_uint32()):
            target_id = reader.read_uint64()
            entity_id = reader.read_uint64()
            damage = reader.read_float()
            # is this actually padding? copied as part of MOVQ, but may just be
            # optimization. not used in client, it seems.
            # could also be related to items_10, seems to use similar list
            # copy implementation
            reader.skip(4)
            self.items_11.append((target_id, entity_id, damage))

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        self.items_13 = []
        for _ in xrange(reader.read_uint32()):
            self.items_13.append(reader.read(56))

        debug = True
        if debug:
            v = vars(self).copy()
            del v['items_11']
            del v['items_10']
            del v['items_9']
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
示例#6
0
文件: packet.py 项目: xEnt22/cuwo
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.items_2 = read_list(reader, PlayerDamage)

        self.items_3 = []
        for _ in xrange(reader.read_uint32()):
            self.items_3.append(reader.read(72))

        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)

        self.items_6 = []
        for _ in xrange(reader.read_uint32()):
            self.items_6.append(reader.read(88))

        self.items_7 = read_list(reader, EntityAction)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        self.items_13 = []
        for _ in xrange(reader.read_uint32()):
            self.items_13.append(reader.read(56))

        debug = False
        if debug:
            v = vars(self).copy()
            del v['pickups']
            del v['kill_actions']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            del v['items_2']
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()