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/AuctionHouse/AuctionHouseMgr.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/AuctionHouse/AuctionHouseMgr.cpp')
| -rw-r--r-- | src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 4118ea902f5..253570dcba1 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -402,18 +402,32 @@ bool AuctionHouseMgr::RemoveAItem(ObjectGuid::LowType id, bool deleteItem) return true; } -void AuctionHouseMgr::PendingAuctionAdd(Player* player, AuctionEntry* aEntry) +bool AuctionHouseMgr::PendingAuctionAdd(Player* player, AuctionEntry* aEntry, Item* item) { PlayerAuctions* thisAH; auto itr = pendingAuctionMap.find(player->GetGUID()); if (itr != pendingAuctionMap.end()) + { thisAH = itr->second.first; + + // Get deposit so far + uint64 totalDeposit = 0; + for (AuctionEntry const* thisAuction : *thisAH) + totalDeposit += GetAuctionDeposit(thisAuction->auctionHouseEntry, thisAuction->etime, item, thisAuction->itemCount); + + // Add this deposit + totalDeposit += GetAuctionDeposit(aEntry->auctionHouseEntry, aEntry->etime, item, aEntry->itemCount); + + if (!player->HasEnoughMoney(totalDeposit)) + return false; + } else { thisAH = new PlayerAuctions; pendingAuctionMap[player->GetGUID()] = AuctionPair(thisAH, 0); } thisAH->push_back(aEntry); + return true; } uint32 AuctionHouseMgr::PendingAuctionCount(const Player* player) const @@ -462,6 +476,7 @@ void AuctionHouseMgr::PendingAuctionProcess(Player* player) } AH->DeleteFromDB(trans); + AH->SaveToDB(trans); } |
