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)
570{
571 ASSERT(it);
572 ASSERT(_mAitems.find(it->GetGUID()) == _mAitems.end());
573 _mAitems[it->GetGUID()] = it;
574}
#define ASSERT
Definition: Errors.h:68
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

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
267{
268 uint32 MSV = pItem->GetTemplate()->SellPrice;
269
270 if (MSV <= 0)
272
273 float multiplier = CalculatePct(float(entry->depositPercent), 3);
274 uint32 timeHr = (((time / 60) / 60) / 12);
275 uint32 deposit = uint32(((multiplier * MSV * count / 3) * timeHr * 3) * sWorld->getRate(RATE_AUCTION_DEPOSIT));
276
277 LOG_DEBUG("auctionHouse", "MSV: {}", MSV);
278 LOG_DEBUG("auctionHouse", "Items: {}", count);
279 LOG_DEBUG("auctionHouse", "Multiplier: {}", multiplier);
280 LOG_DEBUG("auctionHouse", "Deposit: {}", deposit);
281
282 if (deposit < AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT))
284 else
285 return deposit;
286}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
T CalculatePct(T base, U pct)
Definition: Util.h:61
constexpr auto AH_MINIMUM_DEPOSIT
Definition: AuctionHouseMgr.cpp:33
@ RATE_AUCTION_DEPOSIT
Definition: IWorld.h:502
#define sWorld
Definition: World.h:447
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:545
uint32 SellPrice
Definition: ItemTemplate.h:640

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
602{
603 uint32 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
604
606 {
607 //FIXME: found way for proper auctionhouse selection by another way
608 // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
609 // but no easy way convert creature faction to player race faction for specific city
610 FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
611 if (!u_entry)
612 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
613 else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
614 houseid = AUCTIONHOUSE_ALLIANCE; // human auction house
615 else if (u_entry->ourMask & FACTION_MASK_HORDE)
616 houseid = AUCTIONHOUSE_HORDE; // orc auction house
617 else
618 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
619 }
620
621 return sAuctionHouseStore.LookupEntry(houseid);
622}
@ AUCTIONHOUSE_HORDE
Definition: AuctionHouseMgr.h:69
@ AUCTIONHOUSE_ALLIANCE
Definition: AuctionHouseMgr.h:68
@ AUCTIONHOUSE_NEUTRAL
Definition: AuctionHouseMgr.h:70
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< AuctionHouseEntry > sAuctionHouseStore(AuctionHouseEntryfmt)
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
Definition: IWorld.h:83
@ FACTION_MASK_ALLIANCE
Definition: DBCEnums.h:346
@ FACTION_MASK_HORDE
Definition: DBCEnums.h:347
Definition: DBCStructure.h:930
uint32 ourMask
Definition: DBCStructure.h:934

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
264}

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 ( )
476{
477 uint32 oldMSTime = getMSTime();
478
479 // need to clear in case we are reloading
480 if (!_mAitems.empty())
481 {
482 for (ItemMap::iterator itr = _mAitems.begin(); itr != _mAitems.end(); ++itr)
483 delete itr->second;
484
485 _mAitems.clear();
486 }
487
488 // data needs to be at first place for Item::LoadFromDB
490 PreparedQueryResult result = CharacterDatabase.Query(stmt);
491
492 if (!result)
493 {
494 LOG_WARN("server.loading", ">> Loaded 0 auction items. DB table `auctionhouse` or `item_instance` is empty!");
495 LOG_INFO("server.loading", " ");
496 return;
497 }
498
499 uint32 count = 0;
500
501 do
502 {
503 Field* fields = result->Fetch();
504
505 ObjectGuid::LowType item_guid = fields[11].Get<uint32>();
506 uint32 item_template = fields[12].Get<uint32>();
507
508 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template);
509 if (!proto)
510 {
511 LOG_ERROR("auctionHouse", "AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: {} id: #{}) in auction, skipped.", item_guid, item_template);
512 continue;
513 }
514
515 Item* item = NewItemOrBag(proto);
516 if (!item->LoadFromDB(item_guid, ObjectGuid::Empty, fields, item_template))
517 {
518 delete item;
519 continue;
520 }
521 AddAItem(item);
522
523 ++count;
524 } while (result->NextRow());
525
526 LOG_INFO("server.loading", ">> Loaded {} auction items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
527 LOG_INFO("server.loading", " ");
528}
#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
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SEL_AUCTION_ITEMS
Definition: CharacterDatabase.h:104
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:67
#define sObjectMgr
Definition: ObjectMgr.h:1640
Definition: PreparedStatement.h:158
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
void AddAItem(Item *it)
Definition: AuctionHouseMgr.cpp:569
Definition: Item.h:214
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
Definition: Item.cpp:420
Definition: ItemTemplate.h:628
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
uint32 LowType
Definition: ObjectGuid.h:124

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 ( )
531{
532 uint32 oldMSTime = getMSTime();
533
535 PreparedQueryResult result = CharacterDatabase.Query(stmt);
536
537 if (!result)
538 {
539 LOG_WARN("server.loading", ">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
540 LOG_INFO("server.loading", " ");
541 return;
542 }
543
544 uint32 count = 0;
545
546 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
547 do
548 {
549 Field* fields = result->Fetch();
550
551 AuctionEntry* aItem = new AuctionEntry();
552 if (!aItem->LoadFromDB(fields))
553 {
554 aItem->DeleteFromDB(trans);
555 delete aItem;
556 continue;
557 }
558
560 count++;
561 } while (result->NextRow());
562
563 CharacterDatabase.CommitTransaction(trans);
564
565 LOG_INFO("server.loading", ">> Loaded {} auctions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
566 LOG_INFO("server.loading", " ");
567}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
@ CHAR_SEL_AUCTIONS
Definition: CharacterDatabase.h:108
Definition: AuctionHouseMgr.h:101
void DeleteFromDB(CharacterDatabaseTransaction trans) const
Definition: AuctionHouseMgr.cpp:977
bool LoadFromDB(Field *fields)
Definition: AuctionHouseMgr.cpp:1000
uint8 houseId
Definition: AuctionHouseMgr.h:103
void AddAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:629
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 
)
577{
578 ItemMap::iterator i = _mAitems.find(itemGuid);
579 if (i == _mAitems.end())
580 return false;
581
582 if (deleteFromDB)
583 {
584 ASSERT(trans);
585 i->second->FSetState(ITEM_REMOVED);
586 i->second->SaveToDB(*trans);
587 }
588
589 _mAitems.erase(i);
590 return true;
591}
@ ITEM_REMOVED
Definition: Item.h:206

References _mAitems, ASSERT, and ITEM_REMOVED.

◆ SendAuctionCancelledToBidderMail()

void AuctionHouseMgr::SendAuctionCancelledToBidderMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendMail = true 
)
455{
457
458 uint32 bidder_accId = 0;
459 if (!bidder)
460 {
461 bidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
462 }
463
464 // bidder exist
465 if (bidder || bidder_accId)
466 {
467 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(this, auction, bidder, bidder_accId, sendMail);
468 if (sendMail) // can be changed in the hook
470 .AddMoney(auction->bid)
471 .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
472 }
473}
@ 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:50
#define sScriptMgr
Definition: ScriptMgr.h:698
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:260
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:1039
ObjectGuid bidder
Definition: AuctionHouseMgr.h:112
std::string BuildAuctionMailSubject(MailAuctionAnswers response) const
Definition: AuctionHouseMgr.cpp:1032
uint32 buyout
Definition: AuctionHouseMgr.h:110
uint32 deposit
Definition: AuctionHouseMgr.h:113
ObjectGuid owner
Definition: AuctionHouseMgr.h:107
LowType GetCounter() const
Definition: ObjectGuid.h:147
Definition: Player.h:1056
Definition: Mail.h:106
Definition: Mail.h:120
MailDraft & AddMoney(uint32 money)
Definition: Mail.h:138
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:186

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 
)
403{
404 //return an item in auction to its owner by mail
405 Item* pItem = GetAItem(auction->item_guid);
406 if (!pItem)
407 return;
408
410 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
411
412 // owner exist
413 if (owner || owner_accId)
414 {
415 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(this, auction, owner, owner_accId, sendNotification, sendMail);
416
417 if (owner && sendNotification) // can be changed in the hook
418 owner->GetSession()->SendAuctionOwnerNotification(auction);
419
420 if (sendMail) // can be changed in the hook
422 .AddItem(pItem)
423 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0);
424 }
425 else
426 sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
427}
@ 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:1961
MailDraft & AddItem(Item *item)
Definition: Mail.cpp:94
void SendAuctionOwnerNotification(AuctionEntry *auction)
Definition: AuctionHouseHandler.cpp:103

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 
)
431{
433
434 uint32 oldBidder_accId = 0;
435 if (!oldBidder)
436 oldBidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
437
438 // old bidder exist
439 if (oldBidder || oldBidder_accId)
440 {
441 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(this, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail);
442
443 if (oldBidder && newBidder && sendNotification) // can be changed in the hook
444 oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
445
446 if (sendMail) // can be changed in the hook
448 .AddMoney(auction->bid)
449 .SendMailTo(trans, MailReceiver(oldBidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
450 }
451}
@ 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:971
uint8 GetHouseId() const
Definition: AuctionHouseMgr.h:117
uint32 Id
Definition: AuctionHouseMgr.h:102
uint32 GetAuctionCut() const
Definition: AuctionHouseMgr.cpp:964
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:89

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 
)
336{
338 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
339 // owner exist (online or offline)
340 if (owner || owner_accId)
341 {
342 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(this, auction, owner, owner_accId, sendMail);
343
344 uint32 deliveryDelay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
345
346 ByteBuffer timePacker;
347 timePacker.AppendPackedTime(GameTime::GetGameTime().count() + time_t(deliveryDelay));
348
349 if (sendMail) // can be changed in the hook
351 AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut(), deliveryDelay, timePacker.read<uint32>()))
352 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
353 }
354}
@ 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 
)
358{
360 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
361 // owner exist
362 if (owner || owner_accId)
363 {
364 uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut();
365 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(this, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail);
366
367 if (owner)
368 {
369 if (updateAchievementCriteria) // can be changed in the hook
370 {
373 }
374
375 if (sendNotification) // can be changed in the hook
376 owner->GetSession()->SendAuctionOwnerNotification(auction);
377 }
378
379 if (sendMail) // can be changed in the hook
381 .AddMoney(profit)
382 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY));
383
384 if (auction->bid >= 500 * GOLD)
385 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(auction->bidder))
386 {
388 std::string owner_name = "";
389 uint8 owner_level = 0;
390 if (CharacterCacheEntry const* gpd_owner = sCharacterCache->GetCharacterCacheByGuid(auction->owner))
391 {
392 owner_name = gpd_owner->Name;
393 owner_level = gpd_owner->Level;
394 }
395 CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"profit: {}g, bidder: {} {} lvl (guid: {}), seller: {} {} lvl (guid: {}), item {} ({})\", NOW(), {})",
396 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);
397 }
398 }
399}
std::uint8_t uint8
Definition: Define.h:110
@ AUCTION_SUCCESSFUL
Definition: AuctionHouseMgr.h:59
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
Definition: DBCEnums.h:197
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD
Definition: DBCEnums.h:201
@ GOLD
Definition: SharedDefines.h:253
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:373

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

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, sAuctionMgr, sCharacterCache, WorldSession::SendAuctionBidderNotification(), MailDraft::SendMailTo(), PreparedStatementBase::SetData(), sScriptMgr, and Player::UpdateAchievementCriteria().

◆ Update()

void AuctionHouseMgr::Update ( )
594{
595 sScriptMgr->OnBeforeAuctionHouseMgrUpdate();
599}
void Update()
Definition: AuctionHouseMgr.cpp:650

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