示例#1
0
        /// <summary>
        /// Sends inventory items to the client.  If windowType is one of the client inventory windows then the client
        /// will display the window.  Once the window is displayed to the client all handling of items in the window
        /// is done in the move item request handlers
        /// </summary>
        /// <param name="items"></param>
        /// <param name="windowType"></param>
        protected override void SendInventoryItemsPartialUpdate(IDictionary <int, InventoryItem> items, eInventoryWindowType windowType)
        {
            //ChatUtil.SendDebugMessage(m_gameClient, string.Format("SendItemsPartialUpdate: windowType: {0}, {1}", windowType, items == null ? "nothing" : items[0].Name));

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.InventoryUpdate)))
            {
                GameVault houseVault = m_gameClient.Player.ActiveInventoryObject as GameVault;
                pak.WriteByte((byte)(items.Count));
                pak.WriteByte(0x00);                                                                                                               // new in 189b+, show shield in left hand
                pak.WriteByte((byte)((m_gameClient.Player.IsCloakInvisible ? 0x01 : 0x00) | (m_gameClient.Player.IsHelmInvisible ? 0x02 : 0x00))); // new in 189b+, cloack/helm visibility
                if (windowType == eInventoryWindowType.HouseVault && houseVault != null)
                {
                    pak.WriteByte((byte)(houseVault.Index + 1));                        // Add the vault number to the window caption
                }
                else
                {
                    pak.WriteByte((byte)((m_gameClient.Player.IsCloakHoodUp ? 0x01 : 0x00) | (int)m_gameClient.Player.ActiveQuiverSlot));                     //bit0 is hood up bit4 to 7 is active quiver
                }
                // ^ in 1.89b+, 0 bit - showing hooded cloack, if not hooded not show cloack at all ?
                pak.WriteByte(m_gameClient.Player.VisibleActiveWeaponSlots);
                pak.WriteByte((byte)windowType);
                foreach (var entry in items)
                {
                    pak.WriteByte((byte)(entry.Key));
                    WriteItemData(pak, entry.Value);
                }
                SendTCP(pak);
            }
        }
示例#2
0
        /// <summary>
        /// Legacy inventory update. This handler silently
        /// assumes that a slot on the client matches a slot on the server.
        /// </summary>
        /// <param name="slots"></param>
        /// <param name="preAction"></param>
        protected override void SendInventorySlotsUpdateRange(ICollection <int> slots, eInventoryWindowType windowType)
        {
            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.InventoryUpdate)))
            {
                GameVault houseVault = m_gameClient.Player.ActiveInventoryObject as GameVault;

                pak.WriteByte((byte)(slots == null ? 0 : slots.Count));
                pak.WriteByte(0);                                                                                                                  // CurrentSpeed & 0xFF (not used for player, only for NPC)
                pak.WriteByte((byte)((m_gameClient.Player.IsCloakInvisible ? 0x01 : 0x00) | (m_gameClient.Player.IsHelmInvisible ? 0x02 : 0x00))); // new in 189b+, cloack/helm visibility

                if (windowType == eInventoryWindowType.HouseVault && houseVault != null)
                {
                    pak.WriteByte((byte)(houseVault.Index + 1));                        // Add the vault number to the window caption
                }
                else
                {
                    pak.WriteByte((byte)((m_gameClient.Player.IsCloakHoodUp ? 0x01 : 0x00) | (int)m_gameClient.Player.ActiveQuiverSlot));                     //bit0 is hood up bit4 to 7 is active quiver
                }

                pak.WriteByte((byte)m_gameClient.Player.VisibleActiveWeaponSlots);
                pak.WriteByte((byte)windowType);

                if (slots != null)
                {
                    foreach (int updatedSlot in slots)
                    {
                        if (updatedSlot >= (int)eInventorySlot.Consignment_First && updatedSlot <= (int)eInventorySlot.Consignment_Last)
                        {
                            log.Error("PacketLib198:SendInventorySlotsUpdateBase - GameConsignmentMerchant inventory is no longer cached with player.  Use a Dictionary<int, InventoryItem> instead.");
                            pak.WriteByte((byte)(updatedSlot - (int)eInventorySlot.Consignment_First + (int)eInventorySlot.HousingInventory_First));
                        }
                        else
                        {
                            pak.WriteByte((byte)(updatedSlot));
                        }

                        WriteItemData(pak, m_gameClient.Player.Inventory.GetItem((eInventorySlot)(updatedSlot)));
                    }
                }

                SendTCP(pak);
            }
        }