aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
diff options
context:
space:
mode:
authorpete318 <pete318@users.noreply.github.com>2016-02-03 00:45:31 +0000
committerShauren <shauren.trinity@gmail.com>2016-04-10 17:48:29 +0200
commit7d5d79aa015b21969a1f5ca75ca3efe8cb842f25 (patch)
treee21f6f3a63c2a4a3a0891fc4348dee866200dd67 /src/server/game/AuctionHouse/AuctionHouseMgr.cpp
parentb23a6aeaff403266491ea75207558bf9917b9cc4 (diff)
Implement AuctionHouse features: GetAll scan and search throttling
Implements two standard features of the Auction House. * GetAll scan, retrieves all auctions and sends them in a single packet. There's a limitation on how often a player can do this (Max 55000 items) * Search throttling. For normal searches, the server can send a time in milliseconds to the client, the client will wait that long between searches. Delay set in config Closes #16469 (cherry picked from commit 3aaeb574050668e5a240078f6e40337c3975d110)
Diffstat (limited to 'src/server/game/AuctionHouse/AuctionHouseMgr.cpp')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp60
1 files changed, 57 insertions, 3 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index ce8815dee07..1ea1099cd96 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -581,6 +581,15 @@ void AuctionHouseObject::Update()
if (AuctionsMap.empty())
return;
+ // Clear expired throttled players
+ for (PlayerGetAllThrottleMap::const_iterator itr = GetAllThrottleMap.begin(); itr != GetAllThrottleMap.end();)
+ {
+ if (itr->second.NextAllowedReplication <= curTime)
+ itr = GetAllThrottleMap.erase(itr);
+ else
+ ++itr;
+ }
+
SQLTransaction trans = CharacterDatabase.BeginTransaction();
for (AuctionEntryMap::iterator it = AuctionsMap.begin(); it != AuctionsMap.end();)
@@ -736,16 +745,61 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPackets::AuctionHouse::Aucti
// Add the item if no search term or if entered search term was found
if (packet.Items.size() < 50 && totalcount >= listfrom)
- Aentry->BuildAuctionInfo(packet.Items, true);
+ Aentry->BuildAuctionInfo(packet.Items, true, item);
++totalcount;
}
}
+void AuctionHouseObject::BuildReplicate(WorldPackets::AuctionHouse::AuctionReplicateResponse& auctionReplicateResult, Player* player,
+ uint32 global, uint32 cursor, uint32 tombstone, uint32 count)
+{
+ time_t curTime = sWorld->GetGameTime();
+
+ auto throttleItr = GetAllThrottleMap.find(player->GetGUID());
+ if (throttleItr != GetAllThrottleMap.end())
+ {
+ if (throttleItr->second.Global != global || throttleItr->second.Cursor != cursor || throttleItr->second.Tombstone != tombstone)
+ return;
+
+ if (!throttleItr->second.IsReplicationInProgress() && throttleItr->second.NextAllowedReplication > curTime)
+ return;
+ }
+ else
+ {
+ throttleItr = GetAllThrottleMap.insert({ player->GetGUID(), PlayerGetAllThrottleData{} }).first;
+ throttleItr->second.NextAllowedReplication = curTime + sWorld->getIntConfig(CONFIG_AUCTION_GETALL_DELAY);
+ throttleItr->second.Global = uint32(curTime);
+ }
+
+ if (AuctionsMap.empty() || !count)
+ return;
+
+ auto itr = AuctionsMap.upper_bound(cursor);
+ for (; itr != AuctionsMap.end(); ++itr)
+ {
+ AuctionEntry* auction = itr->second;
+ if (auction->expire_time < curTime)
+ continue;
+
+ Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
+ if (!item)
+ continue;
+
+ auction->BuildAuctionInfo(auctionReplicateResult.Items, true, item);
+ if (!--count)
+ break;
+ }
+
+ auctionReplicateResult.ChangeNumberGlobal = throttleItr->second.Global;
+ auctionReplicateResult.ChangeNumberCursor = throttleItr->second.Cursor = !auctionReplicateResult.Items.empty() ? auctionReplicateResult.Items.back().AuctionItemID : 0;
+ auctionReplicateResult.ChangeNumberTombstone = throttleItr->second.Tombstone = !count ? AuctionsMap.rbegin()->first : 0;
+}
+
//this function inserts to WorldPacket auction's data
-void AuctionEntry::BuildAuctionInfo(std::vector<WorldPackets::AuctionHouse::AuctionItem>& items, bool listAuctionItems) const
+void AuctionEntry::BuildAuctionInfo(std::vector<WorldPackets::AuctionHouse::AuctionItem>& items, bool listAuctionItems, Item* sourceItem /*= nullptr*/) const
{
- Item* item = sAuctionMgr->GetAItem(itemGUIDLow);
+ Item* item = (sourceItem) ? sourceItem : sAuctionMgr->GetAItem(itemGUIDLow);
if (!item)
{
TC_LOG_ERROR("misc", "AuctionEntry::BuildAuctionInfo: Auction %u has a non-existent item: " UI64FMTD, Id, itemGUIDLow);