Beispiel #1
0
        public static void Move(MapleClient c, MapleInventoryType type, short src, short dst)
        {
            byte srcSlot = (byte)src;
            byte dstSlot = (byte)dst;

            if (srcSlot > 127 || dstSlot > 127 || srcSlot > c.Player.Inventorys[type.Value].SlotLimit || dstSlot > c.Player.Inventorys[type.Value].SlotLimit)
            {
                return;
            }
            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;
            IMapleItem source;
            IMapleItem initialTarget;

            if (!c.Player.Inventorys[type.Value].Inventory.TryGetValue(srcSlot, out source))
            {
                return;
            }
            short olddstQ = -1;

            if (c.Player.Inventorys[type.Value].Inventory.TryGetValue(dstSlot, out initialTarget))
            {
                olddstQ = initialTarget.Quantity;
            }
            short oldsrcQ = source.Quantity;
            short slotMax = ii.GetSlotMax(c, source.ItemId);
            bool  op      = c.Player.Inventorys[type.Value].Move(srcSlot, dstSlot, slotMax);

            if (!op)
            {
                c.Send(PacketCreator.EnableActions());
                return;
            }
            if (type != MapleInventoryType.Equip && initialTarget != null && initialTarget.ItemId == source.ItemId && !ii.IsThrowingStar(source.ItemId) && !ii.IsBullet(source.ItemId))
            {
                c.Send(olddstQ + oldsrcQ > slotMax
                    ? PacketCreator.MoveAndMergeWithRestInventoryItem(type, srcSlot, dstSlot,
                                                                      (short)((olddstQ + oldsrcQ) - slotMax), slotMax)
                    : PacketCreator.MoveAndMergeInventoryItem(type, srcSlot, dstSlot,
                                                              ((Item)c.Player.Inventorys[type.Value].Inventory[dstSlot]).Quantity));
            }
            else
            {
                c.Send(PacketCreator.MoveInventoryItem(type, src, dst, 0));
            }
        }