示例#1
0
    def send_inventory_list(self, world_session):
        vendor_data, session = WorldDatabaseManager.creature_get_vendor_data(
            self.entry)
        item_count = len(vendor_data) if vendor_data else 0

        data = pack('<QB', self.guid, item_count)

        if item_count == 0:
            data += pack('<B', 0)
        else:
            item_query = pack('<I', len(vendor_data))
            for count, vendor_data_entry in enumerate(vendor_data):
                data += pack(
                    '<7I',
                    count + 1,  # m_muid, acts as slot counter.
                    vendor_data_entry.item,
                    vendor_data_entry.item_template.display_id,
                    0xFFFFFFFF if vendor_data_entry.maxcount <= 0 else
                    vendor_data_entry.maxcount,
                    vendor_data_entry.item_template.buy_price,
                    vendor_data_entry.item_template.
                    max_durability,  # Max durability (not implemented in 0.5.3).
                    vendor_data_entry.item_template.buy_count  # Stack count.
                )
                item_query += ItemManager.generate_query_details_data(
                    vendor_data_entry.item_template)

            # Send all vendor item query details.
            world_session.enqueue_packet(
                PacketWriter.get_packet(
                    OpCode.SMSG_ITEM_QUERY_MULTIPLE_RESPONSE, item_query))

        session.close()
        world_session.enqueue_packet(
            PacketWriter.get_packet(OpCode.SMSG_LIST_INVENTORY, data))
示例#2
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 4:  # Avoid handling empty item query packet.
            entry = unpack('<I', reader.data[:4])[0]
            if entry > 0:
                item_template = WorldDatabaseManager.ItemTemplateHolder.item_template_get_by_entry(entry)
                if item_template:
                    query_data = ItemManager.generate_query_details_data(item_template)
                    query_packet = PacketWriter.get_packet(OpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, query_data)
                    world_session.enqueue_packet(query_packet)

        return 0
示例#3
0
    def _gen_item_struct(self, item_entry, count):
        item_template = WorldDatabaseManager.ItemTemplateHolder.item_template_get_by_entry(item_entry)
        display_id = 0
        if item_template:
            display_id = item_template.display_id
            query_data = ItemManager.generate_query_details_data(item_template)
            self.player_mgr.enqueue_packet(PacketWriter.get_packet(OpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, query_data))

        item_data = pack(
            '<3I',
            item_entry,
            count,
            display_id
        )

        return item_data
    def handle(world_session, socket, reader):
        if len(reader.data
               ) >= 4:  # Avoid handling empty multiple item query packet.
            requested_item_count = unpack('<I', reader.data[:4])[0]
            if requested_item_count:
                found_items = 0
                item_query_data = b''
                for requested_item in range(requested_item_count):
                    entry = unpack(
                        '<I', reader.data[4 + (requested_item_count * 4):4])[0]
                    item_template = WorldDatabaseManager.ItemTemplateHolder.item_template_get_by_entry(
                        entry)
                    if item_template:
                        found_items += 1
                        item_query_data += ItemManager.generate_query_details_data(
                            item_template)

                if found_items:
                    data = pack(f'<I{len(item_query_data)}s', found_items,
                                item_query_data)
                    packet = PacketWriter.get_packet(
                        OpCode.SMSG_ITEM_QUERY_MULTIPLE_RESPONSE, data)
                    world_session.enqueue_packet(packet)
        return 0