public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            eBageType bagType   = (eBageType)packet.ReadByte();
            int       place     = packet.ReadInt();
            eBageType tobagType = (eBageType)packet.ReadByte();
            int       result;

            if (tobagType == eBageType.TempBag)
            {
                GameServer.log.Error("User want to put item into temp bag!");
                result = 0;
            }
            else
            {
                int             toplace = packet.ReadInt();
                int             count   = packet.ReadInt();
                PlayerInventory bag     = player.GetInventory(bagType);
                PlayerInventory tobag   = player.GetInventory(tobagType);
                if (tobagType == eBageType.TempBag)
                {
                    result = 0;
                }
                else
                {
                    bag.BeginChanges();
                    tobag.BeginChanges();
                    try
                    {
                        if (place != -1)
                        {
                            ItemInfo item = bag.GetItemAt(place);
                            if (tobagType == eBageType.Bank)
                            {
                                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                                if (info != null)
                                {
                                    tobag.Capalility = info.StoreLevel * 10;
                                }
                            }
                            if (toplace == -1)
                            {
                                if (tobag.StackItemToAnother(item) || tobag.AddItem(item))
                                {
                                    bag.TakeOutItem(item);
                                }
                                else
                                {
                                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                                }
                            }
                            else
                            {
                                if (bagType == tobagType)
                                {
                                    bag.MoveItem(place, toplace, count);
                                }
                                else
                                {
                                    if (bagType == eBageType.HideBag)
                                    {
                                        this.MoveFromHide(player, bag, item, toplace, tobag, count);
                                    }
                                    else
                                    {
                                        if (tobagType == eBageType.HideBag)
                                        {
                                            this.MoveToHide(player, bag, item, toplace, tobag, count);
                                        }
                                        else
                                        {
                                            if (bagType == eBageType.Bank)
                                            {
                                                UserChangeItemPlaceHandler.MoveFromBank(player, place, toplace, bag, tobag, item);
                                            }
                                            else
                                            {
                                                if (tobagType == eBageType.Bank)
                                                {
                                                    UserChangeItemPlaceHandler.MoveToBank(place, toplace, bag, tobag, item);
                                                }
                                                else
                                                {
                                                    if (tobag.AddItemTo(item, toplace))
                                                    {
                                                        bag.TakeOutItem(item);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (toplace != -1)
                            {
                                bag.RemoveItemAt(toplace, eItemRemoveType.Delete);
                            }
                        }
                    }
                    finally
                    {
                        bag.CommitChanges();
                        tobag.CommitChanges();
                    }
                    result = 0;
                }
            }
            return(result);
        }
Esempio n. 2
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType eBageType  = (eBageType)packet.ReadByte();
            int       num        = packet.ReadInt();
            eBageType eBageType2 = (eBageType)packet.ReadByte();
            int       num2       = packet.ReadInt();
            int       num3       = packet.ReadInt();

            packet.ReadBoolean();
            PlayerInventory inventory  = client.Player.GetInventory(eBageType);
            PlayerInventory inventory2 = client.Player.GetInventory(eBageType2);
            ItemInfo        itemAt     = inventory.GetItemAt(num);

            if (eBageType2 == eBageType.TempBag)
            {
                GameServer.log.Error("User want to put item into temp bag!");
                return(0);
            }
            if (inventory == null || itemAt == null)
            {
                return(0);
            }
            ItemInfo itemAt2 = inventory2.GetItemAt(num2);

            if (itemAt2 != null)
            {
                if (itemAt2.ItemID == itemAt.ItemID)
                {
                    GameServer.log.Error(string.Concat(new string[]
                    {
                        "Hack Trung ItemID ",
                        client.Player.PlayerCharacter.UserName,
                        "-[",
                        client.Player.PlayerCharacter.NickName,
                        "]"
                    }));
                    client.Disconnect();//kick user hack
                    return(0);
                }
                if (inventory == inventory2 && itemAt2.Place == itemAt.Place)
                {
                    GameServer.log.Error(string.Concat(new string[]
                    {
                        "Hack Trung PLace ",
                        client.Player.PlayerCharacter.UserName,
                        "-[",
                        client.Player.PlayerCharacter.NickName,
                        "]"
                    }));
                    return(0);
                }
            }
            if (num3 < 0 || num3 > itemAt.Count)
            {
                num3 = itemAt.Count;
            }
            inventory.BeginChanges();
            inventory2.BeginChanges();
            try
            {
                if (eBageType2 == eBageType.Consortia)
                {
                    ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    if (consortiaInfo != null)
                    {
                        inventory2.Capalility = consortiaInfo.StoreLevel * 10;
                    }
                }
                if (num2 == -1)
                {
                    bool flag = false;
                    if (eBageType == eBageType.CaddyBag && eBageType2 == eBageType.BeadBag)
                    {
                        num2 = inventory2.FindFirstEmptySlot();
                        if (inventory2.AddItemTo(itemAt, num2))
                        {
                            inventory.TakeOutItem(itemAt);
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        if (eBageType == eBageType2 && eBageType2 == eBageType.MainBag)
                        {
                            num2 = inventory2.FindFirstEmptySlot();
                            if (!inventory.MoveItem(num, num2, num3))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            if (inventory2.StackItemToAnother(itemAt) || inventory2.AddItem(itemAt))
                            {
                                inventory.TakeOutItem(itemAt);
                            }
                            else
                            {
                                flag = true;
                            }
                        }
                    }
                    if (flag)
                    {
                        client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                    }
                }
                else
                {
                    if (eBageType == eBageType2)
                    {
                        inventory.MoveItem(num, num2, num3);
                        client.Player.OnNewGearEvent(itemAt.Template.CategoryID);
                    }
                    else
                    {
                        if (eBageType == eBageType.Store)
                        {
                            this.MoveFromStore(client, inventory, itemAt, num2, inventory2, num3);
                        }
                        else
                        {
                            if (eBageType == eBageType.Consortia)
                            {
                                UserChangeItemPlaceHandler.MoveFromBank(client, num, num2, inventory, inventory2, itemAt);
                            }
                            else
                            {
                                if (eBageType2 == eBageType.Store)
                                {
                                    this.MoveToStore(client, inventory, itemAt, num2, inventory2, num3);
                                }
                                else
                                {
                                    if (eBageType2 == eBageType.Consortia)
                                    {
                                        UserChangeItemPlaceHandler.MoveToBank(num, num2, inventory, inventory2, itemAt);
                                    }
                                    else
                                    {
                                        if (inventory2.AddItemTo(itemAt, num2))
                                        {
                                            inventory.TakeOutItem(itemAt);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                inventory.CommitChanges();
                inventory2.CommitChanges();
            }
            return(0);
        }