From c4b3884c0c9bed8de59e0ff69fc7fe78ee5aa761 Mon Sep 17 00:00:00 2001 From: Tristan 'Natrist' Cormier Date: Fri, 14 May 2021 03:17:36 -0400 Subject: [PATCH] Fixed a bug that caused the client to crash when listing more than 50.. (#155) .. owned auctions. This is a client limitation. --- .../WorldHandlers/AuctionHouseHandler.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/game/WorldHandlers/AuctionHouseHandler.cpp b/src/game/WorldHandlers/AuctionHouseHandler.cpp index 08cd1616..618e907b 100644 --- a/src/game/WorldHandlers/AuctionHouseHandler.cpp +++ b/src/game/WorldHandlers/AuctionHouseHandler.cpp @@ -351,6 +351,32 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data) GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount()); } + /* The client limits owned auctions to 50: */ + /* Make sure we do not go over this limit, or the client will crash */ + char numTotalOwned = 0; + for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctions().begin(); itr != auctionHouse->GetAuctions().end(); ++itr) + { + AuctionEntry* Aentry = itr->second; + if (Aentry->owner == pl->GetGUIDLow()) + { + Item *pItem = sAuctionMgr.GetAItem(Aentry->itemGuidLow); + if (!pItem) + { + sLog.outError("%s:%d:\tItem %id doesn't exist!", __FILE__, __LINE__, Aentry->itemGuidLow); + } + else + { + numTotalOwned++; + if (numTotalOwned == 50) + { + /* Player already listed 50 auctions; */ + /* Send an internal error result back down to the client... */ + return SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_DATABASE, EQUIP_ERR_OK); + } + } + } + } + pl->ModifyMoney(-int32(deposit)); AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, it, etime, bid, buyout, deposit, pl);