def update_entity(self, entity): reader = ByteReader(self.data) reader.skip(8) read_masked_data(entity, reader)
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()