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 More...
 
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
939{
940 Item* item = sAuctionMgr->GetAItem(item_guid);
941 if (!item)
942 {
943 LOG_ERROR("auctionHouse", "AuctionEntry::BuildAuctionInfo: Auction {} has a non-existent item: {}", Id, item_guid.ToString());
944 return false;
945 }
946 data << uint32(Id);
947 data << uint32(item->GetEntry());
948
949 for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i)
950 {
951 data << uint32(item->GetEnchantmentId(EnchantmentSlot(i)));
954 }
955
956 data << int32(item->GetItemRandomPropertyId()); // Random item property id
957 data << uint32(item->GetItemSuffixFactor()); // SuffixFactor
958 data << uint32(item->GetCount()); // item->count
959 data << uint32(item->GetSpellCharges()); // item->charge FFFFFFF
960 data << uint32(0); // Unknown
961 data << owner; // Auction->owner
962 data << uint32(startbid); // Auction->startbid (not sure if useful)
963 data << uint32(bid ? GetAuctionOutBid() : 0);
964 // Minimal outbid
965 data << uint32(buyout); // Auction->buyout
966 data << uint32((expire_time - GameTime::GetGameTime().count()) * IN_MILLISECONDS); // time left
967 data << bidder; // auction->bidder current
968 data << uint32(bid); // current bid
969 return true;
970}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::int32_t int32
Definition: Define.h:103
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
#define sAuctionMgr
Definition: AuctionHouseMgr.h:227
EnchantmentSlot
Definition: Item.h:168
@ MAX_INSPECTED_ENCHANTMENT_SLOT
Definition: Item.h:176
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:979
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:220
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:304
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:317
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:305
int32 GetItemRandomPropertyId() const
Definition: Item.h:295
uint32 GetItemSuffixFactor() const
Definition: Item.h:296
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:306
uint32 GetCount() const
Definition: Item.h:272
uint32 GetEntry() const
Definition: Object.h:115
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
1048{
1049 std::ostringstream strm;
1050 strm.width(16);
1051 strm << std::right << std::hex << guid.GetRawValue();
1052 strm << std::dec << ':' << bid << ':' << buyout;
1053 strm << ':' << deposit << ':' << cut;
1054 strm << ':' << moneyDelay << ':' << eta;
1055 return strm.str();
1056}
uint32 deposit
Definition: AuctionHouseMgr.h:113
uint64 GetRawValue() const
Definition: ObjectGuid.h:142

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
1041{
1042 std::ostringstream strm;
1043 strm << item_template << ":0:" << response << ':' << Id << ':' << itemCount;
1044 return strm.str();
1045}
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
986{
988 stmt->SetData(0, Id);
989 trans->Append(stmt);
990}
@ CHAR_DEL_AUCTION
Definition: CharacterDatabase.h:106
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77

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
973{
975 return std::max(cut, 0);
976}
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ RATE_AUCTION_CUT
Definition: IWorld.h:508
#define sWorld
Definition: World.h:443
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:114
uint32 cutPercent
Definition: DBCStructure.h:577

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

980{
981 uint32 outbid = CalculatePct(bid, 5);
982 return outbid ? outbid : 1;
983}

References bid, and CalculatePct().

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

◆ GetHouseId()

uint8 AuctionEntry::GetHouseId ( ) const
inline

◆ LoadFromDB()

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

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
993{
995 stmt->SetData(0, Id);
996 stmt->SetData(1, houseId);
997 stmt->SetData(2, item_guid.GetCounter());
998 stmt->SetData(3, owner.GetCounter());
999 stmt->SetData (4, buyout);
1000 stmt->SetData(5, uint32(expire_time));
1001 stmt->SetData(6, bidder.GetCounter());
1002 stmt->SetData (7, bid);
1003 stmt->SetData (8, startbid);
1004 stmt->SetData (9, deposit);
1005 trans->Append(stmt);
1006}
@ CHAR_INS_AUCTION
Definition: CharacterDatabase.h:105
LowType GetCounter() const
Definition: ObjectGuid.h:145

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