aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2019-08-01 00:17:06 +0200
committerShauren <shauren.trinity@gmail.com>2020-03-29 12:23:15 +0200
commitd731ebb4bd53bf88ecaddaaa64a25f95dde68ec7 (patch)
tree2a4ba8f83955cdffe967c1e76dd377e0f9dabddb /src
parent2c1c04a8f643d61bf29185f96d16fe4614e8e3ce (diff)
Core/AuctionHouse: Fixed auction deposit calculation
Closes #23656 (cherry picked from commit 6f7ab817256f3b47c794b7d6431f247f4b785f9f)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 11dc23134d2..70918679211 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -413,10 +413,10 @@ bool AuctionHouseMgr::PendingAuctionAdd(Player* player, AuctionEntry* aEntry, It
// Get deposit so far
uint64 totalDeposit = 0;
for (AuctionEntry const* thisAuction : *thisAH)
- totalDeposit += GetAuctionDeposit(thisAuction->auctionHouseEntry, thisAuction->etime, item, thisAuction->itemCount);
+ totalDeposit += thisAuction->deposit;
// Add this deposit
- totalDeposit += GetAuctionDeposit(aEntry->auctionHouseEntry, aEntry->etime, item, aEntry->itemCount);
+ totalDeposit += aEntry->deposit;
if (!player->HasEnoughMoney(totalDeposit))
return false;
@@ -447,40 +447,34 @@ void AuctionHouseMgr::PendingAuctionProcess(Player* player)
PlayerAuctions* thisAH = iterMap->second.first;
- CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
-
- uint32 totalItems = 0;
- for (auto itrAH = thisAH->begin(); itrAH != thisAH->end(); ++itrAH)
+ uint64 totaldeposit = 0;
+ auto itrAH = thisAH->begin();
+ for (; itrAH != thisAH->end(); ++itrAH)
{
AuctionEntry* AH = (*itrAH);
- totalItems += AH->itemCount;
- }
-
- uint64 totaldeposit = 0;
- auto itr = (*thisAH->begin());
+ if (!player->HasEnoughMoney(totaldeposit + AH->deposit))
+ break;
- if (Item* item = GetAItem(itr->itemGUIDLow))
- totaldeposit = GetAuctionDeposit(itr->auctionHouseEntry, itr->etime, item, totalItems);
+ totaldeposit += AH->deposit;
+ }
- uint64 depositremain = totaldeposit;
- for (auto itrAH = thisAH->begin(); itrAH != thisAH->end(); ++itrAH)
+ // expire auctions we cannot afford
+ if (itrAH != thisAH->end())
{
- AuctionEntry* AH = (*itrAH);
+ CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
- if (next(itrAH) == thisAH->end())
- AH->deposit = depositremain;
- else
+ do
{
- AH->deposit = totaldeposit / thisAH->size();
- depositremain -= AH->deposit;
- }
-
- AH->DeleteFromDB(trans);
+ AuctionEntry* AH = (*itrAH);
+ AH->expire_time = GameTime::GetGameTime();
+ AH->DeleteFromDB(trans);
+ AH->SaveToDB(trans);
+ ++itrAH;
+ } while (itrAH != thisAH->end());
- AH->SaveToDB(trans);
+ CharacterDatabase.CommitTransaction(trans);
}
- CharacterDatabase.CommitTransaction(trans);
pendingAuctionMap.erase(player->GetGUID());
delete thisAH;
player->ModifyMoney(-int64(totaldeposit));