//[WorldPacketHandler(ClientOpcodes.AuctionListItems)] void HandleAuctionListItems(AuctionListItems packet) { Creature creature = GetPlayer().GetNPCIfCanInteractWith(packet.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None); if (!creature) { Log.outDebug(LogFilter.Network, "WORLD: HandleAuctionListItems - {0} not found or you can't interact with him.", packet.Auctioneer.ToString()); return; } // remove fake death if (GetPlayer().HasUnitState(UnitState.Died)) { GetPlayer().RemoveAurasByType(AuraType.FeignDeath); } AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction()); Optional <AuctionSearchFilters> filters = new Optional <AuctionSearchFilters>(); AuctionListItemsResult result = new AuctionListItemsResult(); if (!packet.ClassFilters.Empty()) { filters.HasValue = true; foreach (var classFilter in packet.ClassFilters) { if (!classFilter.SubClassFilters.Empty()) { foreach (var subClassFilter in classFilter.SubClassFilters) { filters.Value.Classes[classFilter.ItemClass].SubclassMask |= (AuctionSearchFilters.FilterType)(1 << subClassFilter.ItemSubclass); filters.Value.Classes[classFilter.ItemClass].InvTypes[subClassFilter.ItemSubclass] = subClassFilter.InvTypeMask; } } else { filters.Value.Classes[classFilter.ItemClass].SubclassMask = AuctionSearchFilters.FilterType.SkipSubclass; } } } auctionHouse.BuildListAuctionItems(result, GetPlayer(), packet.Name.ToLower(), packet.Offset, packet.MinLevel, packet.MaxLevel, packet.OnlyUsable, filters, packet.Quality); result.DesiredDelay = WorldConfig.GetUIntValue(WorldCfg.AuctionSearchDelay); result.OnlyUsable = packet.OnlyUsable; SendPacket(result); }
public void BuildListAuctionItems(AuctionListItemsResult packet, Player player, string searchedname, uint listfrom, byte levelmin, byte levelmax, bool usable, Optional <AuctionSearchFilters> filters, uint quality) { long curTime = GameTime.GetGameTime(); foreach (var Aentry in AuctionsMap.Values) { // Skip expired auctions if (Aentry.expire_time < curTime) { continue; } Item item = Global.AuctionMgr.GetAItem(Aentry.itemGUIDLow); if (!item) { continue; } ItemTemplate proto = item.GetTemplate(); if (filters.HasValue) { // if we dont want any class filters, Optional is not initialized // if we dont want this class included, SubclassMask is set to FILTER_SKIP_CLASS // if we want this class and did not specify and subclasses, its set to FILTER_SKIP_SUBCLASS // otherwise full restrictions apply if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask == AuctionSearchFilters.FilterType.SkipClass) { continue; } if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask != AuctionSearchFilters.FilterType.SkipSubclass) { if (!Convert.ToBoolean((int)filters.Value.Classes[(int)proto.GetClass()].SubclassMask & (1u << (int)proto.GetSubClass()))) { continue; } if (!Convert.ToBoolean(filters.Value.Classes[(int)proto.GetClass()].InvTypes[(int)proto.GetSubClass()] & (1u << (int)proto.GetInventoryType()))) { continue; } } } if (quality != 0xffffffff && (uint)proto.GetQuality() != quality) { continue; } if (levelmin != 0 && (item.GetRequiredLevel() < levelmin || (levelmax != 0 && item.GetRequiredLevel() > levelmax))) { continue; } if (usable && player.CanUseItem(item) != InventoryResult.Ok) { continue; } // Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey) // No need to do any of this if no search term was entered if (!string.IsNullOrEmpty(searchedname)) { string name = proto.GetName(player.GetSession().GetSessionDbcLocale()); if (string.IsNullOrEmpty(name)) { continue; } } // Add the item if no search term or if entered search term was found if (packet.Items.Count < 50 && packet.TotalCount >= listfrom) { Aentry.BuildAuctionInfo(packet.Items, true); } ++packet.TotalCount; } }
public void BuildListAuctionItems(AuctionListItemsResult packet, Player player, string searchedname, uint listfrom, byte levelmin, byte levelmax, bool usable, Optional <AuctionSearchFilters> filters, uint quality) { long curTime = Global.WorldMgr.GetGameTime(); foreach (var Aentry in AuctionsMap.Values) { // Skip expired auctions if (Aentry.expire_time < curTime) { continue; } Item item = Global.AuctionMgr.GetAItem(Aentry.itemGUIDLow); if (!item) { continue; } ItemTemplate proto = item.GetTemplate(); if (filters.HasValue) { // if we dont want any class filters, Optional is not initialized // if we dont want this class included, SubclassMask is set to FILTER_SKIP_CLASS // if we want this class and did not specify and subclasses, its set to FILTER_SKIP_SUBCLASS // otherwise full restrictions apply if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask == AuctionSearchFilters.FilterType.SkipClass) { continue; } if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask != AuctionSearchFilters.FilterType.SkipSubclass) { if (!Convert.ToBoolean((int)filters.Value.Classes[(int)proto.GetClass()].SubclassMask & (1u << (int)proto.GetSubClass()))) { continue; } if (!Convert.ToBoolean(filters.Value.Classes[(int)proto.GetClass()].InvTypes[(int)proto.GetSubClass()] & (1u << (int)proto.GetInventoryType()))) { continue; } } } if (quality != 0xffffffff && (uint)proto.GetQuality() != quality) { continue; } if (levelmin != 0 && (proto.GetBaseRequiredLevel() < levelmin || (levelmax != 0x00 && proto.GetBaseRequiredLevel() > levelmax))) { continue; } if (usable && player.CanUseItem(item) != InventoryResult.Ok) { continue; } // Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey) // No need to do any of this if no search term was entered if (!string.IsNullOrEmpty(searchedname)) { string name = proto.GetName(player.GetSession().GetSessionDbcLocale()); if (string.IsNullOrEmpty(name)) { continue; } // DO NOT use GetItemEnchantMod(proto.RandomProperty) as it may return a result // that matches the search but it may not equal item.GetItemRandomPropertyId() // used in BuildAuctionInfo() which then causes wrong items to be listed int propRefID = item.GetItemRandomPropertyId(); if (propRefID != 0) { string suffix = null; // Append the suffix to the name (ie: of the Monkey) if one exists // These are found in ItemRandomProperties.dbc, not ItemRandomSuffix.dbc // even though the DBC names seem misleading if (propRefID < 0) { ItemRandomSuffixRecord itemRandSuffix = CliDB.ItemRandomSuffixStorage.LookupByKey(-propRefID); if (itemRandSuffix != null) { suffix = itemRandSuffix.Name[player.GetSession().GetSessionDbcLocale()]; } } else { ItemRandomPropertiesRecord itemRandProp = CliDB.ItemRandomPropertiesStorage.LookupByKey(propRefID); if (itemRandProp != null) { suffix = itemRandProp.Name[player.GetSession().GetSessionDbcLocale()]; } } // dbc local name if (!string.IsNullOrEmpty(suffix)) { // Append the suffix (ie: of the Monkey) to the name using localization // or default enUS if localization is invalid name += ' ' + suffix; } } } // Add the item if no search term or if entered search term was found if (packet.Items.Count < 50 && packet.TotalCount >= listfrom) { Aentry.BuildAuctionInfo(packet.Items, true); } ++packet.TotalCount; } }