mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
* Add some more transactioncontrol on auctionhouse actions, ensuring database consistency
--HG-- branch : trunk
This commit is contained in:
@@ -382,6 +382,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
||||
|
||||
// after this update we should save player's money ...
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);
|
||||
@@ -406,12 +407,13 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
auctionmgr.SendAuctionWonMail(auction);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
auction->DeleteFromDB();
|
||||
uint32 item_template = auction->item_template;
|
||||
auctionmgr.RemoveAItem(auction->item_guidlow);
|
||||
auctionHouse->RemoveAuction(auction, item_template);
|
||||
}
|
||||
CharacterDatabase.BeginTransaction();
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
@@ -481,14 +483,15 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||
|
||||
//inform player, that auction is removed
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_CANCEL, AUCTION_OK);
|
||||
|
||||
// Now remove the auction
|
||||
CharacterDatabase.BeginTransaction();
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
auction->DeleteFromDB();
|
||||
uint32 item_template = auction->item_template;
|
||||
auctionmgr.RemoveAItem(auction->item_guidlow);
|
||||
auctionHouse->RemoveAuction(auction, item_template);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
//called when player lists his bids
|
||||
|
||||
@@ -77,20 +77,15 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
|
||||
else
|
||||
deposit = 0;
|
||||
|
||||
sLog.outDebug("SellPrice:\t\t%u", MSV);
|
||||
sLog.outDebug("Deposit Percent:\t%f", ((double)entry->depositPercent / 100.0f));
|
||||
sLog.outDebug("Auction Time1:\t\t%u", time);
|
||||
sLog.outDebug("Auction Time2:\t\t%u", MIN_AUCTION_TIME);
|
||||
sLog.outDebug("Auction Time3:\t\t%u", timeHr);
|
||||
sLog.outDebug("Count:\t\t\t%u", pItem->GetCount());
|
||||
sLog.outDebug("Sellprice: %u / Depositpercent: %f / AT1: %u / AT2: %u / AT3: %u / Count: %u", MSV, ((double)entry->depositPercent / 100.0f), time, MIN_AUCTION_TIME, timeHr, pItem->GetCount() );
|
||||
if (deposit > 0)
|
||||
{
|
||||
sLog.outDebug("Deposit:\t\t%u", deposit);
|
||||
sLog.outDebug("Deposit: %u", deposit);
|
||||
return deposit;
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outDebug("Deposit:\t\t0");
|
||||
sLog.outDebug("Deposit: 0");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +150,6 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
|
||||
// set owner to bidder (to prevent delete item with sender char deleting)
|
||||
// owner in `data` will set at mail receive and item extracting
|
||||
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
if (bidder)
|
||||
bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template);
|
||||
@@ -539,10 +533,12 @@ void AuctionHouseObject::Update()
|
||||
}
|
||||
|
||||
///- In any case clear the auction
|
||||
CharacterDatabase.BeginTransaction();
|
||||
auction->DeleteFromDB();
|
||||
uint32 item_template = auction->item_template;
|
||||
auctionmgr.RemoveAItem(auction->item_guidlow);
|
||||
RemoveAuction(auction, item_template);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user