AzeorthCore 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)
 
AuctionHouseObjectGetBidsMap (uint32 factionTemplateId)
 
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 mHordeAuctions
 
AuctionHouseObject mAllianceAuctions
 
AuctionHouseObject mNeutralAuctions
 
ItemMap mAitems
 

Detailed Description

Member Typedef Documentation

◆ ItemMap

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

Constructor & Destructor Documentation

◆ AuctionHouseMgr()

AuctionHouseMgr::AuctionHouseMgr ( )
private
218{
219}

◆ ~AuctionHouseMgr()

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

References mAitems.

Member Function Documentation

◆ AddAItem()

void AuctionHouseMgr::AddAItem ( Item it)
572{
573 ASSERT(it);
574 ASSERT(mAitems.find(it->GetGUID()) == mAitems.end());
575 mAitems[it->GetGUID()] = it;
576}
#define ASSERT
Definition: Errors.h:68
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

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

Referenced by LoadAuctionItems().

◆ GetAItem()

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

References mAitems.

Referenced by SendAuctionExpiredMail(), and SendAuctionWonMail().

◆ GetAuctionDeposit()

uint32 AuctionHouseMgr::GetAuctionDeposit ( AuctionHouseEntry const *  entry,
uint32  time,
Item pItem,
uint32  count 
)
static
269{
270 uint32 MSV = pItem->GetTemplate()->SellPrice;
271
272 if (MSV <= 0)
274
275 float multiplier = CalculatePct(float(entry->depositPercent), 3);
276 uint32 timeHr = (((time / 60) / 60) / 12);
277 uint32 deposit = uint32(((multiplier * MSV * count / 3) * timeHr * 3) * sWorld->getRate(RATE_AUCTION_DEPOSIT));
278
279 LOG_DEBUG("auctionHouse", "MSV: {}", MSV);
280 LOG_DEBUG("auctionHouse", "Items: {}", count);
281 LOG_DEBUG("auctionHouse", "Multiplier: {}", multiplier);
282 LOG_DEBUG("auctionHouse", "Deposit: {}", deposit);
283
284 if (deposit < AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT))
286 else
287 return deposit;
288}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
T CalculatePct(T base, U pct)
Definition: Util.h:61
constexpr auto AH_MINIMUM_DEPOSIT
Definition: AuctionHouseMgr.cpp:35
@ RATE_AUCTION_DEPOSIT
Definition: IWorld.h:503
#define sWorld
Definition: World.h:458
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:546
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
604{
605 uint32 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
606
608 {
609 //FIXME: found way for proper auctionhouse selection by another way
610 // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
611 // but no easy way convert creature faction to player race faction for specific city
612 FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
613 if (!u_entry)
614 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
615 else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
616 houseid = AUCTIONHOUSE_ALLIANCE; // human auction house
617 else if (u_entry->ourMask & FACTION_MASK_HORDE)
618 houseid = AUCTIONHOUSE_HORDE; // orc auction house
619 else
620 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
621 }
622
623 return sAuctionHouseStore.LookupEntry(houseid);
624}
@ 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:94
@ FACTION_MASK_ALLIANCE
Definition: DBCEnums.h:343
@ FACTION_MASK_HORDE
Definition: DBCEnums.h:344
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)
234{
236 return &mNeutralAuctions;
237
238 // team have linked auction houses
239 FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
240 if (!u_entry)
241 return &mNeutralAuctions;
242 else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
243 return &mAllianceAuctions;
244 else if (u_entry->ourMask & FACTION_MASK_HORDE)
245 return &mHordeAuctions;
246
247 return &mNeutralAuctions;
248}
AuctionHouseObject mNeutralAuctions
Definition: AuctionHouseMgr.h:223
AuctionHouseObject mHordeAuctions
Definition: AuctionHouseMgr.h:221
AuctionHouseObject mAllianceAuctions
Definition: AuctionHouseMgr.h:222

References CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, FACTION_MASK_ALLIANCE, FACTION_MASK_HORDE, mAllianceAuctions, mHordeAuctions, mNeutralAuctions, FactionTemplateEntry::ourMask, sFactionTemplateStore, and sWorld.

◆ GetAuctionsMapByHouseId()

AuctionHouseObject * AuctionHouseMgr::GetAuctionsMapByHouseId ( uint8  auctionHouseId)
251{
253 return &mNeutralAuctions;
254
255 switch(auctionHouseId)
256 {
258 return &mAllianceAuctions;
260 return &mHordeAuctions;
261 break;
262 }
263
264 return &mNeutralAuctions;
265
266}

References AUCTIONHOUSE_ALLIANCE, AUCTIONHOUSE_HORDE, CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, mAllianceAuctions, mHordeAuctions, mNeutralAuctions, and sWorld.

Referenced by LoadAuctions().

◆ GetBidsMap()

AuctionHouseObject * AuctionHouseMgr::GetBidsMap ( uint32  factionTemplateId)

◆ instance()

AuctionHouseMgr * AuctionHouseMgr::instance ( )
static
228{
230 return &instance;
231}
Definition: AuctionHouseMgr.h:175
static AuctionHouseMgr * instance()
Definition: AuctionHouseMgr.cpp:227

References instance().

Referenced by instance().

◆ LoadAuctionItems()

void AuctionHouseMgr::LoadAuctionItems ( )
478{
479 uint32 oldMSTime = getMSTime();
480
481 // need to clear in case we are reloading
482 if (!mAitems.empty())
483 {
484 for (ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr)
485 delete itr->second;
486
487 mAitems.clear();
488 }
489
490 // data needs to be at first place for Item::LoadFromDB
492 PreparedQueryResult result = CharacterDatabase.Query(stmt);
493
494 if (!result)
495 {
496 LOG_WARN("server.loading", ">> Loaded 0 auction items. DB table `auctionhouse` or `item_instance` is empty!");
497 LOG_INFO("server.loading", " ");
498 return;
499 }
500
501 uint32 count = 0;
502
503 do
504 {
505 Field* fields = result->Fetch();
506
507 ObjectGuid::LowType item_guid = fields[11].Get<uint32>();
508 uint32 item_template = fields[12].Get<uint32>();
509
510 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template);
511 if (!proto)
512 {
513 LOG_ERROR("auctionHouse", "AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: {} id: #{}) in auction, skipped.", item_guid, item_template);
514 continue;
515 }
516
517 Item* item = NewItemOrBag(proto);
518 if (!item->LoadFromDB(item_guid, ObjectGuid::Empty, fields, item_template))
519 {
520 delete item;
521 continue;
522 }
523 AddAItem(item);
524
525 ++count;
526 } while (result->NextRow());
527
528 LOG_INFO("server.loading", ">> Loaded {} auction items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
529 LOG_INFO("server.loading", " ");
530}
#define LOG_INFO(filterType__,...)
Definition: Log.h:167
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_WARN(filterType__,...)
Definition: Log.h:163
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:1612
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:571
Definition: Item.h:214
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
Definition: Item.cpp:421
Definition: ItemTemplate.h:628
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
uint32 LowType
Definition: ObjectGuid.h:124

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

◆ LoadAuctions()

void AuctionHouseMgr::LoadAuctions ( )
533{
534 uint32 oldMSTime = getMSTime();
535
537 PreparedQueryResult result = CharacterDatabase.Query(stmt);
538
539 if (!result)
540 {
541 LOG_WARN("server.loading", ">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
542 LOG_INFO("server.loading", " ");
543 return;
544 }
545
546 uint32 count = 0;
547
548 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
549 do
550 {
551 Field* fields = result->Fetch();
552
553 AuctionEntry* aItem = new AuctionEntry();
554 if (!aItem->LoadFromDB(fields))
555 {
556 aItem->DeleteFromDB(trans);
557 delete aItem;
558 continue;
559 }
560
562 count++;
563 } while (result->NextRow());
564
565 CharacterDatabase.CommitTransaction(trans);
566
567 LOG_INFO("server.loading", ">> Loaded {} auctions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
568 LOG_INFO("server.loading", " ");
569}
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:979
bool LoadFromDB(Field *fields)
Definition: AuctionHouseMgr.cpp:1002
uint8 houseId
Definition: AuctionHouseMgr.h:103
void AddAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:631
AuctionHouseObject * GetAuctionsMapByHouseId(uint8 auctionHouseId)
Definition: AuctionHouseMgr.cpp:250

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 
)
579{
580 ItemMap::iterator i = mAitems.find(itemGuid);
581 if (i == mAitems.end())
582 return false;
583
584 if (deleteFromDB)
585 {
586 ASSERT(trans);
587 i->second->FSetState(ITEM_REMOVED);
588 i->second->SaveToDB(*trans);
589 }
590
591 mAitems.erase(i);
592 return true;
593}
@ ITEM_REMOVED
Definition: Item.h:206

References ASSERT, ITEM_REMOVED, and mAitems.

◆ SendAuctionCancelledToBidderMail()

void AuctionHouseMgr::SendAuctionCancelledToBidderMail ( AuctionEntry auction,
CharacterDatabaseTransaction  trans,
bool  sendMail = true 
)
457{
459
460 uint32 bidder_accId = 0;
461 if (!bidder)
462 {
463 bidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
464 }
465
466 // bidder exist
467 if (bidder || bidder_accId)
468 {
469 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(this, auction, bidder, bidder_accId, sendMail);
470 if (sendMail) // can be changed in the hook
472 .AddMoney(auction->bid)
473 .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
474 }
475}
@ 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:2690
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:262
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:1041
ObjectGuid bidder
Definition: AuctionHouseMgr.h:112
std::string BuildAuctionMailSubject(MailAuctionAnswers response) const
Definition: AuctionHouseMgr.cpp:1034
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:1046
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 
)
405{
406 //return an item in auction to its owner by mail
407 Item* pItem = GetAItem(auction->item_guid);
408 if (!pItem)
409 return;
410
412 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
413
414 // owner exist
415 if (owner || owner_accId)
416 {
417 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(this, auction, owner, owner_accId, sendNotification, sendMail);
418
419 if (owner && sendNotification) // can be changed in the hook
420 owner->GetSession()->SendAuctionOwnerNotification(auction);
421
422 if (sendMail) // can be changed in the hook
424 .AddItem(pItem)
425 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0);
426 }
427 else
428 sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
429}
@ AUCTION_EXPIRED
Definition: AuctionHouseMgr.h:60
#define sAuctionMgr
Definition: AuctionHouseMgr.h:228
ObjectGuid item_guid
Definition: AuctionHouseMgr.h:104
Item * GetAItem(ObjectGuid itemGuid)
Definition: AuctionHouseMgr.h:189
WorldSession * GetSession() const
Definition: Player.h:1947
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 
)
433{
435
436 uint32 oldBidder_accId = 0;
437 if (!oldBidder)
438 oldBidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->bidder);
439
440 // old bidder exist
441 if (oldBidder || oldBidder_accId)
442 {
443 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(this, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail);
444
445 if (oldBidder && newBidder && sendNotification) // can be changed in the hook
446 oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
447
448 if (sendMail) // can be changed in the hook
450 .AddMoney(auction->bid)
451 .SendMailTo(trans, MailReceiver(oldBidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
452 }
453}
@ 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:973
uint8 GetHouseId() const
Definition: AuctionHouseMgr.h:117
uint32 Id
Definition: AuctionHouseMgr.h:102
uint32 GetAuctionCut() const
Definition: AuctionHouseMgr.cpp:966
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 
)
338{
340 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
341 // owner exist (online or offline)
342 if (owner || owner_accId)
343 {
344 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(this, auction, owner, owner_accId, sendMail);
345
346 uint32 deliveryDelay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
347
348 ByteBuffer timePacker;
349 timePacker.AppendPackedTime(GameTime::GetGameTime().count() + time_t(deliveryDelay));
350
351 if (sendMail) // can be changed in the hook
353 AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut(), deliveryDelay, timePacker.read<uint32>()))
354 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
355 }
356}
@ AUCTION_SALE_PENDING
Definition: AuctionHouseMgr.h:63
@ CONFIG_MAIL_DELIVERY_DELAY
Definition: IWorld.h:268
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: ByteBuffer.h:70
void AppendPackedTime(time_t time)
Definition: ByteBuffer.cpp:138
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 
)
360{
362 uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(auction->owner);
363 // owner exist
364 if (owner || owner_accId)
365 {
366 uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut();
367 sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(this, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail);
368
369 if (owner)
370 {
371 if (updateAchievementCriteria) // can be changed in the hook
372 {
375 }
376
377 if (sendNotification) // can be changed in the hook
378 owner->GetSession()->SendAuctionOwnerNotification(auction);
379 }
380
381 if (sendMail) // can be changed in the hook
383 .AddMoney(profit)
384 .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY));
385
386 if (auction->bid >= 500 * GOLD)
387 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(auction->bidder))
388 {
390 std::string owner_name = "";
391 uint8 owner_level = 0;
392 if (CharacterCacheEntry const* gpd_owner = sCharacterCache->GetCharacterCacheByGuid(auction->owner))
393 {
394 owner_name = gpd_owner->Name;
395 owner_level = gpd_owner->Level;
396 }
397 CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"profit: {}g, bidder: {} {} lvl (guid: {}), seller: {} {} lvl (guid: {}), item {} ({})\", NOW(), {})",
398 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);
399 }
400 }
401}
std::uint8_t uint8
Definition: Define.h:110
@ AUCTION_SUCCESSFUL
Definition: AuctionHouseMgr.h:59
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
Definition: DBCEnums.h:195
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD
Definition: DBCEnums.h:199
@ GOLD
Definition: SharedDefines.h:225
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:2125
std::string const & GetRemoteAddress()
Definition: WorldSession.h:369

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

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 ( )
596{
597 sScriptMgr->OnBeforeAuctionHouseMgrUpdate();
601}
void Update()
Definition: AuctionHouseMgr.cpp:652

References mAllianceAuctions, mHordeAuctions, mNeutralAuctions, sScriptMgr, and AuctionHouseObject::Update().

Member Data Documentation

◆ mAitems

ItemMap AuctionHouseMgr::mAitems
private

◆ mAllianceAuctions

AuctionHouseObject AuctionHouseMgr::mAllianceAuctions
private

◆ mHordeAuctions

AuctionHouseObject AuctionHouseMgr::mHordeAuctions
private

◆ mNeutralAuctions

AuctionHouseObject AuctionHouseMgr::mNeutralAuctions
private