TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AuctionEntry Struct Reference

#include <AuctionHouseMgr.h>

Public Member Functions

uint32 GetHouseId () const
 
uint32 GetHouseFaction () 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...
 
void BuildAuctionInfo (std::vector< WorldPackets::AuctionHouse::AuctionItem > &items, bool listAuctionItems) const
 
void DeleteFromDB (SQLTransaction &trans) const
 
void SaveToDB (SQLTransaction &trans) const
 
bool LoadFromDB (Field *fields)
 
std::string BuildAuctionMailSubject (MailAuctionAnswers response) const
 

Static Public Member Functions

static std::string BuildAuctionMailBody (uint64 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut)
 

Public Attributes

uint32 Id
 
ObjectGuid::LowType auctioneer
 
ObjectGuid::LowType itemGUIDLow
 
uint32 itemEntry
 
uint32 itemCount
 
ObjectGuid::LowType owner
 
uint32 startbid
 
uint32 bid
 
uint32 buyout
 
time_t expire_time
 
ObjectGuid::LowType bidder
 
uint32 deposit
 
uint32 etime
 
AuctionHouseEntry constauctionHouseEntry
 
uint32 factionTemplateId
 

Member Function Documentation

void AuctionEntry::BuildAuctionInfo ( std::vector< WorldPackets::AuctionHouse::AuctionItem > &  items,
bool  listAuctionItems 
) const
747 {
748  Item* item = sAuctionMgr->GetAItem(itemGUIDLow);
749  if (!item)
750  {
751  TC_LOG_ERROR("misc", "AuctionEntry::BuildAuctionInfo: Auction %u has a non-existent item: " UI64FMTD, Id, itemGUIDLow);
752  return;
753  }
754 
756 
757  auctionItem.AuctionItemID = Id;
758  auctionItem.Item.Initialize(item);
759  auctionItem.BuyoutPrice = buyout;
760  auctionItem.CensorBidInfo = false;
761  auctionItem.CensorServerSideInfo = listAuctionItems;
762  auctionItem.Charges = item->GetSpellCharges();
763  auctionItem.Count = item->GetCount();
764  auctionItem.DeleteReason = 0; // Always 0 ?
765  auctionItem.DurationLeft = (expire_time - time(NULL)) * IN_MILLISECONDS;
766  auctionItem.EndTime = expire_time;
767  auctionItem.Flags = 0; // todo
768  auctionItem.ItemGuid = item->GetGUID();
769  auctionItem.MinBid = startbid;
770  auctionItem.Owner = ObjectGuid::Create<HighGuid::Player>(owner);
771  auctionItem.OwnerAccountID = ObjectGuid::Create<HighGuid::WowAccount>(ObjectMgr::GetPlayerAccountIdByGUID(auctionItem.Owner));
772  auctionItem.MinIncrement = bidder ? GetAuctionOutBid() : 0;
773  auctionItem.Bidder = bidder ? ObjectGuid::Create<HighGuid::Player>(bidder) : ObjectGuid::Empty;
774  auctionItem.BidAmount = bidder ? bid : 0;
775 
776  for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++)
777  {
778  if (!item->GetEnchantmentId((EnchantmentSlot) i))
779  continue;
780 
781  auctionItem.Enchantments.emplace_back(item->GetEnchantmentId((EnchantmentSlot) i), item->GetEnchantmentDuration((EnchantmentSlot) i), item->GetEnchantmentCharges((EnchantmentSlot) i), i);
782  }
783 
784  items.emplace_back(auctionItem);
785 }
uint32 GetCount() const
Definition: Item.h:322
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:364
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
int32 DurationLeft
Definition: AuctionHousePackets.h:53
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
EnchantmentSlot
Definition: Item.h:172
bool CensorBidInfo
Definition: AuctionHousePackets.h:56
uint64 MinIncrement
Definition: AuctionHousePackets.h:51
arena_t NULL
Definition: jemalloc_internal.h:624
uint8 DeleteReason
Definition: AuctionHousePackets.h:54
Definition: AuctionHousePackets.h:32
int32 Flags
Definition: AuctionHousePackets.h:47
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:352
uint32 Id
Definition: AuctionHouseMgr.h:69
bool CensorServerSideInfo
Definition: AuctionHousePackets.h:55
std::vector< AuctionItemEnchant > Enchantments
Definition: AuctionHousePackets.h:46
ObjectGuid Bidder
Definition: AuctionHousePackets.h:60
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
uint64 MinBid
Definition: AuctionHousePackets.h:50
Item::ItemInstance Item
Definition: AuctionHousePackets.h:43
Definition: Item.h:259
ObjectGuid ItemGuid
Definition: AuctionHousePackets.h:57
uint32 startbid
Definition: AuctionHouseMgr.h:75
#define UI64FMTD
Definition: Define.h:137
int32 Count
Definition: AuctionHousePackets.h:44
uint32 bid
Definition: AuctionHouseMgr.h:76
time_t expire_time
Definition: AuctionHouseMgr.h:78
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 buyout
Definition: AuctionHouseMgr.h:77
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:353
Definition: Common.h:103
void Initialize(::Item const *item)
Definition: ItemPackets.cpp:248
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
uint64 BuyoutPrice
Definition: AuctionHousePackets.h:52
uint8_t uint8
Definition: Define.h:152
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ObjectGuid Owner
Definition: AuctionHousePackets.h:49
uint32 EndTime
Definition: AuctionHousePackets.h:59
uint64 BidAmount
Definition: AuctionHousePackets.h:61
Definition: Item.h:183
ObjectGuid OwnerAccountID
Definition: AuctionHousePackets.h:58
int32 Charges
Definition: AuctionHousePackets.h:45
uint32 GetAuctionOutBid() const
the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
Definition: AuctionHouseMgr.cpp:794
int32 AuctionItemID
Definition: AuctionHousePackets.h:48
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string AuctionEntry::BuildAuctionMailBody ( uint64  lowGuid,
uint32  bid,
uint32  buyout,
uint32  deposit,
uint32  cut 
)
static
878 {
879  std::ostringstream strm;
880  strm.width(16);
881  strm << std::right << std::hex << ObjectGuid::Create<HighGuid::Player>(lowGuid); // HIGHGUID_PLAYER always present, even for empty guids
882  strm << std::dec << ':' << bid << ':' << buyout;
883  strm << ':' << deposit << ':' << cut;
884  return strm.str();
885 }
uint32 bid
Definition: AuctionHouseMgr.h:76
uint32 buyout
Definition: AuctionHouseMgr.h:77
uint32 deposit
Definition: AuctionHouseMgr.h:80

+ Here is the caller graph for this function:

std::string AuctionEntry::BuildAuctionMailSubject ( MailAuctionAnswers  response) const
871 {
872  std::ostringstream strm;
873  strm << itemEntry << ":0:" << response << ':' << Id << ':' << itemCount;
874  return strm.str();
875 }
uint32 itemEntry
Definition: AuctionHouseMgr.h:72
uint32 itemCount
Definition: AuctionHouseMgr.h:73
uint32 Id
Definition: AuctionHouseMgr.h:69

+ Here is the caller graph for this function:

void AuctionEntry::DeleteFromDB ( SQLTransaction trans) const
801 {
803  stmt->setUInt32(0, Id);
804  trans->Append(stmt);
805 }
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:123
uint32 Id
Definition: AuctionHouseMgr.h:69
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionEntry::GetAuctionCut ( ) const
788 {
790  return std::max(cut, 0);
791 }
Definition: World.h:434
#define sWorld
Definition: World.h:887
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82
T max(const T &x, const T &y)
Definition: g3dmath.h:320
int32_t int32
Definition: Define.h:146
uint32 bid
Definition: AuctionHouseMgr.h:76
T CalculatePct(T base, U pct)
Definition: Util.h:92
int32_t int32
Definition: g3dmath.h:167
uint32 ConsignmentRate
Definition: DB2Structure.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionEntry::GetAuctionOutBid ( ) const

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

795 {
796  uint32 outbid = CalculatePct(bid, 5);
797  return outbid ? outbid : 1;
798 }
uint32_t uint32
Definition: Define.h:150
uint32 bid
Definition: AuctionHouseMgr.h:76
T CalculatePct(T base, U pct)
Definition: Util.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionEntry::GetHouseFaction ( ) const
inline
87 { return auctionHouseEntry->FactionID; }
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82
uint32 FactionID
Definition: DB2Structure.h:56
uint32 AuctionEntry::GetHouseId ( ) const
inline
86 { return auctionHouseEntry->ID; }
uint32 ID
Definition: DB2Structure.h:55
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82

+ Here is the caller graph for this function:

bool AuctionEntry::LoadFromDB ( Field fields)
824 {
825  Id = fields[0].GetUInt32();
826  auctioneer = fields[1].GetUInt64();
827  itemGUIDLow = fields[2].GetUInt64();
828  itemEntry = fields[3].GetUInt32();
829  itemCount = fields[4].GetUInt32();
830  owner = fields[5].GetUInt64();
831  buyout = fields[6].GetUInt32();
832  expire_time = fields[7].GetUInt32();
833  bidder = fields[8].GetUInt64();
834  bid = fields[9].GetUInt32();
835  startbid = fields[10].GetUInt32();
836  deposit = fields[11].GetUInt32();
837 
838  CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(auctioneer);
839  if (!auctioneerData)
840  {
841  TC_LOG_ERROR("misc", "Auction %u has not a existing auctioneer (GUID : " UI64FMTD ")", Id, auctioneer);
842  return false;
843  }
844 
845  CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id);
846  if (!auctioneerInfo)
847  {
848  TC_LOG_ERROR("misc", "Auction %u has not a existing auctioneer (GUID : " UI64FMTD " Entry: %u)", Id, auctioneer, auctioneerData->id);
849  return false;
850  }
851 
852  factionTemplateId = auctioneerInfo->faction;
854  if (!auctionHouseEntry)
855  {
856  TC_LOG_ERROR("misc", "Auction %u has auctioneer (GUID : " UI64FMTD " Entry: %u) with wrong faction %u", Id, auctioneer, auctioneerData->id, factionTemplateId);
857  return false;
858  }
859 
860  // check if sold item exists for guid
861  // and itemEntry in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
862  if (!sAuctionMgr->GetAItem(itemGUIDLow))
863  {
864  TC_LOG_ERROR("misc", "Auction %u has not a existing item : " UI64FMTD, Id, itemGUIDLow);
865  return false;
866  }
867  return true;
868 }
Definition: Creature.h:287
uint32 itemEntry
Definition: AuctionHouseMgr.h:72
uint32 itemCount
Definition: AuctionHouseMgr.h:73
uint64 GetUInt64() const
Definition: Field.h:184
uint32 id
Definition: Creature.h:293
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
#define sObjectMgr
Definition: ObjectMgr.h:1567
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82
uint32 faction
Definition: Creature.h:97
uint32 Id
Definition: AuctionHouseMgr.h:69
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
uint32 startbid
Definition: AuctionHouseMgr.h:75
#define UI64FMTD
Definition: Define.h:137
uint32 bid
Definition: AuctionHouseMgr.h:76
time_t expire_time
Definition: AuctionHouseMgr.h:78
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 buyout
Definition: AuctionHouseMgr.h:77
ObjectGuid::LowType auctioneer
Definition: AuctionHouseMgr.h:70
uint32 factionTemplateId
Definition: AuctionHouseMgr.h:83
uint32 GetUInt32() const
Definition: Field.h:146
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Creature.h:79
uint32 deposit
Definition: AuctionHouseMgr.h:80
static AuctionHouseEntry const * GetAuctionHouseEntry(uint32 factionTemplateId)
Definition: AuctionHouseMgr.cpp:516

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionEntry::SaveToDB ( SQLTransaction trans) const
808 {
810  stmt->setUInt32(0, Id);
811  stmt->setUInt64(1, auctioneer);
812  stmt->setUInt64(2, itemGUIDLow);
813  stmt->setUInt64(3, owner);
814  stmt->setUInt32(4, buyout);
815  stmt->setUInt32(5, uint32(expire_time));
816  stmt->setUInt64(6, bidder);
817  stmt->setUInt32(7, bid);
818  stmt->setUInt32(8, startbid);
819  stmt->setUInt32(9, deposit);
820  trans->Append(stmt);
821 }
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
Definition: PreparedStatement.h:74
uint32 Id
Definition: AuctionHouseMgr.h:69
Definition: CharacterDatabase.h:122
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
uint32 startbid
Definition: AuctionHouseMgr.h:75
uint32 bid
Definition: AuctionHouseMgr.h:76
time_t expire_time
Definition: AuctionHouseMgr.h:78
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 buyout
Definition: AuctionHouseMgr.h:77
ObjectGuid::LowType auctioneer
Definition: AuctionHouseMgr.h:70
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32_t uint32
Definition: g3dmath.h:168
uint32 deposit
Definition: AuctionHouseMgr.h:80

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

ObjectGuid::LowType AuctionEntry::auctioneer
AuctionHouseEntry const* AuctionEntry::auctionHouseEntry
uint32 AuctionEntry::bid
ObjectGuid::LowType AuctionEntry::bidder
uint32 AuctionEntry::buyout
uint32 AuctionEntry::deposit
uint32 AuctionEntry::etime
time_t AuctionEntry::expire_time
uint32 AuctionEntry::factionTemplateId
uint32 AuctionEntry::Id
uint32 AuctionEntry::itemCount
uint32 AuctionEntry::itemEntry
ObjectGuid::LowType AuctionEntry::itemGUIDLow
ObjectGuid::LowType AuctionEntry::owner
uint32 AuctionEntry::startbid

The documentation for this struct was generated from the following files: