aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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));