public int HandlePacket(GameClient client, GSPacketIn packet) { if (998 <= client.Player.PlayerCharacter.Money) { ItemInfo item = this.getitem(client, 1, "", "", 1101801); ItemInfo item2 = this.getitem(client, 1, "", "", 1102001); ItemInfo item3 = this.getitem(client, 1, "", "", 1102401); ItemInfo item4 = this.getitem(client, 1, "", "", 1102401); ItemInfo item5 = this.getitem(client, 1, "", "", 1102401); PlayerInventory inventory = client.Player.GetInventory(eBageType.Store); client.Player.GetInventory(eBageType.PropBag); List <ItemInfo> items = inventory.GetItems(); foreach (ItemInfo arg_CA_0 in items) { } inventory.AddItemTo(item, 4); inventory.AddItemTo(item2, 3); inventory.AddItemTo(item3, 2); inventory.AddItemTo(item4, 1); inventory.AddItemTo(item5, 0); client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.Success", new object[0])); client.Player.RemoveMoney(998); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney", new object[0])); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (998 <= client.Player.PlayerCharacter.Money) { SqlDataProvider.Data.ItemInfo item = this.getitem(client, 1, "", "", 1101801); SqlDataProvider.Data.ItemInfo info2 = this.getitem(client, 1, "", "", 1102001); SqlDataProvider.Data.ItemInfo info3 = this.getitem(client, 1, "", "", 1102401); SqlDataProvider.Data.ItemInfo info4 = this.getitem(client, 1, "", "", 1102401); SqlDataProvider.Data.ItemInfo info5 = this.getitem(client, 1, "", "", 1102401); PlayerInventory bag = client.Player.GetInventory(eBageType.Store); PlayerInventory inventory = client.Player.GetInventory(eBageType.PropBag); List <SqlDataProvider.Data.ItemInfo> items = bag.GetItems(); foreach (SqlDataProvider.Data.ItemInfo info6 in items) { bag.MoveToStore(bag, info6.Place, inventory.FindFirstEmptySlot(0), inventory, 50); } bag.AddItemTo(item, 4); bag.AddItemTo(info2, 3); bag.AddItemTo(info3, 2); bag.AddItemTo(info4, 1); bag.AddItemTo(info5, 0); client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.Success", new object[0])); client.Player.RemoveMoney(998); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney", new object[0])); } return(0); }
private static void MoveToBank(int place, int toplace, PlayerInventory bag, PlayerInventory bank, ItemInfo item) { if (bag != null && item != null && bag != null) { ItemInfo toitem = bank.GetItemAt(toplace); if (toitem != null) { if (item.CanStackedTo(toitem) && item.Count + toitem.Count <= item.Template.MaxCount) { if (bank.AddCountToStack(toitem, item.Count)) { bag.RemoveItem(item, eItemRemoveType.Stack); } } else { if (toitem.Template.BagType == (eBageType)bag.BagType) { bag.TakeOutItem(item); bank.TakeOutItem(toitem); bag.AddItemTo(toitem, place); bank.AddItemTo(item, toplace); } } } else { if (bank.AddItemTo(item, toplace)) { bag.TakeOutItem(item); } } } }
private static void MoveFromBank(GameClient client, int place, int toplace, PlayerInventory bag, PlayerInventory tobag, ItemInfo item) { if (item != null) { PlayerInventory itemInventory = client.Player.GetItemInventory(item.Template); if (itemInventory == tobag) { ItemInfo itemAt = itemInventory.GetItemAt(toplace); if (itemAt == null) { if (itemInventory.AddItemTo(item, toplace)) { bag.TakeOutItem(item); return; } } else { if (!item.CanStackedTo(itemAt) || item.Count + itemAt.Count > item.Template.MaxCount) { itemInventory.TakeOutItem(itemAt); bag.TakeOutItem(item); itemInventory.AddItemTo(item, toplace); bag.AddItemTo(itemAt, place); return; } if (itemInventory.AddCountToStack(itemAt, item.Count)) { bag.RemoveItem(item, eItemRemoveType.Stack); return; } } } else { if (itemInventory.AddItem(item)) { bag.TakeOutItem(item); } } } }
private static void MoveFromBank(GamePlayer player, int place, int toplace, PlayerInventory bag, PlayerInventory tobag, ItemInfo item) { if (item != null) { PlayerInventory tb = player.GetItemInventory(item.Template); if (tb == tobag) { ItemInfo toitem = tb.GetItemAt(toplace); if (toitem == null) { if (tb.AddItemTo(item, toplace)) { bag.TakeOutItem(item); } } else { if (item.CanStackedTo(toitem) && item.Count + toitem.Count <= item.Template.MaxCount) { if (tb.AddCountToStack(toitem, item.Count)) { bag.RemoveItem(item, eItemRemoveType.Stack); } } else { tb.TakeOutItem(toitem); bag.TakeOutItem(item); tb.AddItemTo(item, toplace); bag.AddItemTo(toitem, place); } } } else { if (tb.AddItem(item)) { bag.TakeOutItem(item); } } } }
public void MoveFromStore(GameClient client, PlayerInventory storeBag, ItemInfo item, int toSlot, PlayerInventory bag, int count) { if (client.Player != null && item != null && storeBag != null && bag != null && item.Template.BagType == (eBageType)bag.BagType) { if (toSlot < bag.BeginSlot || toSlot > bag.Capalility) { if (bag.StackItemToAnother(item)) { storeBag.RemoveItem(item, eItemRemoveType.Stack); return; } string key = string.Format("temp_place_{0}", item.ItemID); if (client.Player.TempProperties.ContainsKey(key)) { toSlot = (int)storeBag.Player.TempProperties[key]; storeBag.Player.TempProperties.Remove(key); } else { toSlot = bag.FindFirstEmptySlot(); } } if (bag.StackItemToAnother(item) || bag.AddItemTo(item, toSlot)) { storeBag.TakeOutItem(item); return; } toSlot = bag.FindFirstEmptySlot(); if (bag.AddItemTo(item, toSlot)) { storeBag.TakeOutItem(item); return; } storeBag.TakeOutItem(item); client.Player.SendItemToMail(item, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]), LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]), eMailType.ItemOverdue); client.Player.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { PlayerInventory inventory = client.Player.GetInventory(eBageType.Store); PlayerInventory arg_19_0 = client.Player.PropBag; int num = 0; bool isBinds = true; for (int i = 1; i < 5; i++) { ItemInfo itemAt = inventory.GetItemAt(i); if (itemAt != null) { inventory.RemoveItemAt(i); } if (itemAt.IsBinds) { isBinds = true; } num += itemAt.Template.Quality; } int[] array = new int[] { 7015, 7016, 7017, 7018, 7019, 7021, 7022, 7023, 7048, 11041, 15019, 16015 }; Random random = new Random(); int num2 = random.Next(0, array.Length - 1); int templateId = array[num2]; ItemInfo itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(templateId), 1, 105); itemInfo.IsBinds = isBinds; itemInfo.BeginDate = DateTime.Now; if (itemInfo.Template.CategoryID != 11) { itemInfo.ValidDate = 7; } itemInfo.RemoveDate = DateTime.Now.AddDays(7.0); inventory.AddItemTo(itemInfo, 0); return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { PlayerInventory inventory = client.Player.GetInventory(eBageType.Store); PlayerInventory propBag = client.Player.PropBag; for (int i = 1; i < 5; i++) { if (inventory.GetItemAt(i) != null) { inventory.RemoveItemAt(i); } } int ItemRandom = ThreadSafeRandom.NextStatic(listItemRandom.Count); SqlDataProvider.Data.ItemInfo item = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(listItemRandom[ItemRandom]), 1, 105); inventory.AddItemTo(item, 0); return(1); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int count = packet.ReadInt(); PlayerInventory bag = player.GetInventory((eBageType)packet.ReadInt()); Dictionary <int, int> switches = new Dictionary <int, int>(); for (int i = 0; i < count; i++) { int old_place = packet.ReadInt(); int new_place = packet.ReadInt(); if (!switches.ContainsKey(old_place)) { switches.Add(old_place, new_place); } else { ArrangeBagHandler.log.Error(string.Format("client:{0} error client data,index already exist in the dics.", player.PlayerId)); } } int result2; if (switches.Count != bag.GetItems(bag.BeginSlot, bag.Capalility - 1).Count) { result2 = 0; } else { Dictionary <int, ItemInfo> rawitems = bag.GetRawSpaces(); bag.BeginChanges(); bool result = false; try { bag.Clear(bag.BeginSlot, bag.Capalility - 1); foreach (KeyValuePair <int, int> sp in switches) { if (sp.Key < bag.BeginSlot || sp.Value < bag.BeginSlot) { throw new Exception(string.Format("can't operate that place: old {0} new {1}", sp.Key, sp.Value)); } ItemInfo it = rawitems[sp.Key]; if (!bag.AddItemTo(it, sp.Value)) { throw new Exception(string.Format("move item error: old place:{0} new place:{1}", sp.Key, sp.Value)); } } result = true; } catch (Exception ex) { ArrangeBagHandler.log.ErrorFormat("Arrange bag errror,user id:{0} msg:{1}", player.PlayerId, ex.Message); } finally { if (!result) { bag.Clear(0, bag.Capalility - 1); foreach (KeyValuePair <int, ItemInfo> sp2 in rawitems) { bag.AddItemTo(sp2.Value, sp2.Key); } } bag.CommitChanges(); } result2 = 0; } return(result2); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bageType = (eBageType)packet.ReadByte(); int slot = packet.ReadInt(); eBageType toBageType = (eBageType)packet.ReadByte(); int toSlot = packet.ReadInt(); int count = packet.ReadInt(); PlayerInventory bag = client.Player.GetInventory(bageType); PlayerInventory inventory = client.Player.GetInventory(toBageType); if (toSlot < 0) { if ((inventory.BagType == (int)eBageType.Bank) || (inventory.BagType == (int)eBageType.PropBag)) { toSlot = inventory.FindFirstEmptySlot(0); } else { toSlot = inventory.FindFirstEmptySlot(31); } } //================================== if (count > 0) { if ((bag == null) || (bag.GetItemAt(slot) == null)) { return(0); } if ((bageType == toBageType) && (slot != -1)) { if (bag.GetItemAt(slot).Count >= count) { Console.WriteLine("-----Stage 1 !"); bag.MoveItem(slot, toSlot, count); } else { Console.WriteLine("--" + client.Player.Account + " Hack = CE"); bag.MoveItem(slot, toSlot, bag.GetItemAt(slot).Count); } return(1); } if ((slot == -1) && (toSlot != -1)) { Console.WriteLine("-----Stage 2 !"); bag.RemoveItemAt(toSlot); return(1); } if (((((slot != -1) && (toSlot == -1)) && ((bageType != eBageType.CaddyBag) && (toBageType != eBageType.Bank))) && (bageType != eBageType.Store)) && (toBageType != eBageType.Store)) { if (bageType == eBageType.MainBag) { Console.WriteLine("-----Stage 3 !"); bag.AddItem(client.Player.GetItemAt(bageType, slot), 31); } else { Console.WriteLine("-----Stage 4 !"); //bag.AddItem(client.Player.GetItemAt(bageType, slot), 0); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Full")); } return(1); } if ((((slot != -1) && (toBageType != bageType)) && (toBageType != eBageType.Store)) && (toBageType != eBageType.MainBag)) { ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); if (info != null) { if (toBageType == eBageType.Store) { } Console.WriteLine("-----Stage 5 !"); bag.MoveToStore(bag, slot, toSlot, inventory, info.StoreLevel * 10); return(1); } } if ((toBageType == eBageType.Store) || (bageType == eBageType.Store)) { SqlDataProvider.Data.ItemInfo itemAt = client.Player.GetItemAt(bageType, slot); if ((itemAt != null) && (itemAt.Count > 1)) { itemAt.Count -= count; bag.UpdateItem(itemAt); SqlDataProvider.Data.ItemInfo item = itemAt.Clone(); item.Count = count; if (inventory.GetItemAt(toSlot) == null) { Console.WriteLine("-----Stage 6 !"); inventory.AddItemTo(item, toSlot); } else { SqlDataProvider.Data.ItemInfo itemByTemplateID = bag.GetItemByTemplateID(0, inventory.GetItemAt(toSlot).TemplateID); if (itemByTemplateID == null) { Console.WriteLine("-----Stage 7 !"); bag.MoveToStore(inventory, toSlot, bag.FindFirstEmptySlot(0), bag, 999); } else { Console.WriteLine("-----Stage 8 !"); itemByTemplateID.Count++; bag.UpdateItem(itemByTemplateID); inventory.RemoveItemAt(toSlot); } Console.WriteLine("-----Stage 9 !"); inventory.AddItemTo(item, toSlot); } } else { if ((((toBageType != eBageType.Store) && (toBageType != eBageType.MainBag)) && ((bag.GetItemAt(slot) != null) && (bag.GetItemAt(slot).Template.CategoryID == 7))) && (((toSlot > 0) && (toSlot < 31)) && (toSlot != 6))) { return(1); } try { Console.WriteLine("-----Stage 10 !"); bag.MoveToStore(bag, slot, toSlot, inventory, 50); } catch (Exception) { LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", new object[] { slot, toSlot, bageType, toBageType }); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(slot), inventory.GetItemAt(toSlot)); } } return(1); } if ((toBageType == eBageType.MainBag) && (bageType == eBageType.Bank)) { Console.WriteLine("-----Stage 11!"); bag.MoveToStore(bag, slot, toSlot, inventory, 50); return(1); } } //================================== return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } int num = (int)packet.ReadByte(); bool flag = false; int num2 = 0; bool flag2 = false; ItemTemplateInfo itemTemplateInfo = null; StringBuilder stringBuilder = new StringBuilder(); int num3 = 2147483647; List <ItemInfo> list = new List <ItemInfo>(); List <ItemInfo> appendItems = new List <ItemInfo>(); PlayerInventory storeBag = client.Player.StoreBag; ItemInfo item = null; string beginProperty = null; string addItem = ""; int num4 = 0; for (int i = 1; i < 5; i++) { ItemInfo itemAt = storeBag.GetItemAt(i); if (itemAt != null) { if (list.Contains(itemAt)) { client.Out.SendMessage(eMessageType.Normal, "Bad Input 1"); return(1); } stringBuilder.Append(string.Concat(new object[] { itemAt.ItemID, ":", itemAt.TemplateID, "," })); list.Add(itemAt); if (itemAt.ValidDate != 0 && itemAt.ValidDate >= num4) { num3 = itemAt.ValidDate; } num4 = itemAt.ValidDate; } } switch (num) { case 0: { flag = false; Dictionary <int, double> dictionary = FusionMgr.FusionPreview(list, appendItems, ref flag); if (dictionary != null && dictionary.Count > 0) { if (dictionary.Count != 0) { client.Out.SendFusionPreview(client.Player, dictionary, flag, num3); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.ItemNotEnough", new object[0])); } return(0); } case 1: num2 = 1600; if (client.Player.PlayerCharacter.Gold < num2) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.NoMoney", new object[0])); return(0); } flag = false; flag2 = false; itemTemplateInfo = FusionMgr.Fusion(list, appendItems, ref flag, ref flag2); break; } int num5 = client.Player.MainBag.FindFirstEmptySlot(); int num6 = client.Player.PropBag.FindFirstEmptySlot(); if ((num5 == -1 && itemTemplateInfo.BagType == eBageType.MainBag) || (num6 == -1 && itemTemplateInfo.BagType == eBageType.PropBag)) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0])); return(0); } if (itemTemplateInfo != null) { client.Player.RemoveGold(num2); for (int j = 1; j < 5; j++) { ItemInfo itemAt2 = storeBag.GetItemAt(j); if (itemAt2.Count > 1) { itemAt2.Count--; storeBag.UpdateItem(itemAt2); } else { storeBag.RemoveItem(itemAt2); } } if (flag2) { stringBuilder.Append(itemTemplateInfo.TemplateID + ","); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 105); if (itemInfo == null) { return(0); } item = itemInfo; itemInfo.IsBinds = flag; itemInfo.ValidDate = num3; client.Player.OnItemFusion(itemInfo.Template.FusionType); client.Out.SendFusionResult(client.Player, flag2); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Succeed1", new object[0]) + " " + itemInfo.Template.Name); if ((itemInfo.TemplateID >= 8300 && itemInfo.TemplateID <= 8999) || (itemInfo.TemplateID >= 9300 && itemInfo.TemplateID <= 9999) || (itemInfo.TemplateID >= 14300 && itemInfo.TemplateID <= 14999) || (itemInfo.TemplateID >= 7024 && itemInfo.TemplateID <= 7028) || (itemInfo.TemplateID >= 14006 && itemInfo.TemplateID <= 14010) || (itemInfo.TemplateID >= 17000 && itemInfo.TemplateID <= 17010)) { string translation = LanguageMgr.GetTranslation("ItemFusionHandler.Notice", new object[] { client.Player.PlayerCharacter.NickName, itemInfo.Template.Name }); client.Player.SendAllMessage(translation); } if (!storeBag.AddItemTo(itemInfo, 0)) { stringBuilder.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0])); } } else { stringBuilder.Append("false"); client.Out.SendFusionResult(client.Player, flag2); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Failed", new object[0])); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Fusion, beginProperty, item, addItem, Convert.ToInt32(flag2)); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.NoCondition", new object[0])); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); int bageType = packet.ReadInt(); int templateId = packet.ReadInt(); int place = packet.ReadInt(); int bagType = packet.ReadInt(); int templateId2 = packet.ReadInt(); PlayerInventory inventory = client.Player.GetInventory((eBageType)bageType); ItemInfo itemInfo = inventory.GetItemAt(num); client.Player.GetItemAt((eBageType)bagType, place); double num2 = 5.0; GoldEquipTemplateLoadInfo goldEquipTemplateLoadInfo = GoldEquipMgr.FindGoldEquipTemplate(templateId); GSPacketIn gSPacketIn = new GSPacketIn(106, client.Player.PlayerCharacter.ID); if (goldEquipTemplateLoadInfo == null && itemInfo.Template.CategoryID == 7) { gSPacketIn.WriteInt(5); } else { if (!itemInfo.IsGold) { if (num2 > (double)WishBeadEquipHandler.random.Next(100)) { itemInfo.StrengthenLevel++; itemInfo.IsGold = true; itemInfo.goldBeginTime = DateTime.Now; itemInfo.goldValidDate = 30; itemInfo.IsBinds = true; if (goldEquipTemplateLoadInfo != null && itemInfo.Template.CategoryID == 7) { ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(goldEquipTemplateLoadInfo.NewTemplateId); if (itemTemplateInfo != null) { ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116); itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel; itemInfo2.IsGold = itemInfo.IsGold; itemInfo2.goldBeginTime = itemInfo.goldBeginTime; itemInfo2.goldValidDate = itemInfo.goldValidDate; itemInfo2.IsBinds = itemInfo.IsBinds; ItemInfo.OpenHole(ref itemInfo2); StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2); inventory.RemoveItemAt(num); inventory.AddItemTo(itemInfo2, num); itemInfo = itemInfo2; } } inventory.UpdateItem(itemInfo); gSPacketIn.WriteInt(0); inventory.SaveToDatabase(); } else { gSPacketIn.WriteInt(1); } client.Player.RemoveTemplate(templateId2, 1); } else { gSPacketIn.WriteInt(6); } } client.Out.SendTCP(gSPacketIn); return(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); }
public void MoveToStore(GameClient client, PlayerInventory bag, ItemInfo item, int toSlot, PlayerInventory storeBag, int count) { if (client.Player != null && bag != null && item != null && storeBag != null) { int place = item.Place; ItemInfo itemAt = storeBag.GetItemAt(toSlot); if (itemAt != null) { if (itemAt.CanStackedTo(item)) { return; } if (item.Count == 1 && item.BagType == itemAt.BagType) { bag.TakeOutItem(item); storeBag.TakeOutItem(itemAt); bag.AddItemTo(itemAt, place); storeBag.AddItemTo(item, toSlot); return; } string key = string.Format("temp_place_{0}", itemAt.ItemID); PlayerInventory itemInventory = client.Player.GetItemInventory(itemAt.Template); if (client.Player.TempProperties.ContainsKey(key) && itemInventory.BagType == 0) { int place2 = (int)client.Player.TempProperties[key]; client.Player.TempProperties.Remove(key); if (itemInventory.AddItemTo(itemAt, place2)) { storeBag.TakeOutItem(itemAt); } } else { if (itemInventory.StackItemToAnother(itemAt)) { storeBag.RemoveItem(itemAt, eItemRemoveType.Stack); } else { if (itemInventory.AddItem(itemAt)) { storeBag.TakeOutItem(itemAt); } else { client.Player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0])); } } } } if (storeBag.IsEmpty(toSlot)) { if (item.Count == 1) { if (storeBag.AddItemTo(item, toSlot)) { bag.TakeOutItem(item); if (item.Template.BagType == eBageType.MainBag && place < 31) { string key = string.Format("temp_place_{0}", item.ItemID); if (client.Player.TempProperties.ContainsKey(key)) { client.Player.TempProperties[key] = place; return; } client.Player.TempProperties.Add(key, place); return; } } } else { ItemInfo itemInfo = item.Clone(); itemInfo.Count = count; if (bag.RemoveCountFromStack(item, count, eItemRemoveType.Stack) && !storeBag.AddItemTo(itemInfo, toSlot)) { bag.AddCountToStack(item, count); } } } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { byte b = packet.ReadByte(); PlayerInventory inventory = client.Player.GetInventory(eBageType.BeadBag); string text = ""; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } if (DateTime.Compare(client.Player.LastDrillUpTime.AddSeconds(2.0), DateTime.Now) > 0) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Quá nhiều thao tác!", new object[0])); return(1); } switch (b) { case 1: { int num = packet.ReadInt(); int num2 = packet.ReadInt(); int num3 = 10; if (num2 == -1) { num2 = inventory.FindFirstEmptySlot(); } if (num <= 12 && num >= 4 && BeadHandle.canEquip(num2, client.Player.PlayerCharacter.Grade, ref num3)) { client.Out.SendMessage(eMessageType.Normal, string.Format("Cấp {0} mở", num3)); return(0); } if (!inventory.MoveItem(num, num2, 1)) { Console.WriteLine("????User move bead error"); } client.Player.MainBag.UpdatePlayerProperties(); break; } case 2: { new List <int>(); ItemInfo itemAt = inventory.GetItemAt(31); if (itemAt == null) { client.Player.SendMessage("Vật phẩm lạ không tìm thấy!!! Hack chăng???!!!"); return(0); } int arg_504_0 = itemAt.Hole1; int num4 = packet.ReadInt(); int num5 = RuneMgr.MaxLv(); for (int i = 0; i < num4; i++) { int num6 = packet.ReadInt(); ItemInfo itemAt2 = inventory.GetItemAt(num6); RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(itemAt.TemplateID); if (runeTemplateInfo == null) { inventory.RemoveItem(itemAt2); } else { if (itemAt2.Hole1 < itemAt.Hole1 && !itemAt2.IsUsed) { int hole = itemAt2.Hole2; int hole2 = itemAt.Hole2; int hole3 = itemAt.Hole1; int exp = hole + hole2; inventory.RemoveItemAt(num6); if (BeadHandle.CanUpLv(exp, hole3)) { itemAt.Hole2 += hole; itemAt.Hole1++; } else { itemAt.Hole2 += hole; } int nextTemplateID = runeTemplateInfo.NextTemplateID; RuneTemplateInfo runeTemplateInfo2 = RuneMgr.FindRuneTemplateID(nextTemplateID); if (itemAt.Hole1 == runeTemplateInfo2.BaseLevel) { ItemInfo itemInfo = new ItemInfo(ItemMgr.FindItemTemplate(nextTemplateID)); itemAt.TemplateID = nextTemplateID; itemInfo.Copy(itemAt); inventory.RemoveItemAt(31); inventory.AddItemTo(itemInfo, 31); } else { inventory.UpdateItem(itemAt); } if (itemAt.Hole1 == num5 + 1) { break; } } } } break; } case 3: { string[] array = GameProperties.OpenRunePackageMoney.Split(new char[] { '|' }); int num7 = packet.ReadInt(); packet.ReadBoolean(); int num8 = Convert.ToInt32(array[num7]); if (client.Player.PlayerCharacter.Money < num8) { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("DivorceApplyHandler.Msg1", new object[0])); return(1); } if (inventory.FindFirstEmptySlot() == -1) { client.Out.SendMessage(eMessageType.Normal, "Rương đã đầy không thể mở thêm!"); return(1); } List <RuneTemplateInfo> list = new List <RuneTemplateInfo>(); switch (num7) { case 1: list = RuneMgr.OpenPackageLv2(); break; case 2: list = RuneMgr.OpenPackageLv3(); break; case 3: list = RuneMgr.OpenPackageLv4(); break; default: list = RuneMgr.OpenPackageLv1(); break; } int index = ThreadSafeRandom.NextStatic(list.Count); ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(list[index].TemplateID), 1, 105); inventory.AddItem(itemInfo2); client.Out.SendMessage(eMessageType.Normal, "Bạn nhận được " + RuneMgr.FindRuneTemplateID(itemInfo2.TemplateID).Name); client.Player.RemoveMoney(num8); int rand = BeadHandle.NextBeadIndex(client, num7); this.BeadIndexUpdate(client, num7); client.Out.SendRuneOpenPackage(client.Player, rand); break; } case 4: { int num = packet.ReadInt(); ItemInfo itemAt2 = inventory.GetItemAt(num); if (itemAt2.IsUsed) { itemAt2.IsUsed = false; } else { itemAt2.IsUsed = true; } inventory.UpdateItem(itemAt2); break; } case 5: { int num9 = packet.ReadInt(); int templateId = packet.ReadInt(); PlayerInventory inventory2 = client.Player.GetInventory(eBageType.PropBag); inventory2.GetItemByTemplateID(0, templateId); int itemCount = inventory2.GetItemCount(templateId); if (itemCount <= 0) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("Mủi khoan không đủ!", new object[0])); } else { int num10 = BeadHandle.randomExp.Next(2, 6); text = LanguageMgr.GetTranslation("OpenHoleHandler.GetExp", new object[] { num10 }); UserDrillInfo userDrillInfo = client.Player.UserDrills[num9]; userDrillInfo.HoleExp += num10; if ((userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(0) && userDrillInfo.HoleLv == 0) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(1) && userDrillInfo.HoleLv == 1) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(2) && userDrillInfo.HoleLv == 2) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(3) && userDrillInfo.HoleLv == 3) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(4) && userDrillInfo.HoleLv == 4)) { userDrillInfo.HoleLv++; userDrillInfo.HoleExp = 0; } client.Player.UpdateDrill(num9, userDrillInfo); using (PlayerBussiness playerBussiness = new PlayerBussiness()) { playerBussiness.UpdateUserDrillInfo(userDrillInfo); } } if (text != "") { client.Out.SendMessage(eMessageType.Normal, text); } client.Player.Out.SendPlayerDrill(client.Player.PlayerCharacter.ID, client.Player.UserDrills); inventory2.RemoveTemplate(templateId, 1); client.Player.LastDrillUpTime = DateTime.Now; break; } } inventory.SaveToDatabase(); return(0); }
public void MoveToHide(GamePlayer player, PlayerInventory bag, ItemInfo item, int toSlot, PlayerInventory hideBag, int count) { if (player != null && bag != null && item != null && hideBag != null) { int oldplace = item.Place; ItemInfo toItem = hideBag.GetItemAt(toSlot); if (toItem != null) { if (toItem.CanStackedTo(item)) { return; } if (item.Count == 1 && item.BagType == toItem.BagType) { bag.TakeOutItem(item); hideBag.TakeOutItem(toItem); bag.AddItemTo(toItem, oldplace); hideBag.AddItemTo(item, toSlot); return; } string key = string.Format("temp_place_{0}", toItem.ItemID); PlayerInventory tb = player.GetItemInventory(toItem.Template); if (player.TempProperties.ContainsKey(key) && tb.BagType == 0) { int tempSlot = (int)player.TempProperties[key]; player.TempProperties.Remove(key); if (tb.AddItemTo(toItem, tempSlot)) { hideBag.TakeOutItem(toItem); } } else { if (tb.StackItemToAnother(toItem)) { hideBag.RemoveItem(toItem, eItemRemoveType.Stack); } else { if (tb.AddItem(toItem)) { hideBag.TakeOutItem(toItem); } else { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0])); } } } } if (hideBag.IsEmpty(toSlot)) { if (item.Count == 1) { if (hideBag.AddItemTo(item, toSlot)) { bag.TakeOutItem(item); if (item.Template.BagType == eBageType.MainBag) { string key = string.Format("temp_place_{0}", item.ItemID); if (player.TempProperties.ContainsKey(key)) { player.TempProperties[key] = oldplace; } else { player.TempProperties.Add(key, oldplace); } } } } else { ItemInfo newItem = item.Clone(); newItem.Count = 1; if (bag.RemoveCountFromStack(item, 1, eItemRemoveType.Stack)) { if (!hideBag.AddItemTo(newItem, toSlot)) { bag.AddCountToStack(item, 1); } } } } } }
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); }
public int HandlePacket(GameClient client, GSPacketIn packet) { bool flag = packet.ReadBoolean(); int num = packet.ReadInt(); int bageType = packet.ReadInt(); PlayerInventory inventory = client.Player.GetInventory((eBageType)bageType); List <ItemInfo> items = inventory.GetItems(inventory.BeginSlot, inventory.Capalility); if (num == items.Count) { inventory.BeginChanges(); try { ItemInfo[] rawSpaces = inventory.GetRawSpaces(); inventory.ClearBag(); for (int i = 0; i < num; i++) { int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); ItemInfo item = rawSpaces[num2]; if (!inventory.AddItemTo(item, num3)) { throw new Exception(string.Format("move item error: old place:{0} new place:{1}", num2, num3)); } } } catch (Exception ex) { MoveGoodsAllHandler.log.ErrorFormat("Arrage bag errror,user id:{0} msg:{1}", client.Player.PlayerId, ex.Message); } finally { if (flag) { items = inventory.GetItems(); List <int> list = new List <int>(); for (int j = 0; j < items.Count; j++) { if (!list.Contains(j)) { for (int k = items.Count - 1; k > j; k--) { if (!list.Contains(k) && items[j].TemplateID == items[k].TemplateID && items[j].CanStackedTo(items[k])) { inventory.MoveItem(items[k].Place, items[j].Place, items[k].Count); list.Add(k); } } } } items = inventory.GetItems(); if (inventory.FindFirstEmptySlot() != -1) { int num4 = 1; while (inventory.FindFirstEmptySlot() < items[items.Count - num4].Place) { inventory.MoveItem(items[items.Count - num4].Place, inventory.FindFirstEmptySlot(), items[items.Count - num4].Count); num4++; } } } inventory.CommitChanges(); } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); //int toBagTemp = packet.ReadByte(); //if (toBagTemp == 11) toBagTemp++; //eBageType tobagType = (eBageType)toBagTemp; eBageType tobagType = (eBageType)packet.ReadByte(); int toplace = packet.ReadInt(); int count = packet.ReadInt(); //pkg.writeByte(bagtype); //pkg.writeInt(place); //pkg.writeByte(tobagType); //pkg.writeInt(toplace); //pkg.writeInt(count); PlayerInventory bag = client.Player.GetInventory(bagType); PlayerInventory tobag = client.Player.GetInventory(tobagType); //chong hack chua xac dinh. do nem' vui khi di lung tung if (bag == null || bag.GetItemAt(place) == null) { return(0); } // chuyen do noi bo trong cung 1 tui' if ((bagType == tobagType) && place != -1) { //.GetItemInventory(temp); bag.MoveItem(place, toplace, count); return(1); } if (place == -1 && toplace != -1) { bag.RemoveItemAt(toplace); return(1); } if (place != -1 && toplace == -1 && bagType != eBageType.CaddyBag && tobagType != eBageType.Bank && bagType != eBageType.Store && tobagType != eBageType.Store) { if (bagType == 0) { bag.AddItem(client.Player.GetItemAt(bagType, place), 31); //toSolt = bag.FindFirstEmptySlot(31); } else { bag.AddItem(client.Player.GetItemAt(bagType, place), 0); } return(1); } if (place != -1 && tobagType != bagType && tobagType != eBageType.Store && tobagType != eBageType.MainBag) { ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); if (info != null) { //if(tobagType==eBageType.Store) client.Player.StoreBag.MoveToStore(bag, place, bagType, info.StoreLevel * 10); bag.MoveToStore(bag, place, toplace, tobag, info.StoreLevel * 10); return(1); } } //danh cho store khi nang cap chuyen do ve main if (tobagType == eBageType.Store || bagType == eBageType.Store) { var item = client.Player.GetItemAt(bagType, place); if (item != null && item.Count > 1) { item.Count--; bag.UpdateItem(item); var tempItem = item.Clone(); tempItem.Count = 1; if (tobag.GetItemAt(toplace) == null) { tobag.AddItemTo(tempItem, toplace); } else { var tempItem2 = bag.GetItemByTemplateID(0, tobag.GetItemAt(toplace).TemplateID); if (tempItem2 == null) { bag.MoveToStore(tobag, toplace, bag.FindFirstEmptySlot(0), bag, 999); } else { tempItem2.Count++; bag.UpdateItem(tempItem2); tobag.RemoveItemAt(toplace); } tobag.AddItemTo(tempItem, toplace); } //tobag.CommitChanges(); } else { if (tobagType != eBageType.Store && tobagType != eBageType.MainBag && bag.GetItemAt(place) != null && bag.GetItemAt(place).Template.CategoryID == 7 && (toplace > 0 && toplace < 31 && toplace != 6)) { return(1); } try { bag.MoveToStore(bag, place, toplace, tobag, 50); } catch (Exception e) { LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", place, toplace, bagType, tobagType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(place), tobag.GetItemAt(toplace)); } } return(1); } //danh cho tu ngan hang chuyen do ve main if (tobagType == eBageType.MainBag && bagType == eBageType.Bank) { bag.MoveToStore(bag, place, toplace, tobag, 50); return(1); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bageType = (eBageType)packet.ReadByte(); int slot = packet.ReadInt(); eBageType type2 = (eBageType)packet.ReadByte(); int toSlot = packet.ReadInt(); int count = packet.ReadInt(); PlayerInventory bag = client.Player.GetInventory(bageType); PlayerInventory inventory = client.Player.GetInventory(type2); if (toSlot < 0) { if ((inventory.BagType == 11) || (inventory.BagType == 1)) { toSlot = inventory.FindFirstEmptySlot(0); } else { toSlot = inventory.FindFirstEmptySlot(0x1f); } } if (count > 0) { if ((bag == null) || (bag.GetItemAt(slot) == null)) { return(0); } if ((bageType == type2) && (slot != -1)) { if (bag.GetItemAt(slot).Count >= count) { bag.MoveItem(slot, toSlot, count); } else { Console.WriteLine("--" + client.Player.Account + " Hack = CE"); bag.MoveItem(slot, toSlot, bag.GetItemAt(slot).Count); } return(1); } if ((slot == -1) && (toSlot != -1)) { bag.RemoveItemAt(toSlot); return(1); } if (((((slot != -1) && (toSlot == -1)) && ((bageType != eBageType.CaddyBag) && (type2 != eBageType.Bank))) && (bageType != eBageType.Store)) && (type2 != eBageType.Store)) { if (bageType == eBageType.MainBag) { bag.AddItem(client.Player.GetItemAt(bageType, slot), 0x1f); } else { bag.AddItem(client.Player.GetItemAt(bageType, slot), 0); } return(1); } if ((((slot != -1) && (type2 != bageType)) && (type2 != eBageType.Store)) && (type2 != eBageType.MainBag)) { ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); if (info != null) { if (type2 == eBageType.Store) { } bag.MoveToStore(bag, slot, toSlot, inventory, info.StoreLevel * 10); return(1); } } if ((type2 == eBageType.Store) || (bageType == eBageType.Store)) { SqlDataProvider.Data.ItemInfo itemAt = client.Player.GetItemAt(bageType, slot); if ((itemAt != null) && (itemAt.Count > 1)) { itemAt.Count--; bag.UpdateItem(itemAt); SqlDataProvider.Data.ItemInfo item = itemAt.Clone(); item.Count = 1; if (inventory.GetItemAt(toSlot) == null) { inventory.AddItemTo(item, toSlot); } else { SqlDataProvider.Data.ItemInfo itemByTemplateID = bag.GetItemByTemplateID(0, inventory.GetItemAt(toSlot).TemplateID); if (itemByTemplateID == null) { bag.MoveToStore(inventory, toSlot, bag.FindFirstEmptySlot(0), bag, 0x3e7); } else { itemByTemplateID.Count++; bag.UpdateItem(itemByTemplateID); inventory.RemoveItemAt(toSlot); } inventory.AddItemTo(item, toSlot); } } else { if ((((type2 != eBageType.Store) && (type2 != eBageType.MainBag)) && ((bag.GetItemAt(slot) != null) && (bag.GetItemAt(slot).Template.CategoryID == 7))) && (((toSlot > 0) && (toSlot < 0x1f)) && (toSlot != 6))) { return(1); } try { bag.MoveToStore(bag, slot, toSlot, inventory, 50); } catch (Exception) { LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", new object[] { slot, toSlot, bageType, type2 }); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(slot), inventory.GetItemAt(toSlot)); } } return(1); } if ((type2 == eBageType.MainBag) && (bageType == eBageType.Bank)) { bag.MoveToStore(bag, slot, toSlot, inventory, 50); return(1); } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { bool isStack = packet.ReadBoolean(); int count = packet.ReadInt(); int bagType = packet.ReadInt(); PlayerInventory inventory = client.Player.GetInventory((eBageType)bagType); List <ItemInfo> recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); if (count == recoverItems.Count) { inventory.BeginChanges(); bool result = false; try { ItemInfo[] rawitems = inventory.GetRawSpaces(); inventory.ClearBag(); for (int i = 0; i < count; i++) { int oldplace = packet.ReadInt(); int newplace = packet.ReadInt(); ItemInfo it = rawitems[oldplace]; if (!inventory.AddItemTo(it, newplace)) { throw new Exception(string.Format("move item error: old place:{0} new place:{1}", oldplace, newplace)); } } //============================= if (isStack && bagType == 1) { recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); List <int> list2 = new List <int>(); for (int i = 0; i < recoverItems.Count; i++) { if (!list2.Contains(i)) { for (int j = recoverItems.Count - 1; j > i; j--) { if (!list2.Contains(j) && ((recoverItems[i].TemplateID == recoverItems[j].TemplateID) && recoverItems[i].CanStackedTo(recoverItems[j]))) { inventory.MoveItem(recoverItems[j].Place, recoverItems[i].Place, recoverItems[j].Count); list2.Add(j); } } } } } recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); if (inventory.FindFirstEmptySlot(inventory.BeginSlot) != -1) { for (int k = 1; inventory.FindFirstEmptySlot(inventory.BeginSlot) < recoverItems[recoverItems.Count - k].Place; k++) { inventory.MoveItem(recoverItems[recoverItems.Count - k].Place, inventory.FindFirstEmptySlot(inventory.BeginSlot), recoverItems[recoverItems.Count - k].Count); } } //============================= result = true; } catch (Exception ex) { log.ErrorFormat("Arrage bag errror,user id:{0} msg:{1}", client.Player.PlayerId, ex.Message); } finally { if (!result) { inventory.ClearBag(); foreach (ItemInfo info in recoverItems) { inventory.AddItemTo(info, info.Place); } } inventory.CommitChanges(); } } return(0); }