diff options
| author | Shauren <shauren.trinity@gmail.com> | 2016-06-14 21:28:48 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2016-06-14 21:28:48 +0200 |
| commit | 27e08e48e117a3c31e3d45d8bfe5d307d93ebc81 (patch) | |
| tree | 5674e82092b08796214e6ce7f8cf48f90a4629b5 /src/server/game/AuctionHouse/AuctionHouseMgr.cpp | |
| parent | d2733eb6f1f9a550ec6511b5fa696b67b11044b3 (diff) | |
Core/PacketIO: Updated AH and mail packets
Diffstat (limited to 'src/server/game/AuctionHouse/AuctionHouseMgr.cpp')
| -rw-r--r-- | src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 3b3be37b0b3..190ee4d49d8 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -660,8 +660,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPackets::AuctionHouse::Auction } void AuctionHouseObject::BuildListAuctionItems(WorldPackets::AuctionHouse::AuctionListItemsResult& packet, Player* player, - std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, - uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& totalcount) + std::wstring const& searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, bool usable, Optional<AuctionSearchFilters> const& filters, uint32 quality) { time_t curTime = sWorld->GetGameTime(); @@ -677,15 +676,24 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPackets::AuctionHouse::Aucti continue; ItemTemplate const* proto = item->GetTemplate(); + if (filters) + { + // 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->Classes[proto->GetClass()].SubclassMask == AuctionSearchFilters::FILTER_SKIP_CLASS) + continue; - if (itemClass != 0xffffffff && proto->GetClass() != itemClass) - continue; - - if (itemSubClass != 0xffffffff && proto->GetSubClass() != itemSubClass) - continue; + if (filters->Classes[proto->GetClass()].SubclassMask != AuctionSearchFilters::FILTER_SKIP_SUBCLASS) + { + if (!(filters->Classes[proto->GetClass()].SubclassMask & (1 << proto->GetSubClass()))) + continue; - if (inventoryType != 0xffffffff && proto->GetInventoryType() != InventoryType(inventoryType)) - continue; + if (!(filters->Classes[proto->GetClass()].InvTypes[proto->GetSubClass()] & (1 << proto->GetInventoryType()))) + continue; + } + } if (quality != 0xffffffff && proto->GetQuality() != quality) continue; @@ -693,12 +701,12 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPackets::AuctionHouse::Aucti if (levelmin != 0 && (proto->GetBaseRequiredLevel() < levelmin || (levelmax != 0 && proto->GetBaseRequiredLevel() > levelmax))) continue; - if (usable != 0 && player->CanUseItem(item) != EQUIP_ERR_OK) + if (usable && player->CanUseItem(item) != EQUIP_ERR_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 (!wsearchedname.empty()) + if (!searchedname.empty()) { std::string name = proto->GetName(player->GetSession()->GetSessionDbcLocale()); if (name.empty()) @@ -741,15 +749,15 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPackets::AuctionHouse::Aucti } // Perform the search (with or without suffix) - if (!Utf8FitTo(name, wsearchedname)) + if (!Utf8FitTo(name, searchedname)) continue; } // Add the item if no search term or if entered search term was found - if (packet.Items.size() < 50 && totalcount >= listfrom) + if (packet.Items.size() < 50 && packet.TotalCount >= listfrom) Aentry->BuildAuctionInfo(packet.Items, true, item); - ++totalcount; + ++packet.TotalCount; } } @@ -837,6 +845,18 @@ void AuctionEntry::BuildAuctionInfo(std::vector<WorldPackets::AuctionHouse::Auct auctionItem.Enchantments.emplace_back(item->GetEnchantmentId((EnchantmentSlot) i), item->GetEnchantmentDuration((EnchantmentSlot) i), item->GetEnchantmentCharges((EnchantmentSlot) i), i); } + for (std::size_t i = 0; i < item->GetDynamicValues(ITEM_DYNAMIC_FIELD_GEMS).size(); ++i) + { + uint32 gemItemId = item->GetDynamicValue(ITEM_DYNAMIC_FIELD_GEMS, i); + if (!gemItemId) + continue; + + WorldPackets::Item::ItemGemInstanceData gem; + gem.Slot = i; + gem.Item.ItemID = gemItemId; + auctionItem.Gems.push_back(gem); + } + items.emplace_back(auctionItem); } |
