/// <summary> /// c_blist packet /// </summary> /// <param name="cbListPacket"></param> public void RefreshBazarList(CBListPacket cbListPacket) { if (ServerManager.Instance.InShutdown) { return; } SpinWait.SpinUntil(() => !ServerManager.Instance.InBazaarRefreshMode); Session.SendPacket(UserInterfaceHelper.Instance.GenerateRCBList(cbListPacket)); }
public string GenerateRCBList(CBListPacket packet) { string itembazar = string.Empty; List <string> itemssearch = packet.ItemVNumFilter == "0" ? new List <string>() : packet.ItemVNumFilter.Split(' ').ToList(); List <BazaarItemLink> bzlist = new List <BazaarItemLink>(); BazaarItemLink[] billist = new BazaarItemLink[ServerManager.Instance.BazaarList.Count + 20]; ServerManager.Instance.BazaarList.CopyTo(billist); foreach (BazaarItemLink bz in billist) { if (bz?.Item == null) { continue; } switch (packet.TypeFilter) { case BazaarListType.Weapon: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Weapon) { if (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) { if (packet.LevelFilter == 0 || packet.LevelFilter == 11 && bz.Item.Item.IsHeroic || bz.Item.Item.LevelMinimum < packet.LevelFilter * 10 + 1 && bz.Item.Item.LevelMinimum >= packet.LevelFilter * 10 - 9) //Level filter { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { bzlist.Add(bz); } } } } } break; case BazaarListType.Armor: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Armor) { if (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) { if (packet.LevelFilter == 0 || packet.LevelFilter == 11 && bz.Item.Item.IsHeroic || bz.Item.Item.LevelMinimum < packet.LevelFilter * 10 + 1 && bz.Item.Item.LevelMinimum >= packet.LevelFilter * 10 - 9) //Level filter { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { bzlist.Add(bz); } } } } } break; case BazaarListType.Equipment: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Fashion) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Mask || packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Hat || packet.SubTypeFilter == 6 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeHat || packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeSuit || packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Gloves || packet.SubTypeFilter == 4 && bz.Item.Item.EquipmentSlot == EquipmentType.Boots) { if (packet.LevelFilter == 0 || packet.LevelFilter == 11 && bz.Item.Item.IsHeroic || bz.Item.Item.LevelMinimum < packet.LevelFilter * 10 + 1 && bz.Item.Item.LevelMinimum >= packet.LevelFilter * 10 - 9) //Level filter { bzlist.Add(bz); } } } break; case BazaarListType.Jewelery: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Jewelery) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Ring || packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Necklace || packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.Amulet || packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Bracelet || packet.SubTypeFilter == 4 && (bz.Item.Item.EquipmentSlot == EquipmentType.Fairy || bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 5)) { if (packet.LevelFilter == 0 || packet.LevelFilter == 11 && bz.Item.Item.IsHeroic || bz.Item.Item.LevelMinimum < packet.LevelFilter * 10 + 1 && bz.Item.Item.LevelMinimum >= packet.LevelFilter * 10 - 9) //Level filter { bzlist.Add(bz); } } } break; case BazaarListType.Specialist: if (bz.Item.Item.Type == InventoryType.Equipment) { if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 2) { if (bz.Item is BoxInstance boxInstance) { if (packet.SubTypeFilter == 0) { if (packet.LevelFilter == 0 || ((BoxInstance)bz.Item).SpLevel < packet.LevelFilter * 10 + 1 && ((BoxInstance)bz.Item).SpLevel >= packet.LevelFilter * 10 - 9) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && ((BoxInstance)bz.Item).HoldingVNum == 0 || packet.SubTypeFilter == 2 && ((BoxInstance)bz.Item).HoldingVNum != 0) { bzlist.Add(bz); } } } } else if (boxInstance.HoldingVNum == 0) { if (packet.SubTypeFilter == 1) { if (packet.LevelFilter == 0 || ((BoxInstance)bz.Item).SpLevel < packet.LevelFilter * 10 + 1 && ((BoxInstance)bz.Item).SpLevel >= packet.LevelFilter * 10 - 9) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && ((BoxInstance)bz.Item).HoldingVNum == 0 || packet.SubTypeFilter == 2 && ((BoxInstance)bz.Item).HoldingVNum != 0) { bzlist.Add(bz); } } } } } else if (packet.SubTypeFilter == 2 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 10 || packet.SubTypeFilter == 3 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 11 || packet.SubTypeFilter == 4 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 2 || packet.SubTypeFilter == 5 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 3 || packet.SubTypeFilter == 6 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 13 || packet.SubTypeFilter == 7 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 5 || packet.SubTypeFilter == 8 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 12 || packet.SubTypeFilter == 9 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 4 || packet.SubTypeFilter == 10 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 7 || packet.SubTypeFilter == 11 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 15 || packet.SubTypeFilter == 12 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 6 || packet.SubTypeFilter == 13 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 14 || packet.SubTypeFilter == 14 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 9 || packet.SubTypeFilter == 15 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 8 || packet.SubTypeFilter == 16 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 1 || packet.SubTypeFilter == 17 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 16 || packet.SubTypeFilter == 18 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 17 || packet.SubTypeFilter == 19 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 18 || packet.SubTypeFilter == 20 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 19 || packet.SubTypeFilter == 21 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 20 || packet.SubTypeFilter == 22 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 21 || packet.SubTypeFilter == 23 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 22 || packet.SubTypeFilter == 24 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 23 || packet.SubTypeFilter == 25 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 24 || packet.SubTypeFilter == 26 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 25 || packet.SubTypeFilter == 27 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 26 || packet.SubTypeFilter == 28 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 27 || packet.SubTypeFilter == 29 && ServerManager.Instance.GetItem(boxInstance.HoldingVNum).Morph == 28) { if (packet.LevelFilter == 0 || ((BoxInstance)bz.Item).SpLevel < packet.LevelFilter * 10 + 1 && ((BoxInstance)bz.Item).SpLevel >= packet.LevelFilter * 10 - 9) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && ((BoxInstance)bz.Item).HoldingVNum == 0 || packet.SubTypeFilter >= 2 && ((BoxInstance)bz.Item).HoldingVNum != 0) { bzlist.Add(bz); } } } } } } } break; case BazaarListType.Pet: if (bz.Item.Item.Type == InventoryType.Equipment) { if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 0) { if (bz.Item is BoxInstance boxinstanced && (packet.LevelFilter == 0 || boxinstanced.SpLevel < packet.LevelFilter * 10 + 1 && boxinstanced.SpLevel >= packet.LevelFilter * 10 - 9)) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && ((BoxInstance)bz.Item).HoldingVNum == 0 || packet.SubTypeFilter == 2 && ((BoxInstance)bz.Item).HoldingVNum != 0) { bzlist.Add(bz); } } } } break; case BazaarListType.Npc: if (bz.Item.Item.Type == InventoryType.Equipment) { if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 1) { if (bz.Item is BoxInstance box && (packet.LevelFilter == 0 || box.SpLevel < packet.LevelFilter * 10 + 1 && box.SpLevel >= packet.LevelFilter * 10 - 9)) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && ((BoxInstance)bz.Item).HoldingVNum == 0 || packet.SubTypeFilter == 2 && ((BoxInstance)bz.Item).HoldingVNum != 0) { bzlist.Add(bz); } } } } break; case BazaarListType.Shell: if (bz.Item.Item.Type == InventoryType.Equipment) { if (bz.Item.Item.ItemType == ItemType.Shell) { if (packet.SubTypeFilter == 0 || bz.Item.Item.ItemSubType == bz.Item.Item.ItemSubType + 1) { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if (bz.Item is BoxInstance box && (packet.LevelFilter == 0 || box.SpLevel < packet.LevelFilter * 10 + 1 && box.SpLevel >= packet.LevelFilter * 10 - 9)) { bzlist.Add(bz); } } } } } break; case BazaarListType.Main: if (bz.Item.Item.Type == InventoryType.Main) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Main || packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Upgrade || packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Production || packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Special || packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Potion || packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Event) { bzlist.Add(bz); } } break; case BazaarListType.Usable: if (bz.Item.Item.Type == InventoryType.Etc) { if (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Food || packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Snack || packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Magical || packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Part || packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Teacher || packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Sell) { bzlist.Add(bz); } } break; case BazaarListType.Other: if (bz.Item.Item.Type == InventoryType.Equipment) { if (bz.Item.Item.ItemType == ItemType.Box && !bz.Item.Item.Flag9) { bzlist.Add(bz); } } break; case BazaarListType.Vehicle: if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 4) { if (bz.Item is BoxInstance box && (packet.SubTypeFilter == 0 || packet.SubTypeFilter == 1 && box.HoldingVNum == 0 || packet.SubTypeFilter == 2 && box.HoldingVNum != 0)) { bzlist.Add(bz); } } break; default: bzlist.Add(bz); break; } } List <BazaarItemLink> bzlistsearched = bzlist.Where(s => itemssearch.Contains(s.Item.ItemVNum.ToString())).ToList(); //price up price down quantity up quantity down List <BazaarItemLink> definitivelist = itemssearch.Any() ? bzlistsearched : bzlist; switch (packet.OrderFilter) { case 0: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenBy(s => s.BazaarItem.Price).ToList(); break; case 1: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenByDescending(s => s.BazaarItem.Price).ToList(); break; case 2: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenBy(s => s.BazaarItem.Amount).ToList(); break; case 3: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenByDescending(s => s.BazaarItem.Amount).ToList(); break; default: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ToList(); break; } foreach (BazaarItemLink bzlink in definitivelist.Where(s => (s.BazaarItem.DateStart.AddHours(s.BazaarItem.Duration) - DateTime.Now).TotalMinutes > 0 && s.Item.Amount > 0).Skip(packet.Index * 50).Take(50)) { long time = (long)(bzlink.BazaarItem.DateStart.AddHours(bzlink.BazaarItem.Duration) - DateTime.Now).TotalMinutes; string info = string.Empty; if (bzlink.Item.Item.Type == InventoryType.Equipment) { if (bzlink.Item is WearableInstance wear) { wear.EquipmentOptions.Clear(); wear.EquipmentOptions.AddRange(DAOFactory.EquipmentOptionDAO.GetOptionsByWearableInstanceId(wear.Id)); } info = (bzlink.Item.Item.EquipmentSlot != EquipmentType.Sp ? (bzlink.Item as WearableInstance).GenerateEInfo() : bzlink.Item.Item.SpType == 0 && bzlink.Item.Item.ItemSubType == 4 ? (bzlink.Item as SpecialistInstance).GeneratePslInfo() : (bzlink.Item as SpecialistInstance).GenerateSlInfo()).Replace(' ', '^').Replace("slinfo^", "").Replace("e_info^", ""); } itembazar += $"{bzlink.BazaarItem.BazaarItemId}|{bzlink.BazaarItem.SellerId}|{bzlink.Owner}|{bzlink.Item.Item.VNum}|{bzlink.Item.Amount}|{(bzlink.BazaarItem.IsPackage ? 1 : 0)}|{bzlink.BazaarItem.Price}|{time}|2|0|{bzlink.Item.Rare}|{bzlink.Item.Upgrade}|{info} "; } return($"rc_blist {packet.Index} {itembazar} "); }
public string GenerateRCBList(CBListPacket packet) { if (packet == null || packet.ItemVNumFilter == null) { return(string.Empty); } string itembazar = string.Empty; List <string> itemssearch = packet.ItemVNumFilter == "0" ? new List <string>() : packet.ItemVNumFilter.Split(' ').ToList(); List <BazaarItemLink> bzlist = new List <BazaarItemLink>(); BazaarItemLink[] billist = new BazaarItemLink[ServerManager.Instance.BazaarList.Count + 20]; ServerManager.Instance.BazaarList.CopyTo(billist); foreach (BazaarItemLink bz in billist) { if (bz?.Item == null) { continue; } switch (packet.TypeFilter) { case BazaarListType.Weapon: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Weapon) { if (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) { if (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) //Level filter { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { bzlist.Add(bz); } } } } } break; case BazaarListType.Armor: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Armor) { if (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) { if (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) //Level filter { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { bzlist.Add(bz); } } } } } break; case BazaarListType.Equipment: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Fashion) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Mask) || ((packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Hat) || (packet.SubTypeFilter == 6 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeHat) || (packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeSuit) || (packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Gloves) || (packet.SubTypeFilter == 4 && bz.Item.Item.EquipmentSlot == EquipmentType.Boots))) { if (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) //Level filter { bzlist.Add(bz); } } } break; case BazaarListType.Jewelery: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Jewelery) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Ring) || (packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Necklace) || (packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.Amulet) || (packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Bracelet) || (packet.SubTypeFilter == 4 && (bz.Item.Item.EquipmentSlot == EquipmentType.Fairy || (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 5)))) { if (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) //Level filter { bzlist.Add(bz); } } } break; case BazaarListType.Specialist: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 2) { if (packet.SubTypeFilter == 0) { if (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0)) { bzlist.Add(bz); } } } } else if (bz.Item.HoldingVNum == 0) { if (packet.SubTypeFilter == 1) { if (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0)) { bzlist.Add(bz); } } } } } else if ((packet.SubTypeFilter == 2 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 10) || (packet.SubTypeFilter == 3 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 11) || (packet.SubTypeFilter == 4 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 2) || (packet.SubTypeFilter == 5 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 3) || (packet.SubTypeFilter == 6 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 13) || (packet.SubTypeFilter == 7 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 5) || (packet.SubTypeFilter == 8 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 12) || (packet.SubTypeFilter == 9 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 4) || (packet.SubTypeFilter == 10 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 7) || (packet.SubTypeFilter == 11 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 15) || (packet.SubTypeFilter == 12 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 6) || (packet.SubTypeFilter == 13 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 14) || (packet.SubTypeFilter == 14 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 9) || (packet.SubTypeFilter == 15 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 8) || (packet.SubTypeFilter == 16 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 1) || (packet.SubTypeFilter == 17 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 16) || (packet.SubTypeFilter == 18 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 17) || ((packet.SubTypeFilter == 19 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 18) || (packet.SubTypeFilter == 20 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 19) || (packet.SubTypeFilter == 21 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 20) || (packet.SubTypeFilter == 22 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 21) || (packet.SubTypeFilter == 23 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 22) || (packet.SubTypeFilter == 24 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 23) || (packet.SubTypeFilter == 25 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 24) || (packet.SubTypeFilter == 26 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 25) || (packet.SubTypeFilter == 27 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 26) || (packet.SubTypeFilter == 28 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 27) || (packet.SubTypeFilter == 29 && ServerManager.Instance.GetItem(bz.Item.HoldingVNum).Morph == 28))) { if (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) { if (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter >= 2 && bz.Item.HoldingVNum != 0)) { bzlist.Add(bz); } } } } } break; case BazaarListType.Pet: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 0 && (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9))) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0)) { bzlist.Add(bz); } } break; case BazaarListType.Npc: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 1 && (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9))) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0)) { bzlist.Add(bz); } } break; case BazaarListType.Shell: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Shell) { if (packet.SubTypeFilter == 0 || bz.Item.Item.ItemSubType == bz.Item.Item.ItemSubType + 1) { if (packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) { if ((packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9))) { bzlist.Add(bz); } } } } break; case BazaarListType.Main: if (bz.Item.Item.Type == InventoryType.Main) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Main) || (packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Upgrade) || (packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Production) || (packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Special) || (packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Potion) || (packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Event)) { bzlist.Add(bz); } } break; case BazaarListType.Usable: if (bz.Item.Item.Type == InventoryType.Etc) { if (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Food) || ((packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Snack) || (packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Magical) || (packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Part) || (packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Teacher) || (packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Sell))) { bzlist.Add(bz); } } break; case BazaarListType.Other: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && !bz.Item.Item.IsHolder) { bzlist.Add(bz); } break; case BazaarListType.Vehicle: if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 4 && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0))) { bzlist.Add(bz); } break; default: bzlist.Add(bz); break; } } List <BazaarItemLink> bzlistsearched = bzlist.Where(s => itemssearch.Contains(s.Item.ItemVNum.ToString())).ToList(); //price up price down quantity up quantity down List <BazaarItemLink> definitivelist = itemssearch.Count > 0 ? bzlistsearched : bzlist; switch (packet.OrderFilter) { case 0: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenBy(s => s.BazaarItem.Price).ToList(); break; case 1: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenByDescending(s => s.BazaarItem.Price).ToList(); break; case 2: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenBy(s => s.BazaarItem.Amount).ToList(); break; case 3: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ThenByDescending(s => s.BazaarItem.Amount).ToList(); break; default: definitivelist = definitivelist.OrderBy(s => s.Item.Item.Name).ToList(); break; } foreach (BazaarItemLink bzlink in definitivelist.Where(s => (s.BazaarItem.DateStart.AddHours(s.BazaarItem.Duration) - DateTime.Now).TotalMinutes > 0 && s.Item.Amount > 0).Skip(packet.Index * 50).Take(50)) { long time = (long)(bzlink.BazaarItem.DateStart.AddHours(bzlink.BazaarItem.Duration) - DateTime.Now).TotalMinutes; string info = string.Empty; if (bzlink.Item.Item.Type == InventoryType.Equipment) { info = (bzlink.Item.Item.EquipmentSlot != EquipmentType.Sp ? bzlink.Item?.GenerateEInfo() : bzlink.Item.Item.SpType == 0 && bzlink.Item.Item.ItemSubType == 4 ? bzlink.Item?.GeneratePslInfo() : bzlink.Item?.GenerateSlInfo()).Replace(' ', '^').Replace("slinfo^", "").Replace("e_info^", ""); } itembazar += $"{bzlink.BazaarItem.BazaarItemId}|{bzlink.BazaarItem.SellerId}|{bzlink.Owner}|{bzlink.Item.Item.VNum}|{bzlink.Item.Amount}|{(bzlink.BazaarItem.IsPackage ? 1 : 0)}|{bzlink.BazaarItem.Price}|{time}|2|0|{bzlink.Item.Rare}|{bzlink.Item.Upgrade}|{info} "; } return($"rc_blist {packet.Index} {itembazar} "); }
public static string GenerateRCBList(CBListPacket packet) { if (packet == null || packet.ItemVNumFilter == null) { return(string.Empty); } string itembazar = string.Empty; List <string> itemssearch = packet.ItemVNumFilter == "0" ? new List <string>() : packet.ItemVNumFilter.Split(' ').ToList(); List <BazaarItemLink> bzlist = new List <BazaarItemLink>(); BazaarItemLink[] billist = new BazaarItemLink[ServerManager.Instance.BazaarList.Count + 20]; ServerManager.Instance.BazaarList.CopyTo(billist); try { List <BazaarItemLink> temps = new List <BazaarItemLink>(); foreach (BazaarItemLink temp in billist) { if (temp == null) { temps.Add(temp); continue; } if (temp.Item == null) { temps.Add(temp); continue; } if (temp.Item.Item == null) { temps.Add(temp); continue; } if (temp.BazaarItem == null) { temps.Add(temp); continue; } } List <BazaarItemLink> test = billist.ToList(); foreach (BazaarItemLink temp2 in temps) { test.Remove(temp2); } billist = test.ToArray(); foreach (BazaarItemLink bz in billist) { if (bz?.Item == null || bz?.Item.Item == null || bz?.BazaarItem == null) { continue; } switch (packet.TypeFilter) { case BazaarListType.Weapon: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Weapon && (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) && ((packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) && ((packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) && (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1)))) { bzlist.Add(bz); } break; case BazaarListType.Armor: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Armor && (packet.SubTypeFilter == 0 || ((bz.Item.Item.Class + 1 >> packet.SubTypeFilter) & 1) == 1) && ((packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)) && ((packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) && (packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1)))) { bzlist.Add(bz); } break; case BazaarListType.Equipment: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Fashion && ((packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Mask) || ((packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Hat) || (packet.SubTypeFilter == 6 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeHat) || (packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.CostumeSuit) || (packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Gloves) || (packet.SubTypeFilter == 4 && bz.Item.Item.EquipmentSlot == EquipmentType.Boots))) && (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)))) { bzlist.Add(bz); } break; case BazaarListType.Jewelery: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Jewelery && ((packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 2 && bz.Item.Item.EquipmentSlot == EquipmentType.Ring) || (packet.SubTypeFilter == 1 && bz.Item.Item.EquipmentSlot == EquipmentType.Necklace) || (packet.SubTypeFilter == 5 && bz.Item.Item.EquipmentSlot == EquipmentType.Amulet) || (packet.SubTypeFilter == 3 && bz.Item.Item.EquipmentSlot == EquipmentType.Bracelet) || (packet.SubTypeFilter == 4 && (bz.Item.Item.EquipmentSlot == EquipmentType.Fairy || (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 5)))) && (packet.LevelFilter == 0 || (packet.LevelFilter == 11 && bz.Item.Item.IsHeroic) || (bz.Item.Item.LevelMinimum < (packet.LevelFilter * 10) + 1 && bz.Item.Item.LevelMinimum >= (packet.LevelFilter * 10) - 9)))) { bzlist.Add(bz); } break; case BazaarListType.Specialist: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 2) { if (packet.SubTypeFilter == 0 && ((packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) && ((packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0))))) { bzlist.Add(bz); } else if (bz.Item?.HoldingVNum == 0 && (packet.SubTypeFilter == 1 && ((packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) && ((packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0)))))) { bzlist.Add(bz); } else if (Rcbfix(packet.SubTypeFilter, bz?.Item?.HoldingVNum)) { if ((packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) && ((packet.UpgradeFilter == 0 || packet.UpgradeFilter == bz.Item.Upgrade + 1) && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter >= 2 && bz.Item.HoldingVNum != 0)))) { bzlist.Add(bz); } } } break; case BazaarListType.Pet: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 0 && (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0))) { bzlist.Add(bz); } break; case BazaarListType.Npc: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 1 && (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)) && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0))) { bzlist.Add(bz); } break; case BazaarListType.Shell: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Shell && (packet.SubTypeFilter == 0 || bz.Item.Item.ItemSubType == bz.Item.Item.ItemSubType + 1) && ((packet.RareFilter == 0 || packet.RareFilter == bz.Item.Rare + 1) && (packet.LevelFilter == 0 || (bz.Item.SpLevel < (packet.LevelFilter * 10) + 1 && bz.Item.SpLevel >= (packet.LevelFilter * 10) - 9)))) { bzlist.Add(bz); } break; case BazaarListType.Main: if (bz.Item.Item.Type == InventoryType.Main && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Main) || (packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Upgrade) || (packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Production) || (packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Special) || (packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Potion) || (packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Event))) { bzlist.Add(bz); } break; case BazaarListType.Usable: if (bz.Item.Item.Type == InventoryType.Etc && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.Item.ItemType == ItemType.Food) || ((packet.SubTypeFilter == 2 && bz.Item.Item.ItemType == ItemType.Snack) || (packet.SubTypeFilter == 3 && bz.Item.Item.ItemType == ItemType.Magical) || (packet.SubTypeFilter == 4 && bz.Item.Item.ItemType == ItemType.Part) || (packet.SubTypeFilter == 5 && bz.Item.Item.ItemType == ItemType.Teacher) || (packet.SubTypeFilter == 6 && bz.Item.Item.ItemType == ItemType.Sell)))) { bzlist.Add(bz); } break; case BazaarListType.Other: if (bz.Item.Item.Type == InventoryType.Equipment && bz.Item.Item.ItemType == ItemType.Box && !bz.Item.Item.IsHolder) { bzlist.Add(bz); } break; case BazaarListType.Vehicle: if (bz.Item.Item.ItemType == ItemType.Box && bz.Item.Item.ItemSubType == 4 && (packet.SubTypeFilter == 0 || (packet.SubTypeFilter == 1 && bz.Item.HoldingVNum == 0) || (packet.SubTypeFilter == 2 && bz.Item.HoldingVNum != 0))) { bzlist.Add(bz); } break; default: bzlist.Add(bz); break; } } List <BazaarItemLink> bzlistsearched = bzlist.Where(s => itemssearch.Contains(s?.Item.ItemVNum.ToString())).ToList(); //price up price down quantity up quantity down List <BazaarItemLink> definitivelist = itemssearch.Count > 0 ? bzlistsearched : bzlist; if (definitivelist != null) { List <BazaarItemLink> remove = new List <BazaarItemLink>(); foreach (BazaarItemLink temp in definitivelist) { if (temp == null) { remove.Add(temp); continue; } if (temp.Item == null) { remove.Add(temp); continue; } if (temp.Item.Item == null) { remove.Add(temp); continue; } if (temp.BazaarItem == null) { remove.Add(temp); continue; } } foreach (BazaarItemLink temp2 in remove) { definitivelist.Remove(temp2); } } if (definitivelist != null) { switch (packet.OrderFilter) { case 0: definitivelist = definitivelist.OrderBy(s => s?.Item.Item.Name). ThenBy(s => s?.BazaarItem.Price).ToList(); break; case 1: definitivelist = definitivelist.OrderBy(s => s?.Item.Item.Name).ThenByDescending(s => s?.BazaarItem.Price).ToList(); break; case 2: definitivelist = definitivelist.OrderBy(s => s?.Item.Item.Name).ThenBy(s => s?.BazaarItem.Amount).ToList(); break; case 3: definitivelist = definitivelist.OrderBy(s => s?.Item.Item.Name).ThenByDescending(s => s?.BazaarItem.Amount).ToList(); break; default: definitivelist = definitivelist.OrderBy(s => s?.Item.Item.Name).ToList(); break; } } foreach (BazaarItemLink bzlink in definitivelist.Where(s => (s.BazaarItem.DateStart.AddHours(s.BazaarItem.Duration) - DateTime.Now).TotalMinutes > 0 && s?.Item.Amount > 0).Skip(packet.Index * 50).Take(50)) { long time = (long)(bzlink.BazaarItem.DateStart.AddHours(bzlink.BazaarItem.Duration) - DateTime.Now).TotalMinutes; string info = string.Empty; if (bzlink.Item.Item.Type == InventoryType.Equipment) { info = (bzlink.Item.Item.EquipmentSlot != EquipmentType.Sp ? bzlink.Item?.GenerateEInfo() : bzlink.Item.Item.SpType == 0 && bzlink.Item.Item.ItemSubType == 4 ? bzlink.Item?.GeneratePslInfo() : bzlink.Item?.GenerateSlInfo()).Replace(' ', '^').Replace("slinfo^", "").Replace("e_info^", ""); } itembazar += $"{bzlink.BazaarItem.BazaarItemId}|{bzlink.BazaarItem?.SellerId}|{bzlink.Owner}|{bzlink.Item.Item.VNum}|{bzlink.Item.Amount}|{(bzlink.BazaarItem.IsPackage ? 1 : 0)}|{bzlink.BazaarItem.Price}|{time}|2|0|{bzlink.Item.Rare}|{bzlink.Item.Upgrade}|{info} "; } return($"rc_blist {packet.Index} {itembazar} "); } catch (Exception ex) { Core.Logger.Error(ex); return(string.Empty); } }