AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AuctionHouseMgr Class Reference

#include "AuctionHouseMgr.h"

Public Types

typedef std::unordered_map< ObjectGuid, Item * > ItemMap
 

Public Member Functions

AuctionHouseObjectGetAuctionsMap (uint32 factionTemplateId)
 
AuctionHouseObjectGetAuctionsMapByHouseId (uint8 auctionHouseId)
 
ItemGetAItem (ObjectGuid itemGuid)
 
void SendAuctionWonMail (AuctionEntry *auction, CharacterDatabaseTransaction trans, bool sendNotification=true, bool updateAchievementCriteria=true, bool sendMail=true)
 
void SendAuctionSalePendingMail (AuctionEntry *auction, CharacterDatabaseTransaction trans, bool sendMail=true)
 
void SendAuctionSuccessfulMail (AuctionEntry *auction, CharacterDatabaseTransaction trans, bool sendNotification=true, bool updateAchievementCriteria=true, bool sendMail=true)
 
void SendAuctionExpiredMail (AuctionEntry *auction, CharacterDatabaseTransaction trans, bool sendNotification=true, bool sendMail=true)
 
void SendAuctionOutbiddedMail (AuctionEntry *auction, uint32 newPrice, Player *newBidder, CharacterDatabaseTransaction trans, bool sendNotification=true, bool sendMail=true)
 
void SendAuctionCancelledToBidderMail (AuctionEntry *auction, CharacterDatabaseTransaction trans, bool sendMail=true)
 
void LoadAuctionItems ()
 
void LoadAuctions ()
 
void AddAItem (Item *it)
 
bool RemoveAItem (ObjectGuid itemGuid, bool deleteFromDB=false, CharacterDatabaseTransaction *trans=nullptr)
 
void Update ()
 

Static Public Member Functions

static AuctionHouseMgrinstance ()
 
static uint32 GetAuctionDeposit (AuctionHouseEntry const *entry, uint32 time, Item *pItem, uint32 count)
 
static AuctionHouseEntry const * GetAuctionHouseEntry (uint32 factionTemplateId)
 
static AuctionHouseEntry const * GetAuctionHouseEntryFromHouse (uint8 houseId)
 

Private Member Functions

 AuctionHouseMgr ()
 
 ~AuctionHouseMgr ()
 

Private Attributes

AuctionHouseObject _hordeAuctions
 
AuctionHouseObject _allianceAuctions
 
AuctionHouseObject _neutralAuctions
 
ItemMap _mAitems
 

Detailed Description

Member Typedef Documentation

◆ ItemMap

typedef std::unordered_map<ObjectGuid, Item*> AuctionHouseMgr::ItemMap

Constructor & Destructor Documentation

◆ AuctionHouseMgr()

AuctionHouseMgr::AuctionHouseMgr ( )
private
216{
217}

◆ ~AuctionHouseMgr()

AuctionHouseMgr::~AuctionHouseMgr ( )
private
220{
221 for (ItemMap::iterator itr = _mAitems.begin(); itr != _mAitems.end(); ++itr)
222 delete itr->second;
223}
ItemMap _mAitems
Definition: AuctionHouseMgr.h:224

References _mAitems.

Member Function Documentation

◆ AddAItem()

void AuctionHouseMgr::AddAItem ( Item it)
578{
579 ASSERT(it);
580 ASSERT(_mAitems.find(it->GetGUID()) == _mAitems.end());
581 _mAitems[it->GetGUID()] = it;
582}
#define ASSERT
Definition: Errors.h:68
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112

References _mAitems, ASSERT, and Object::GetGUID().

Referenced by LoadAuctionItems().

◆ GetAItem()

Item * AuctionHouseMgr::GetAItem ( ObjectGuid  itemGuid)
inline
189 {
190 ItemMap::const_iterator itr = _mAitems.find(itemGuid);
191 if (itr != _mAitems.end())
192 return itr->second;
193
194 return nullptr;
195 }

References _mAitems.

Referenced by SendAuctionExpiredMail(), and SendAuctionWonMail().

◆ GetAuctionDeposit()

uint32 AuctionHouseMgr::GetAuctionDeposit ( AuctionHouseEntry const *  entry,
uint32  time,
Item pItem,
uint32  count 
)
static
266{
267 uint32 MSV = pItem->GetTemplate()->SellPrice;
268
269 if (MSV <= 0)
271
272 float multiplier = CalculatePct(float(entry->depositPercent), 3);
273 uint32 timeHr = (((time / 60) / 60) / 12);
274 uint32 deposit = uint32(((multiplier * MSV * count / 3) * timeHr * 3) * sWorld->getRate(RATE_AUCTION_DEPOSIT));
275
276 LOG_DEBUG("auctionHouse", "MSV: {}", MSV);
277 LOG_DEBUG("auctionHouse", "Items: {}", count);
278 LOG_DEBUG("auctionHouse", "Multiplier: {}", multiplier);
279 LOG_DEBUG("auctionHouse", "Deposit: {}", deposit);
280
281 if (deposit < AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT))
283 else
284 return deposit;
285}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
T CalculatePct(T base, U pct)
Definition: Util.h:61
std::uint32_t uint32
Definition: Define.h:107
constexpr auto AH_MINIMUM_DEPOSIT
Definition: AuctionHouseMgr.cpp:33
@ RATE_AUCTION_DEPOSIT
Definition: IWorld.h:507
#define sWorld
Definition: World.h:443
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:544
uint32 SellPrice
Definition: ItemTemplate.h:631

References AH_MINIMUM_DEPOSIT, CalculatePct(), AuctionHouseEntry::depositPercent, Item::GetTemplate(), LOG_DEBUG, RATE_AUCTION_DEPOSIT, ItemTemplate::SellPrice, and sWorld.

◆ GetAuctionHouseEntry()

AuctionHouseEntry const * AuctionHouseMgr::GetAuctionHouseEntry ( uint32  factionTemplateId)
static
610{
611 uint32 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
612
614 {
615 //FIXME: found way for proper auctionhouse selection by another way
616 // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
617 // but no easy way convert creature faction to player race faction for specific city
618 FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
619 if (!u_entry)
620 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
621 else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
622 houseid = AUCTIONHOUSE_ALLIANCE; // human auction house
623 else if (u_entry->ourMask & FACTION_MASK_HORDE)
624 houseid = AUCTIONHOUSE_HORDE; // orc auction house
625 else
626 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
627 }
628
629 return sAuctionHouseStore.LookupEntry(houseid);
630}
@ FACTION_MASK_ALLIANCE
Definition: DBCEnums.h:338
@ FACTION_MASK_HORDE
Definition: DBCEnums.h:339
@ AUCTIONHOUSE_HORDE
Definition: AuctionHouseMgr.h:69
@ AUCTIONHOUSE_ALLIANCE
Definition: AuctionHouseMgr.h:68
@ AUCTIONHOUSE_NEUTRAL
Definition: AuctionHouseMgr.h:70
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
Definition: IWorld.h:78
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< AuctionHouseEntry > sAuctionHouseStore(AuctionHouseEntryfmt)
Definition: DBCStructure.h:938
uint32 ourMask
Definition: DBCStructure.h:942

References AUCTIONHOUSE_ALLIANCE, AUCTIONHOUSE_HORDE, AUCTIONHOUSE_NEUTRAL, CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, FACTION_MASK_ALLIANCE, FACTION_MASK_HORDE, FactionTemplateEntry::ourMask, sAuctionHouseStore, sFactionTemplateStore, and sWorld.

Referenced by WorldSession::HandleAuctionSellItem(), and WorldSession::SendAuctionHello().

◆ GetAuctionHouseEntryFromHouse()

AuctionHouseEntry const * AuctionHouseMgr::GetAuctionHouseEntryFromHouse ( uint8  houseId)
static

◆ GetAuctionsMap()

AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap ( uint32  factionTemplateId)
232{
234 return &_neutralAuctions;
235
236 // team have linked auction houses
237 FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
238 if (!u_entry)
239 return &_neutralAuctions;
240 else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
241 return &_allianceAuctions;
242 else if (u_entry->ourMask & FACTION_MASK_HORDE)
243 return &_hordeAuctions;
244
245 return &_neutralAuctions;
246}
AuctionHouseObject _hordeAuctions
Definition: AuctionHouseMgr.h:220
AuctionHouseObject _allianceAuctions
Definition: AuctionHouseMgr.h:221
AuctionHouseObject _neutralAuctions
Definition: AuctionHouseMgr.h:222

References _allianceAuctions, _hordeAuctions, _neutralAuctions, CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, FACTION_MASK_ALLIANCE, FACTION_MASK_HORDE, FactionTemplateEntry::ourMask, sFactionTemplateStore, and sWorld.

◆ GetAuctionsMapByHouseId()

AuctionHouseObject * AuctionHouseMgr::GetAuctionsMapByHouseId ( uint8  auctionHouseId)
249{
251 return &_neutralAuctions;
252
253 switch (auctionHouseId)
254 {
256 return &_allianceAuctions;
258 return &_hordeAuctions;
259 break;
260 }
261
262 return &_neutralAuctions;
263}

References _allianceAuctions, _hordeAuctions, _neutralAuctions, AUCTIONHOUSE_ALLIANCE, AUCTIONHOUSE_HORDE, CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, and sWorld.

Referenced by LoadAuctions().

◆ instance()

AuctionHouseMgr * AuctionHouseMgr::instance ( )
static
226{
228 return &instance;
229}
Definition: AuctionHouseMgr.h:175
static AuctionHouseMgr * instance()
Definition: AuctionHouseMgr.cpp:225

References instance().

Referenced by instance().

◆ LoadAuctionItems()

void AuctionHouseMgr::LoadAuctionItems ( )
484{
485 uint32 oldMSTime = getMSTime();
486
487 // need to clear in case we are reloading
488 if (!_mAitems.empty())
489 {
490 for (ItemMap::iterator itr = _mAitems.begin(); itr != _mAitems.end(); ++itr)
491 delete itr->second;
492
493 _mAitems.clear();
494 }
495
496 // data needs to be at first place for Item::LoadFromDB
498 PreparedQueryResult result = CharacterDatabase.Query(stmt);
499
500 if (!result)
501 {
502 LOG_WARN("server.loading", ">> Loaded 0 auction items. DB table `auctionhouse` or `item_instance` is empty!");
503 LOG_INFO("server.loading", " ");
504 return;
505 }
506
507 uint32 count = 0;
508
509 do
510 {
511 Field* fields = result->Fetch();
512
513 ObjectGuid::LowType item_guid = fields[11].Get<uint32>();
514 uint32 item_template = fields[12].Get<uint32>();
515
516 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template);
517 if (!proto)
518 {
519 LOG_ERROR("auctionHouse", "AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: {} id: #{}) in auction, skipped.", item_guid, item_template);
520 continue;
521 }
522
523 Item* item = NewItemOrBag(proto);
524 if (!item->LoadFromDB(item_guid, ObjectGuid::Empty, fields, item_template))
525 {
526 delete item;
527 continue;
528 }
529 AddAItem(item);
530
531 ++count;
532 } while (result->NextRow());
533
534 LOG_INFO("server.loading", ">> Loaded {} auction items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
535 LOG_INFO("server.loading", " ");
536}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
#define sObjectMgr
Definition: ObjectMgr.h:1635
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:67
@ CHAR_SEL_AUCTION_ITEMS
Definition: CharacterDatabase.h:104
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:157
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
void AddAItem(Item *it)
Definition: AuctionHouseMgr.cpp:577
Definition: Item.h:220
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
Definition: Item.cpp:419
Definition: ItemTemplate.h:619
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
uint32 LowType
Definition: ObjectGuid.h:122

References _mAitems, AddAItem(), CHAR_SEL_AUCTION_ITEMS, CharacterDatabase, ObjectGuid::Empty, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), Item::LoadFromDB(), LOG_ERROR, LOG_INFO, LOG_WARN, NewItemOrBag(), and sObjectMgr.

◆ LoadAuctions()

void AuctionHouseMgr::LoadAuctions ( )
539{
540 uint32 oldMSTime = getMSTime();
541
543 PreparedQueryResult result = CharacterDatabase.Query(stmt);
544
545 if (!result)
546 {
547 LOG_WARN("server.loading", ">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
548 LOG_INFO("server.loading", " ");
549 return;
550 }
551
552 uint32 count = 0;
553
554 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
555 do
556 {
557 Field* fields = result->Fetch();
558
559 AuctionEntry* aItem = new AuctionEntry();
560 if (!aItem->LoadFromDB(fields))
561 {
562 aItem->DeleteFromDB(trans);
563 delete aItem;
564 continue;
565 }
566
568 count++;
569 } while (result->NextRow());
570
571 CharacterDatabase.CommitTransaction(trans);
572
573 LOG_INFO("server.loading", ">> Loaded {} auctions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
574 LOG_INFO("server.loading", " ");
575}
@ CHAR_SEL_AUCTIONS
Definition: CharacterDatabase.h:108
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
Definition: AuctionHouseMgr.h:101
void DeleteFromDB(CharacterDatabaseTransaction trans) const
Definition: AuctionHouseMgr.cpp:985
bool LoadFromDB(Field *fields)
Definition: AuctionHouseMgr.cpp:1008
uint8 houseId
Definition: AuctionHouseMgr.h:103
void AddAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:637
AuctionHouseObject * GetAuctionsMapByHouseId(uint8 auctionHouseId)
Definition: AuctionHouseMgr.cpp:248

References AuctionHouseObject::AddAuction(), CHAR_SEL_AUCTIONS, CharacterDatabase, AuctionEntry::DeleteFromDB(), GetAuctionsMapByHouseId(), getMSTime(), GetMSTimeDiffToNow(), AuctionEntry::houseId, AuctionEntry::LoadFromDB(), LOG_INFO, and LOG_WARN.

◆ RemoveAItem()

bool AuctionHouseMgr::RemoveAItem ( ObjectGuid  itemGuid,
bool  deleteFromDB = false,
CharacterDatabaseTransaction trans = nullptr 
)
585{
586 ItemMap::iterator i = _mAitems.find(itemGuid);
587 if (i == _mAitems.end())
588 return false;
589
590 if (deleteFromDB)
591 {
592 ASSERT(trans);
593 i->second->FSetState(ITEM_REMOVED);
594 i->second->SaveToDB(*trans);
595 }
596
597 _mAitems.erase(i);
598 return true;
599}
@ ITEM_REMOVED
Definition: Item.h:212

References _mAitems, ASSERT, and ITEM_REMOVED.

◆ SendAuctionCancelledToBidderMail()

void AuctionHouseMgr::SendAuctionCancelledToBidderMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendMail = true 
)
463{
465
466 uint32 bidder_accId = 0;
467 if (!bidder)
468 {
469 bidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
470 }
471
472 // bidder exist
473 if (bidder || bidder_accId)
474 {
475 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(this, auction, bidder, bidder_accId, sendMail);
476 if (sendMail) // can be changed in the hook
478 .AddMoney(auction->bid)
479 .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
480 }
481}
@ AUCTION_CANCELLED_TO_BIDDER
Definition: AuctionHouseMgr.h:61
#define sCharacterCache
Definition: CharacterCache.h:83
@ MAIL_CHECK_MASK_COPIED
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:49
#define sScriptMgr
Definition: ScriptMgr.h:709
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:257
uint32 bid
Definition: AuctionHouseMgr.h:109
static std::string BuildAuctionMailBody(ObjectGuid guid, uint32 bid, uint32 buyout, uint32 deposit=0, uint32 cut=0, uint32 moneyDelay=0, uint32 eta=0)
Definition: AuctionHouseMgr.cpp:1047
ObjectGuid bidder
Definition: AuctionHouseMgr.h:112
std::string BuildAuctionMailSubject(MailAuctionAnswers response) const
Definition: AuctionHouseMgr.cpp:1040
uint32 buyout
Definition: AuctionHouseMgr.h:110
uint32 deposit
Definition: AuctionHouseMgr.h:113
ObjectGuid owner
Definition: AuctionHouseMgr.h:107
LowType GetCounter() const
Definition: ObjectGuid.h:145
Definition: Player.h:1081
Definition: Mail.h:105
Definition: Mail.h:119
MailDraft & AddMoney(uint32 money)
Definition: Mail.h:137
void SendMailTo(CharacterDatabaseTransaction trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0, uint32 custom_expiration=0, bool deleteMailItemsFromDB=false, bool sendMail=true)
Definition: Mail.cpp:185

References MailDraft::AddMoney(), AUCTION_CANCELLED_TO_BIDDER, AuctionEntry::bid, AuctionEntry::bidder, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, AuctionEntry::deposit, ObjectAccessor::FindConnectedPlayer(), ObjectGuid::GetCounter(), MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, sCharacterCache, MailDraft::SendMailTo(), and sScriptMgr.

◆ SendAuctionExpiredMail()

void AuctionHouseMgr::SendAuctionExpiredMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendNotification = true,
bool  sendMail = true 
)
411{
412 //return an item in auction to its owner by mail
413 Item* pItem = GetAItem(auction->item_guid);
414 if (!pItem)
415 return;
416
418 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
419
420 // owner exist
421 if (owner || owner_accId)
422 {
423 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(this, auction, owner, owner_accId, sendNotification, sendMail);
424
425 if (owner && sendNotification) // can be changed in the hook
426 owner->GetSession()->SendAuctionOwnerNotification(auction);
427
428 if (sendMail) // can be changed in the hook
430 .AddItem(pItem)
431 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0);
432 }
433 else
434 sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
435}
@ AUCTION_EXPIRED
Definition: AuctionHouseMgr.h:60
#define sAuctionMgr
Definition: AuctionHouseMgr.h:227
ObjectGuid item_guid
Definition: AuctionHouseMgr.h:104
Item * GetAItem(ObjectGuid itemGuid)
Definition: AuctionHouseMgr.h:188
WorldSession * GetSession() const
Definition: Player.h:1998
MailDraft & AddItem(Item *item)
Definition: Mail.cpp:93
void SendAuctionOwnerNotification(AuctionEntry *auction)
Definition: AuctionHouseHandler.cpp:102

References MailDraft::AddItem(), AUCTION_EXPIRED, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, AuctionEntry::deposit, ObjectGuid::Empty, ObjectAccessor::FindConnectedPlayer(), GetAItem(), ObjectGuid::GetCounter(), Player::GetSession(), AuctionEntry::item_guid, MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, sAuctionMgr, sCharacterCache, WorldSession::SendAuctionOwnerNotification(), MailDraft::SendMailTo(), and sScriptMgr.

◆ SendAuctionOutbiddedMail()

void AuctionHouseMgr::SendAuctionOutbiddedMail ( AuctionEntry auction,
uint32  newPrice,
Player newBidder,
CharacterDatabaseTransaction  trans,
bool  sendNotification = true,
bool  sendMail = true 
)
439{
441
442 uint32 oldBidder_accId = 0;
443 if (!oldBidder)
444 oldBidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
445
446 // old bidder exist
447 if (oldBidder || oldBidder_accId)
448 {
449 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(this, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail);
450
451 if (oldBidder && newBidder && sendNotification) // can be changed in the hook
452 oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
453
454 if (sendMail) // can be changed in the hook
456 .AddMoney(auction->bid)
457 .SendMailTo(trans, MailReceiver(oldBidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
458 }
459}
@ AUCTION_OUTBIDDED
Definition: AuctionHouseMgr.h:57
uint32 GetAuctionOutBid() const
the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
Definition: AuctionHouseMgr.cpp:979
uint8 GetHouseId() const
Definition: AuctionHouseMgr.h:117
uint32 Id
Definition: AuctionHouseMgr.h:102
uint32 GetAuctionCut() const
Definition: AuctionHouseMgr.cpp:972
uint32 item_template
Definition: AuctionHouseMgr.h:105
void SendAuctionBidderNotification(uint32 location, uint32 auctionId, ObjectGuid bidder, uint32 bidSum, uint32 diff, uint32 item_template)
Definition: AuctionHouseHandler.cpp:88

References MailDraft::AddMoney(), AUCTION_OUTBIDDED, AuctionEntry::bid, AuctionEntry::bidder, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, AuctionEntry::deposit, ObjectAccessor::FindConnectedPlayer(), AuctionEntry::GetAuctionCut(), AuctionEntry::GetAuctionOutBid(), ObjectGuid::GetCounter(), Object::GetGUID(), AuctionEntry::GetHouseId(), Player::GetSession(), AuctionEntry::Id, AuctionEntry::item_template, MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, sCharacterCache, WorldSession::SendAuctionBidderNotification(), MailDraft::SendMailTo(), and sScriptMgr.

◆ SendAuctionSalePendingMail()

void AuctionHouseMgr::SendAuctionSalePendingMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendMail = true 
)
339{
341 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
342 // owner exist (online or offline)
343 if (owner || owner_accId)
344 {
345 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(this, auction, owner, owner_accId, sendMail);
346
347 uint32 deliveryDelay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
348
349 ByteBuffer timePacker;
350 timePacker.AppendPackedTime(GameTime::GetGameTime().count() + time_t(deliveryDelay));
351
352 if (sendMail) // can be changed in the hook
354 AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut(), deliveryDelay, timePacker.read<uint32>()))
355 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
356 }
357}
@ AUCTION_SALE_PENDING
Definition: AuctionHouseMgr.h:63
@ CONFIG_MAIL_DELIVERY_DELAY
Definition: IWorld.h:263
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: ByteBuffer.h:70
void AppendPackedTime(time_t time)
Definition: ByteBuffer.cpp:137
T read()
Definition: ByteBuffer.h:351

References ByteBuffer::AppendPackedTime(), AUCTION_SALE_PENDING, AuctionEntry::bid, AuctionEntry::bidder, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, CONFIG_MAIL_DELIVERY_DELAY, AuctionEntry::deposit, ObjectAccessor::FindConnectedPlayer(), AuctionEntry::GetAuctionCut(), ObjectGuid::GetCounter(), GameTime::GetGameTime(), MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, ByteBuffer::read(), sCharacterCache, MailDraft::SendMailTo(), sScriptMgr, and sWorld.

◆ SendAuctionSuccessfulMail()

void AuctionHouseMgr::SendAuctionSuccessfulMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendNotification = true,
bool  updateAchievementCriteria = true,
bool  sendMail = true 
)
361{
363 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
364 // owner exist
365 if (owner || owner_accId)
366 {
367 uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut();
368 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(this, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail);
369
370 if (owner)
371 {
372 if (updateAchievementCriteria) // can be changed in the hook
373 {
376 }
377
378 if (sendNotification) // can be changed in the hook
379 owner->GetSession()->SendAuctionOwnerNotification(auction);
380 }
381 else if (updateAchievementCriteria)
382 {
383 sAchievementMgr->UpdateAchievementCriteriaForOfflinePlayer(auction->owner.GetCounter(), ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, profit);
384 sAchievementMgr->UpdateAchievementCriteriaForOfflinePlayer(auction->owner.GetCounter(), ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, auction->bid);
385 }
386
387 if (sendMail) // can be changed in the hook
389 .AddMoney(profit)
390 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY));
391
392 if (auction->bid >= 500 * GOLD)
393 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(auction->bidder))
394 {
396 std::string owner_name = "";
397 uint8 owner_level = 0;
398 if (CharacterCacheEntry const* gpd_owner = sCharacterCache->GetCharacterCacheByGuid(auction->owner))
399 {
400 owner_name = gpd_owner->Name;
401 owner_level = gpd_owner->Level;
402 }
403 CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"profit: {}g, bidder: {} {} lvl (guid: {}), seller: {} {} lvl (guid: {}), item {} ({})\", NOW(), {})",
404 gpd->AccountId, auction->bidder.GetCounter(), gpd->Name, bidder ? bidder->GetSession()->GetRemoteAddress() : "", owner_accId, owner_name, auction->bid, (profit / GOLD), gpd->Name, gpd->Level, auction->bidder.GetCounter(), owner_name, owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount, 2);
405 }
406 }
407}
std::uint8_t uint8
Definition: Define.h:109
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
Definition: DBCEnums.h:189
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD
Definition: DBCEnums.h:193
@ GOLD
Definition: SharedDefines.h:253
@ AUCTION_SUCCESSFUL
Definition: AuctionHouseMgr.h:59
#define sAchievementMgr
Definition: AchievementMgr.h:451
uint32 itemCount
Definition: AuctionHouseMgr.h:106
Definition: CharacterCache.h:28
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: PlayerUpdates.cpp:2131
std::string const & GetRemoteAddress()
Definition: WorldSession.h:371

References ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, MailDraft::AddMoney(), AUCTION_SUCCESSFUL, AuctionEntry::bid, AuctionEntry::bidder, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, CharacterDatabase, CONFIG_MAIL_DELIVERY_DELAY, AuctionEntry::deposit, ObjectAccessor::FindConnectedPlayer(), AuctionEntry::GetAuctionCut(), ObjectGuid::GetCounter(), WorldSession::GetRemoteAddress(), Player::GetSession(), GOLD, AuctionEntry::item_template, AuctionEntry::itemCount, MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, sAchievementMgr, sCharacterCache, WorldSession::SendAuctionOwnerNotification(), MailDraft::SendMailTo(), sScriptMgr, sWorld, and Player::UpdateAchievementCriteria().

◆ SendAuctionWonMail()

void AuctionHouseMgr::SendAuctionWonMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendNotification = true,
bool  updateAchievementCriteria = true,
bool  sendMail = true 
)
289{
290 Item* pItem = GetAItem(auction->item_guid);
291 if (!pItem)
292 return;
293
294 uint32 bidder_accId = 0;
296 if (bidder)
297 {
298 bidder_accId = bidder->GetSession()->GetAccountId();
299 }
300 else
301 {
302 bidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
303 }
304
305 // receiver exist
306 if (bidder || bidder_accId)
307 {
308 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionWonMail(this, auction, bidder, bidder_accId, sendNotification, updateAchievementCriteria, sendMail);
309 // set owner to bidder (to prevent delete item with sender char deleting)
310 // owner in `data` will set at mail receive and item extracting
312 stmt->SetData(0, auction->bidder.GetCounter());
313 stmt->SetData(1, pItem->GetGUID().GetCounter());
314 trans->Append(stmt);
315
316 if (bidder)
317 {
318 if (sendNotification) // can be changed in the hook
319 bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auction->bidder, 0, 0, auction->item_template);
320
321 if (updateAchievementCriteria) // can be changed in the hook
323 }
324 else if (updateAchievementCriteria)
325 {
326 sAchievementMgr->UpdateAchievementCriteriaForOfflinePlayer(auction->bidder.GetCounter(), ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, 1);
327 }
328
329 if (sendMail) // can be changed in the hook
331 .AddItem(pItem)
332 .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
333 }
334 else
335 sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
336}
@ ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS
Definition: DBCEnums.h:192
@ AUCTION_WON
Definition: AuctionHouseMgr.h:58
@ CHAR_UPD_ITEM_OWNER
Definition: CharacterDatabase.h:118
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
uint32 GetAccountId() const
Definition: WorldSession.h:361

References ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, MailDraft::AddItem(), AUCTION_WON, AuctionEntry::bid, AuctionEntry::bidder, AuctionEntry::BuildAuctionMailBody(), AuctionEntry::BuildAuctionMailSubject(), AuctionEntry::buyout, CHAR_UPD_ITEM_OWNER, CharacterDatabase, ObjectAccessor::FindConnectedPlayer(), WorldSession::GetAccountId(), GetAItem(), ObjectGuid::GetCounter(), Object::GetGUID(), AuctionEntry::GetHouseId(), Player::GetSession(), AuctionEntry::Id, AuctionEntry::item_guid, AuctionEntry::item_template, MAIL_CHECK_MASK_COPIED, AuctionEntry::owner, sAchievementMgr, sAuctionMgr, sCharacterCache, WorldSession::SendAuctionBidderNotification(), MailDraft::SendMailTo(), PreparedStatementBase::SetData(), sScriptMgr, and Player::UpdateAchievementCriteria().

◆ Update()

void AuctionHouseMgr::Update ( )
602{
603 sScriptMgr->OnBeforeAuctionHouseMgrUpdate();
607}
void Update()
Definition: AuctionHouseMgr.cpp:658

References _allianceAuctions, _hordeAuctions, _neutralAuctions, sScriptMgr, and AuctionHouseObject::Update().

Member Data Documentation

◆ _allianceAuctions

AuctionHouseObject AuctionHouseMgr::_allianceAuctions
private

◆ _hordeAuctions

AuctionHouseObject AuctionHouseMgr::_hordeAuctions
private

◆ _mAitems

ItemMap AuctionHouseMgr::_mAitems
private

◆ _neutralAuctions

AuctionHouseObject AuctionHouseMgr::_neutralAuctions
private