Example #1
0
        public ItemErrorNo SetItem(eWoW.SlotID id, Item newItem)
        {
            if ((int)id >= items.Length)
            {
                return(ItemErrorNo.WRONG_SLOT);
            }

            items[(int)id] = newItem;
            if (newItem != null)
            {
                SetUpdateValue(UpdateFields.CONTAINER_FIELD_SLOT_1 + (ushort)((byte)id * 2), newItem.GUID);
            }
            else
            {
                SetUpdateValue(UpdateFields.CONTAINER_FIELD_SLOT_1 + (ushort)((byte)id * 2), (ulong)0);
            }
            return(ItemErrorNo.NONE);
        }
Example #2
0
        public ItemErrorNo SetItem(eWoW.SlotID id, Item newItem)
        {
            if ((int)id >= items.Length)
            {
                return(ItemErrorNo.WRONG_SLOT);
            }

            if (newItem != null)
            {
                if ((id >= SlotID.BAG1 && id <= SlotID.BAG4) || (id >= SlotID.BANKBAGS))
                {
                    if (!newItem.IsType(TYPE.CONTAINER))
                    {
                        return(ItemErrorNo.NOT_A_BAG);
                    }
                }

                if (newItem is IContainer && id > SlotID.BAG4)
                {
                    IContainer p = newItem as IContainer;
                    for (SlotID i = 0; i < p.ItemCount; i++)
                    {
                        if (p.GetItem(i) != null)
                        {
                            return(ItemErrorNo.BAG_IN_BAG);
                        }
                    }
                }

                if (id < SlotID.BAG1)                 // equip
                {
                    SlotID expect = WornSlot(newItem.WornType);

                    if (expect == SlotID.BANK && id < SlotID.BAG1)
                    {
                        return(ItemErrorNo.WRONG_EQ_SLOT);
                    }
                    if (expect != id)
                    {
                        bool ok = false;
                        if (expect == SlotID.FINGERL && id == SlotID.FINGERR)
                        {
                            ok = true;
                        }
                        if (expect == SlotID.TRINKETL && id == SlotID.TRINKETR)
                        {
                            ok = true;
                        }
                        if (newItem.WornType == WORN.H1 && id == SlotID.OFFHAND)
                        {
                            ok = true;
                        }
                        if (!ok)
                        {
                            return(ItemErrorNo.WRONG_EQ_SLOT);
                        }
                    }
                    if (newItem.WornType == WORN.H2 && id == SlotID.MAINHAND)                 // check offhand
                    {
                        if (items[(int)SlotID.OFFHAND] != null)
                        {
                            return(ItemErrorNo.WRONG_EQ_SLOT);
                        }
                    }
                }
            }


            items[(int)id] = newItem;
            if (newItem != null)
            {
                SetUpdateValue(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((byte)id * 2), newItem.GUID);
            }
            else
            {
                SetUpdateValue(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((byte)id * 2), (ulong)0);
            }

            if (id < SlotID.BAG1)
            {
                UpdateItemStats();
            }
            return(ItemErrorNo.NONE);
        }