AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AuctionEntry Struct Reference

#include "AuctionHouseMgr.h"

Public Member Functions

uint8 GetHouseId () const
 
uint32 GetAuctionCut () const
 
uint32 GetAuctionOutBid () const
 the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
 
bool BuildAuctionInfo (WorldPacket &data) const
 
void DeleteFromDB (CharacterDatabaseTransaction trans) const
 
void SaveToDB (CharacterDatabaseTransaction trans) const
 
bool LoadFromDB (Field *fields)
 
std::string BuildAuctionMailSubject (MailAuctionAnswers response) const
 

Static Public Member Functions

static std::string BuildAuctionMailBody (ObjectGuid guid, uint32 bid, uint32 buyout, uint32 deposit=0, uint32 cut=0, uint32 moneyDelay=0, uint32 eta=0)
 

Public Attributes

uint32 Id
 
uint8 houseId
 
ObjectGuid item_guid
 
uint32 item_template
 
uint32 itemCount
 
ObjectGuid owner
 
uint32 startbid
 
uint32 bid
 
uint32 buyout
 
time_t expire_time
 
ObjectGuid bidder
 
uint32 deposit
 
AuctionHouseEntry const * auctionHouseEntry
 

Detailed Description

Member Function Documentation

◆ BuildAuctionInfo()

bool AuctionEntry::BuildAuctionInfo ( WorldPacket data) const
931{
932 Item* item = sAuctionMgr->GetAItem(item_guid);
933 if (!item)
934 {
935 LOG_ERROR("auctionHouse", "AuctionEntry::BuildAuctionInfo: Auction {} has a non-existent item: {}", Id, item_guid.ToString());
936 return false;
937 }
938 data << uint32(Id);
939 data << uint32(item->GetEntry());
940
941 for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i)
942 {
943 data << uint32(item->GetEnchantmentId(EnchantmentSlot(i)));
946 }
947
948 data << int32(item->GetItemRandomPropertyId()); // Random item property id
949 data << uint32(item->GetItemSuffixFactor()); // SuffixFactor
950 data << uint32(item->GetCount()); // item->count
951 data << uint32(item->GetSpellCharges()); // item->charge FFFFFFF
952 data << uint32(0); // Unknown
953 data << owner; // Auction->owner
954 data << uint32(startbid); // Auction->startbid (not sure if useful)
955 data << uint32(bid ? GetAuctionOutBid() : 0);
956 // Minimal outbid
957 data << uint32(buyout); // Auction->buyout
958 data << uint32((expire_time - GameTime::GetGameTime().count()) * IN_MILLISECONDS); // time left
959 data << bidder; // auction->bidder current
960 data << uint32(bid); // current bid
961 return true;
962}
constexpr auto IN_MILLISECONDS
Definition: Common.h:55
std::int32_t int32
Definition: Define.h:104
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define sAuctionMgr
Definition: AuctionHouseMgr.h:227
EnchantmentSlot
Definition: Item.h:162
@ MAX_INSPECTED_ENCHANTMENT_SLOT
Definition: Item.h:170
Seconds GetGameTime()
Definition: GameTime.cpp:38
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
uint32 bid
Definition: AuctionHouseMgr.h:109
ObjectGuid bidder
Definition: AuctionHouseMgr.h:112
time_t expire_time
Definition: AuctionHouseMgr.h:111
ObjectGuid item_guid
Definition: AuctionHouseMgr.h:104
uint32 startbid
Definition: AuctionHouseMgr.h:108
uint32 Id
Definition: AuctionHouseMgr.h:102
uint32 buyout
Definition: AuctionHouseMgr.h:110
ObjectGuid owner
Definition: AuctionHouseMgr.h:107
Definition: Item.h:214
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:295
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:308
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:296
int32 GetItemRandomPropertyId() const
Definition: Item.h:286
uint32 GetItemSuffixFactor() const
Definition: Item.h:287
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:297
uint32 GetCount() const
Definition: Item.h:263
uint32 GetEntry() const
Definition: Object.h:109
std::string ToString() const
Definition: ObjectGuid.cpp:47

References bid, bidder, buyout, expire_time, GetAuctionOutBid(), Item::GetCount(), Item::GetEnchantmentCharges(), Item::GetEnchantmentDuration(), Item::GetEnchantmentId(), Object::GetEntry(), GameTime::GetGameTime(), Item::GetItemRandomPropertyId(), Item::GetItemSuffixFactor(), Item::GetSpellCharges(), Id, IN_MILLISECONDS, item_guid, LOG_ERROR, MAX_INSPECTED_ENCHANTMENT_SLOT, owner, sAuctionMgr, startbid, and ObjectGuid::ToString().

Referenced by AuctionHouseObject::BuildListOwnerItems(), and WorldSession::HandleAuctionListBidderItems().

◆ BuildAuctionMailBody()

std::string AuctionEntry::BuildAuctionMailBody ( ObjectGuid  guid,
uint32  bid,
uint32  buyout,
uint32  deposit = 0,
uint32  cut = 0,
uint32  moneyDelay = 0,
uint32  eta = 0 
)
static
1040{
1041 std::ostringstream strm;
1042 strm.width(16);
1043 strm << std::right << std::hex << guid.GetRawValue();
1044 strm << std::dec << ':' << bid << ':' << buyout;
1045 strm << ':' << deposit << ':' << cut;
1046 strm << ':' << moneyDelay << ':' << eta;
1047 return strm.str();
1048}
uint32 deposit
Definition: AuctionHouseMgr.h:113
uint64 GetRawValue() const
Definition: ObjectGuid.h:144

References bid, buyout, deposit, and ObjectGuid::GetRawValue().

Referenced by WorldSession::HandleAuctionRemoveItem(), AuctionHouseMgr::SendAuctionCancelledToBidderMail(), AuctionHouseMgr::SendAuctionExpiredMail(), AuctionHouseMgr::SendAuctionOutbiddedMail(), AuctionHouseMgr::SendAuctionSalePendingMail(), AuctionHouseMgr::SendAuctionSuccessfulMail(), and AuctionHouseMgr::SendAuctionWonMail().

◆ BuildAuctionMailSubject()

std::string AuctionEntry::BuildAuctionMailSubject ( MailAuctionAnswers  response) const
1033{
1034 std::ostringstream strm;
1035 strm << item_template << ":0:" << response << ':' << Id << ':' << itemCount;
1036 return strm.str();
1037}
uint32 itemCount
Definition: AuctionHouseMgr.h:106
uint32 item_template
Definition: AuctionHouseMgr.h:105

References Id, item_template, and itemCount.

Referenced by WorldSession::HandleAuctionRemoveItem(), AuctionHouseMgr::SendAuctionCancelledToBidderMail(), AuctionHouseMgr::SendAuctionExpiredMail(), AuctionHouseMgr::SendAuctionOutbiddedMail(), AuctionHouseMgr::SendAuctionSalePendingMail(), AuctionHouseMgr::SendAuctionSuccessfulMail(), and AuctionHouseMgr::SendAuctionWonMail().

◆ DeleteFromDB()

void AuctionEntry::DeleteFromDB ( CharacterDatabaseTransaction  trans) const
978{
980 stmt->SetData(0, Id);
981 trans->Append(stmt);
982}
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_DEL_AUCTION
Definition: CharacterDatabase.h:106
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References CHAR_DEL_AUCTION, CharacterDatabase, Id, and PreparedStatementBase::SetData().

Referenced by WorldSession::HandleAuctionPlaceBid(), WorldSession::HandleAuctionRemoveItem(), AuctionHouseMgr::LoadAuctions(), and AuctionHouseObject::Update().

◆ GetAuctionCut()

uint32 AuctionEntry::GetAuctionCut ( ) const
965{
967 return std::max(cut, 0);
968}
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ RATE_AUCTION_CUT
Definition: IWorld.h:503
#define sWorld
Definition: World.h:447
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:114
uint32 cutPercent
Definition: DBCStructure.h:578

References auctionHouseEntry, bid, CalculatePct(), AuctionHouseEntry::cutPercent, RATE_AUCTION_CUT, and sWorld.

Referenced by WorldSession::HandleAuctionRemoveItem(), AuctionHouseMgr::SendAuctionOutbiddedMail(), AuctionHouseMgr::SendAuctionSalePendingMail(), and AuctionHouseMgr::SendAuctionSuccessfulMail().

◆ GetAuctionOutBid()

uint32 AuctionEntry::GetAuctionOutBid ( ) const

the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c

972{
973 uint32 outbid = CalculatePct(bid, 5);
974 return outbid ? outbid : 1;
975}

References bid, and CalculatePct().

Referenced by BuildAuctionInfo(), WorldSession::HandleAuctionPlaceBid(), and AuctionHouseMgr::SendAuctionOutbiddedMail().

◆ GetHouseId()

uint8 AuctionEntry::GetHouseId ( ) const
inline

◆ LoadFromDB()

bool AuctionEntry::LoadFromDB ( Field fields)
1001{
1002 Id = fields[0].Get<uint32>();
1003 houseId = fields[1].Get<uint8>();
1004 item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].Get<uint32>());
1005 item_template = fields[3].Get<uint32>();
1006 itemCount = fields[4].Get<uint32>();
1007 owner = ObjectGuid::Create<HighGuid::Player>(fields[5].Get<uint32>());
1008 buyout = fields[6].Get<uint32>();
1009 expire_time = fields[7].Get<uint32>();
1010 bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].Get<uint32>());
1011 bid = fields[9].Get<uint32>();
1012 startbid = fields[10].Get<uint32>();
1013 deposit = fields[11].Get<uint32>();
1014
1016 if (!auctionHouseEntry)
1017 {
1018 LOG_ERROR("auctionHouse", "Auction {} has invalid house id {}", Id, houseId);
1019 return false;
1020 }
1021
1022 // check if sold item exists for guid
1023 // and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
1024 if (!sAuctionMgr->GetAItem(item_guid))
1025 {
1026 LOG_ERROR("auctionHouse", "Auction {} has not a existing item : {}", Id, item_guid.ToString());
1027 return false;
1028 }
1029 return true;
1030}
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
static AuctionHouseEntry const * GetAuctionHouseEntryFromHouse(uint8 houseId)
Definition: AuctionHouseMgr.cpp:624

References auctionHouseEntry, bid, bidder, buyout, deposit, expire_time, Field::Get(), AuctionHouseMgr::GetAuctionHouseEntryFromHouse(), houseId, Id, item_guid, item_template, itemCount, LOG_ERROR, owner, sAuctionMgr, startbid, and ObjectGuid::ToString().

Referenced by AuctionHouseMgr::LoadAuctions().

◆ SaveToDB()

void AuctionEntry::SaveToDB ( CharacterDatabaseTransaction  trans) const
985{
987 stmt->SetData(0, Id);
988 stmt->SetData(1, houseId);
989 stmt->SetData(2, item_guid.GetCounter());
990 stmt->SetData(3, owner.GetCounter());
991 stmt->SetData (4, buyout);
992 stmt->SetData(5, uint32(expire_time));
993 stmt->SetData(6, bidder.GetCounter());
994 stmt->SetData (7, bid);
995 stmt->SetData (8, startbid);
996 stmt->SetData (9, deposit);
997 trans->Append(stmt);
998}
@ CHAR_INS_AUCTION
Definition: CharacterDatabase.h:105
LowType GetCounter() const
Definition: ObjectGuid.h:147

References bid, bidder, buyout, CHAR_INS_AUCTION, CharacterDatabase, deposit, expire_time, ObjectGuid::GetCounter(), houseId, Id, item_guid, owner, PreparedStatementBase::SetData(), and startbid.

Referenced by WorldSession::HandleAuctionSellItem().

Member Data Documentation

◆ auctionHouseEntry

AuctionHouseEntry const* AuctionEntry::auctionHouseEntry

◆ bid

◆ bidder

◆ buyout

◆ deposit

◆ expire_time

◆ houseId

◆ Id

◆ item_guid

◆ item_template

◆ itemCount

◆ owner

◆ startbid