diff options
| author | r00ty-tc <r00ty-tc@users.noreply.github.com> | 2017-02-19 00:47:59 +0000 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-07-21 21:06:54 +0200 |
| commit | 83e277724945a8849c93cf041ecb071a76c4c7b4 (patch) | |
| tree | f43d4777c5b9e64c64aca2f2c85364a6dd40c23a /src/server/game/Handlers/AuctionHouseHandler.cpp | |
| parent | 00454fdd4551bff2d7dbac35fdc92c7ed795fa53 (diff) | |
[Core/AH] Correctly check player can pay deposit
- Deposit amount wasn't correctly checked in the case of multiple items,
player with insufficient funds could auctin more items than they should
(cherrypicked from 6bd9aa27872cd0d76d785bc38162001c4bacd913)
Diffstat (limited to 'src/server/game/Handlers/AuctionHouseHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/AuctionHouseHandler.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 6c29619d38b..6cc5c0b3012 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -268,10 +268,16 @@ void WorldSession::HandleAuctionSellItem(WorldPackets::AuctionHouse::AuctionSell TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: %s %s is selling item %s %s to auctioneer " UI64FMTD " with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetTemplate()->GetDefaultLocaleName(), AH->auctioneer, item->GetCount(), packet.MinBid, packet.BuyoutPrice, auctionTime, AH->GetHouseId()); + + // Add to pending auctions, or fail with insufficient funds error + if (!sAuctionMgr->PendingAuctionAdd(_player, AH, item)) + { + SendAuctionCommandResult(AH, AUCTION_SELL_ITEM, ERR_AUCTION_NOT_ENOUGHT_MONEY); + return; + } + sAuctionMgr->AddAItem(item); auctionHouse->AddAuction(AH); - sAuctionMgr->PendingAuctionAdd(_player, AH); - _player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true); SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -319,9 +325,16 @@ void WorldSession::HandleAuctionSellItem(WorldPackets::AuctionHouse::AuctionSell TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: %s %s is selling %s %s to auctioneer " UI64FMTD " with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), newItem->GetGUID().ToString().c_str(), newItem->GetTemplate()->GetDefaultLocaleName(), AH->auctioneer, newItem->GetCount(), packet.MinBid, packet.BuyoutPrice, auctionTime, AH->GetHouseId()); + + // Add to pending auctions, or fail with insufficient funds error + if (!sAuctionMgr->PendingAuctionAdd(_player, AH, newItem)) + { + SendAuctionCommandResult(AH, AUCTION_SELL_ITEM, ERR_AUCTION_NOT_ENOUGHT_MONEY); + return; + } + sAuctionMgr->AddAItem(newItem); auctionHouse->AddAuction(AH); - sAuctionMgr->PendingAuctionAdd(_player, AH); for (std::size_t i = 0; i < packet.Items.size(); ++i) { |
