Example #1
0
 public void BuildListOwnerItems(AuctionListOwnerItemsResult packet, Player player, ref uint totalcount)
 {
     foreach (var Aentry in AuctionsMap.Values)
     {
         if (Aentry != null && Aentry.owner == player.GetGUID().GetCounter())
         {
             Aentry.BuildAuctionInfo(packet.Items, false);
             ++totalcount;
         }
     }
 }
Example #2
0
        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;
            }
        }
Example #3
0
        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;
            }
        }