From 9f98aed2a38fa7eb66ba4e8b343bbe9ea7fd080f Mon Sep 17 00:00:00 2001 From: jerry Date: Sun, 10 Nov 2024 23:54:00 +0800 Subject: [PATCH 1/4] feat(Core/AuctionHouse): Implement Auction House getAll scan --- .../game/AuctionHouse/AuctionHouseMgr.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 0d2c96d5dd602e..d263930a19dbe6 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -733,8 +733,26 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player, std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, - uint32& count, uint32& totalcount, uint8 /*getAll*/, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout) + uint32& count, uint32& totalcount, uint8 getAll, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout) { + if (getAll) + { + auto itr = GetAuctionsBegin(); + for (; itr != GetAuctionsEnd(); ++itr) + { + auto auction = itr->second; + Item* item = sAuctionMgr->GetAItem(auction->item_guid); + if (!item) + { + continue; + } + ++count; + ++totalcount; + auction->BuildAuctionInfo(data); + } + return true; + } + uint32 itrcounter = 0; // Ensures that listfrom is not greater that auctions count From e2802f3bcc9e633537acf0d6b39d952c918b1e0e Mon Sep 17 00:00:00 2001 From: jerry Date: Mon, 11 Nov 2024 15:08:34 +0800 Subject: [PATCH 2/4] Codestyle --- src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index d263930a19dbe6..7553331ffc2db9 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -737,18 +737,19 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player { if (getAll) { - auto itr = GetAuctionsBegin(); - for (; itr != GetAuctionsEnd(); ++itr) + for (AuctionEntryMap::iterator itr = GetAuctionsBegin(); itr != GetAuctionsEnd(); ++itr) { - auto auction = itr->second; - Item* item = sAuctionMgr->GetAItem(auction->item_guid); + AuctionEntry* Aentry = itr->second; + if (!Aentry) + continue; + + Item* item = sAuctionMgr->GetAItem(Aentry->item_guid); if (!item) - { continue; - } + ++count; ++totalcount; - auction->BuildAuctionInfo(data); + Aentry->BuildAuctionInfo(data); } return true; } From 1fe46c8dc512c09d03deeee069c59f8e41acbdd1 Mon Sep 17 00:00:00 2001 From: jerry Date: Mon, 11 Nov 2024 16:30:31 +0800 Subject: [PATCH 3/4] Change getAll data type from uint8 to bool --- src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 2 +- src/server/game/AuctionHouse/AuctionHouseMgr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 7553331ffc2db9..2b4d6b1010acb6 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -733,7 +733,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player, std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, - uint32& count, uint32& totalcount, uint8 getAll, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout) + uint32& count, uint32& totalcount, bool getAll, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout) { if (getAll) { diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index d765cf1213ac87..c6105e245e2f11 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -162,7 +162,7 @@ class AuctionHouseObject bool BuildListAuctionItems(WorldPacket& data, Player* player, std::wstring const& searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, - uint32& count, uint32& totalcount, uint8 getAll, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout); + uint32& count, uint32& totalcount, bool getAll, AuctionSortOrderVector const& sortOrder, Milliseconds searchTimeout); private: AuctionEntryMap _auctionsMap; From 162cdfd1b1610dfd14bde433fd86efb4d693e106 Mon Sep 17 00:00:00 2001 From: jerry Date: Mon, 11 Nov 2024 18:08:04 +0800 Subject: [PATCH 4/4] Limits maximum number of items --- src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 3 +++ src/server/game/AuctionHouse/AuctionHouseMgr.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 2b4d6b1010acb6..8b80f49e3ed0dd 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -750,6 +750,9 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player ++count; ++totalcount; Aentry->BuildAuctionInfo(data); + + if (count >= MAX_GETALL_RETURN) + break; } return true; } diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index c6105e245e2f11..14ee007639faa0 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -31,6 +31,7 @@ class Player; #define MIN_AUCTION_TIME (12*HOUR) #define MAX_AUCTION_ITEMS 160 +#define MAX_GETALL_RETURN 55000 enum AuctionError {