mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Move auction related code from ObjectMgr to AuctionHouseMgr.
This commit is contained in:
parent
ef1c243187
commit
7c3ab4b453
12 changed files with 572 additions and 513 deletions
|
|
@ -81,7 +81,7 @@ void WorldSession::SendAuctionHello( uint64 guid, Creature* unit )
|
|||
//this function inserts to WorldPacket auction's data
|
||||
bool WorldSession::SendAuctionInfo(WorldPacket & data, AuctionEntry* auction)
|
||||
{
|
||||
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
|
||||
Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
|
||||
if (!pItem)
|
||||
{
|
||||
sLog.outError("auction to item, that doesn't exist !!!!");
|
||||
|
|
@ -104,7 +104,7 @@ bool WorldSession::SendAuctionInfo(WorldPacket & data, AuctionEntry* auction)
|
|||
data << (uint32) 0; //Unknown
|
||||
data << (uint64) auction->owner; //Auction->owner
|
||||
data << (uint32) auction->startbid; //Auction->startbid (not sure if useful)
|
||||
data << (uint32) ((auction->bid)? objmgr.GetAuctionOutBid(auction->bid) : 0);
|
||||
data << (uint32) ((auction->bid)? auctionmgr.GetAuctionOutBid(auction->bid) : 0);
|
||||
//minimal outbid
|
||||
data << (uint32) auction->buyout; //auction->buyout
|
||||
data << (uint32) (auction->time - time(NULL)) * 1000; //time left
|
||||
|
|
@ -170,7 +170,7 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri
|
|||
msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED;
|
||||
|
||||
if (oldBidder)
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template);
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, auctionmgr.GetAuctionOutBid(auction->bid), auction->item_template);
|
||||
|
||||
WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
|||
|
||||
Item *it = pl->GetItemByGuid( item );
|
||||
//do not allow to sell already auctioned items
|
||||
if(objmgr.GetAItem(GUID_LOPART(item)))
|
||||
if(auctionmgr.GetAItem(GUID_LOPART(item)))
|
||||
{
|
||||
sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
|
||||
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
|
||||
|
|
@ -264,10 +264,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
|||
|
||||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
AuctionHouseObject * mAuctions;
|
||||
mAuctions = objmgr.GetAuctionsMap( location );
|
||||
mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
//we have to take deposit :
|
||||
uint32 deposit = objmgr.GetAuctionDeposit( location, etime, it );
|
||||
uint32 deposit = auctionmgr.GetAuctionDeposit( location, etime, it );
|
||||
if ( pl->GetMoney() < deposit )
|
||||
{
|
||||
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
|
||||
|
|
@ -301,7 +301,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
|||
sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in location: %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, location);
|
||||
mAuctions->AddAuction(AH);
|
||||
|
||||
objmgr.AddAItem(it);
|
||||
auctionmgr.AddAItem(it);
|
||||
pl->MoveItemFromInventory( it->GetBagSlot(), it->GetSlot(), true);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
|
|
@ -344,7 +344,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
|||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
|
||||
AuctionHouseObject * mAuctions;
|
||||
mAuctions = objmgr.GetAuctionsMap( location );
|
||||
mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
AuctionEntry *auction = mAuctions->GetAuction(auctionId);
|
||||
Player *pl = GetPlayer();
|
||||
|
|
@ -371,7 +371,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
|||
|
||||
// price too low for next bid if not buyout
|
||||
if ((price < auction->buyout || auction->buyout == 0) &&
|
||||
price < auction->bid + objmgr.GetAuctionOutBid(auction->bid))
|
||||
price < auction->bid + auctionmgr.GetAuctionOutBid(auction->bid))
|
||||
{
|
||||
//auction has already higher bid, client tests it!
|
||||
return;
|
||||
|
|
@ -429,13 +429,13 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
|||
auction->bidder = pl->GetGUIDLow();
|
||||
auction->bid = auction->buyout;
|
||||
|
||||
objmgr.SendAuctionSalePendingMail( auction );
|
||||
objmgr.SendAuctionSuccessfulMail( auction );
|
||||
objmgr.SendAuctionWonMail( auction );
|
||||
auctionmgr.SendAuctionSalePendingMail( auction );
|
||||
auctionmgr.SendAuctionSuccessfulMail( auction );
|
||||
auctionmgr.SendAuctionWonMail( auction );
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
|
||||
|
||||
objmgr.RemoveAItem(auction->item_guidlow);
|
||||
auctionmgr.RemoveAItem(auction->item_guidlow);
|
||||
mAuctions->RemoveAuction(auction->Id);
|
||||
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
|
||||
|
||||
|
|
@ -471,19 +471,19 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
|||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
|
||||
AuctionHouseObject * mAuctions;
|
||||
mAuctions = objmgr.GetAuctionsMap( location );
|
||||
mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
AuctionEntry *auction = mAuctions->GetAuction(auctionId);
|
||||
Player *pl = GetPlayer();
|
||||
|
||||
if (auction && auction->owner == pl->GetGUIDLow())
|
||||
{
|
||||
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
|
||||
Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
|
||||
if (pItem)
|
||||
{
|
||||
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
|
||||
{
|
||||
uint32 auctionCut = objmgr.GetAuctionCut( auction->location, auction->bid);
|
||||
uint32 auctionCut = auctionmgr.GetAuctionCut( auction->location, auction->bid);
|
||||
if ( pl->GetMoney() < auctionCut ) //player doesn't have enough money, maybe message needed
|
||||
return;
|
||||
//some auctionBidderNotification would be needed, but don't know that parts..
|
||||
|
|
@ -522,7 +522,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
|||
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
objmgr.RemoveAItem( auction->item_guidlow );
|
||||
auctionmgr.RemoveAItem( auction->item_guidlow );
|
||||
mAuctions->RemoveAuction( auction->Id );
|
||||
delete auction;
|
||||
}
|
||||
|
|
@ -557,7 +557,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
|||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
|
||||
AuctionHouseObject* mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
|
||||
Player *pl = GetPlayer();
|
||||
|
|
@ -616,7 +616,7 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
|||
|
||||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
|
||||
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
|
||||
AuctionHouseObject* mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) );
|
||||
data << (uint32) 0; // amount place holder
|
||||
|
|
@ -672,7 +672,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
|||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
|
||||
AuctionHouseObject * mAuctions = objmgr.GetAuctionsMap( location );
|
||||
AuctionHouseObject * mAuctions = auctionmgr.GetAuctionsMap( location );
|
||||
|
||||
//sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
|
||||
|
||||
|
|
@ -691,7 +691,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
|||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
|
||||
{
|
||||
AuctionEntry *Aentry = itr->second;
|
||||
Item *item = objmgr.GetAItem(Aentry->item_guidlow);
|
||||
Item *item = auctionmgr.GetAItem(Aentry->item_guidlow);
|
||||
if( item )
|
||||
{
|
||||
ItemPrototype const *proto = item->GetProto();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue