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>2019-08-01 00:17:06 +0200
commit6f7ab817256f3b47c794b7d6431f247f4b785f9f (patch)
treec061e12bc72767f4d7cacb85343ef7a64da97eb6 /src
parentd9ae19d974a8026b0fd4eb8b1d11fa59c758f5d1 (diff)
Core/AuctionHouse: Fixed auction deposit calculation
Closes #23656
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index a8656a7f117..a7c3d02f07e 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -443,10 +443,10 @@ bool AuctionHouseMgr::PendingAuctionAdd(Player* player, AuctionEntry* aEntry, It
// Get deposit so far
uint32 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;
@@ -477,39 +477,34 @@ void AuctionHouseMgr::PendingAuctionProcess(Player* player)
PlayerAuctions* thisAH = iterMap->second.first;
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
- uint32 totalItems = 0;
- for (auto itrAH = thisAH->begin(); itrAH != thisAH->end(); ++itrAH)
+ uint32 totaldeposit = 0;
+ auto itrAH = thisAH->begin();
+ for (; itrAH != thisAH->end(); ++itrAH)
{
AuctionEntry* AH = (*itrAH);
- totalItems += AH->itemCount;
- }
-
- uint32 totaldeposit = 0;
+ if (!player->HasEnoughMoney(totaldeposit + AH->deposit))
+ break;
- AuctionEntry const* entry = thisAH->front();
- if (Item* item = GetAItem(entry->itemGUIDLow))
- totaldeposit = GetAuctionDeposit(entry->auctionHouseEntry, entry->etime, item, totalItems);
+ totaldeposit += AH->deposit;
+ }
- uint32 depositremain = totaldeposit;
- for (auto itr = thisAH->begin(); itr != thisAH->end(); ++itr)
+ // expire auctions we cannot afford
+ if (itrAH != thisAH->end())
{
- AuctionEntry* AH = (*itr);
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
- if (std::next(itr) == thisAH->end())
- AH->deposit = depositremain;
- else
+ do
{
- AH->deposit = totaldeposit / thisAH->size();
- depositremain -= AH->deposit;
- }
+ AuctionEntry* AH = (*itrAH);
+ AH->expire_time = GameTime::GetGameTime();
+ AH->DeleteFromDB(trans);
+ AH->SaveToDB(trans);
+ ++itrAH;
+ } while (itrAH != thisAH->end());
- AH->DeleteFromDB(trans);
- AH->SaveToDB(trans);
+ CharacterDatabase.CommitTransaction(trans);
}
- CharacterDatabase.CommitTransaction(trans);
pendingAuctionMap.erase(player->GetGUID());
delete thisAH;
player->ModifyMoney(-int32(totaldeposit));