public static void TryRemoveItems(Character activeCharacter, List <int> itemIds) { uint entityLowId = activeCharacter.Record.EntityLowId; if (!Asda2AuctionMgr.ItemsByOwner.ContainsKey(entityLowId)) { activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded."); } else { bool?nullable1 = new bool?(); List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>(); foreach (int itemId in itemIds) { if (!Asda2AuctionMgr.ItemsByOwner[entityLowId].ContainsKey(itemId)) { asda2ItemRecordList.Clear(); activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded."); return; } Asda2ItemRecord asda2ItemRecord = Asda2AuctionMgr.ItemsByOwner[entityLowId][itemId]; if (!nullable1.HasValue) { nullable1 = new bool?(asda2ItemRecord.Template.IsShopInventoryItem); } bool?nullable2 = nullable1; bool shopInventoryItem = asda2ItemRecord.Template.IsShopInventoryItem; if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0) { activeCharacter.YouAreFuckingCheater( "Trying to remove shop\not shop item in one auction buy request.", 1); activeCharacter.SendAuctionMsg( "Removing from auction failed cause founded shop\not shop items in one request."); } asda2ItemRecordList.Add(asda2ItemRecord); } if (nullable1.Value) { if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } } else if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } List <Asda2ItemTradeRef> asda2Items = new List <Asda2ItemTradeRef>(); foreach (Asda2ItemRecord record in asda2ItemRecordList) { Asda2AuctionMgr.UnRegisterItem(record); int amount = record.Amount; int auctionId = record.AuctionId; Asda2Item asda2Item = (Asda2Item)null; Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null); int num = (int)activeCharacter.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true, ref asda2Item, new Asda2InventoryType?(), itemToCopyStats); record.DeleteLater(); asda2Items.Add(new Asda2ItemTradeRef() { Amount = amount, Item = asda2Item, Price = auctionId }); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId) .AddAttribute("source", 0.0, "removed_from_auction").AddItemAttributes(asda2Item, "").Write(); } Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, asda2Items); } }
public static void TryRemoveItems(Character activeCharacter, List <int> itemIds) { var chrId = activeCharacter.Record.EntityLowId; if (!ItemsByOwner.ContainsKey(chrId)) { activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded."); return; } bool?isShopItems = null; var items = new List <Asda2ItemRecord>(); foreach (var itemId in itemIds) { if (!ItemsByOwner[chrId].ContainsKey(itemId)) { items.Clear(); activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded."); return; } var item = ItemsByOwner[chrId][itemId]; if (isShopItems == null) { isShopItems = item.Template.IsShopInventoryItem; } if (isShopItems != item.Template.IsShopInventoryItem) { activeCharacter.YouAreFuckingCheater("Trying to remove shop\not shop item in one auction buy request."); activeCharacter.SendAuctionMsg("Removing from auction failed cause founded shop\not shop items in one request."); } items.Add(item); } if ((bool)isShopItems) { if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < items.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } } else { if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < items.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } } var r = new List <Asda2ItemTradeRef>(); foreach (var rec in items) { UnRegisterItem(rec); var amount = rec.Amount; var aucId = rec.AuctionId; Asda2Item item = null; var aucItem = Asda2Item.CreateItem(rec, (Character)null); activeCharacter.Asda2Inventory.TryAdd(rec.ItemId, rec.Amount, true, ref item, null, aucItem); rec.DeleteLater(); r.Add(new Asda2ItemTradeRef { Amount = amount, Item = item, Price = aucId }); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId) .AddAttribute("source", 0, "removed_from_auction") .AddItemAttributes(item) .Write(); } Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, r); }