76 uint32 curTime = time(NULL);
77 return (endTime >= curTime) ? endTime - curTime : 0;
89 Field* fields = result->Fetch();
98 SF_LOG_ERROR(
"sql.sql",
"Table `blackmarket_template` (MarketId: %u) have data for not existing creature template (Entry: %u), ignoring", blackmarket_template->
MarketId, blackmarket_template->
SellerNPCEntry);
104 SF_LOG_ERROR(
"sql.sql",
"Table `blackmarket_template` (MarketId: %u) have data for not existing item template (Entry: %u), ignoring.", blackmarket_template->
MarketId, blackmarket_template->
ItemEntry);
108 if (!blackmarket_template->
Quantity)
110 SF_LOG_ERROR(
"sql.sql",
"Table `blackmarket_template` (MarketId: %u) have amount == 0 for (ItemEntry : %u) in `blackmarket_template` table, ignoring.", blackmarket_template->
MarketId, blackmarket_template->
ItemEntry);
117 _templates[blackmarket_template->
Id] = blackmarket_template;
120 }
while (result->NextRow());
135 Field* fields = result->Fetch();
157 }
while (result->NextRow());
205 for (
uint32 i = 0; i < number; ++i)
208 std::vector<uint32> templateList;
209 uint32 rand = std::rand() % 100 + 1;
213 if (itr->second->Chance >= rand)
214 templateList.push_back(itr->first);
218 templateList.erase(std::remove(templateList.begin(), templateList.end(), itr->second->GetTemplateId()), templateList.end());
220 if (templateList.empty())
287 SF_LOG_DEBUG(
"network",
">> Sent %u Black Market Auctions", count);
292 uint64 currentBid = newPrice + requiredIncrement;
293 uint64 minIncrement = currentBid * 0.05f;
311 for (BMAuctionTemplateStore::const_iterator itr =
_templates.begin(); itr !=
_templates.end(); ++itr)
312 if (itr->second->Id == templateId)
315 SF_LOG_DEBUG(
"blackMarket",
"BlackMarketMgr::GetTemplate: [%u] not found!", templateId);
321 for (BMAuctionStore::const_iterator itr =
_auctions.begin(); itr !=
_auctions.end(); ++itr)
322 if (itr->second->GetAuctionId() == auctionId)
325 SF_LOG_DEBUG(
"blackMarket",
"BlackMarketMgr::GetAuction: [%u] not found!", auctionId);
331 std::ostringstream strm;
338 std::ostringstream strm;
342 strm <<
':' << 0 <<
':' << 0;
352 if (bidder || bidder_accId)
376 if (bidder || bidder_accId)
struct BlackMarketAuction BlackMarketAuction
struct BlackMarketAuctionTemplate BlackMarketAuctionTemplate
@ CHAR_DEL_BLACKMARKET_AUCTION
@ CHAR_UPD_BLACKMARKET_AUCTION
@ CHAR_SEL_BLACKMARKET_AUCTIONS
@ CHAR_INS_BLACKMARKET_AUCTION
#define SF_LOG_DEBUG(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
#define SF_LOG_INFO(filterType__,...)
@ MAIL_CHECK_MASK_COPIED
This mail was returned. Do not allow returning mail back again.
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
@ WORLD_SEL_BLACKMARKET_TEMPLATE
void SendAuctionWon(BlackMarketAuction *auction, SQLTransaction &trans)
void SendAuctionOutbidded(BlackMarketAuction *auction, SQLTransaction &trans)
BlackMarketAuction * GetAuction(uint32 auctionId) const
BMAuctionStore::iterator GetAuctionsEnd()
uint32 GetFreeAuctionId()
BMAuctionTemplateStore _templates
void UpdateAuction(BlackMarketAuction *auction, uint64 newPrice, uint64 requiredIncrement, Player *newBidder)
void CreateAuctions(uint32 number, SQLTransaction &trans)
BMAuctionTemplateStore::iterator GetTemplatesBegin()
void LoadBlackMarketAuctions()
void LoadBlackMarketTemplates()
BMAuctionStore::iterator GetAuctionsBegin()
void BuildBlackMarketRequestItemsResult(WorldPacket &data, uint32 guidLow)
BlackMarketAuctionTemplate * GetTemplate(uint32 templateId) const
BMAuctionTemplateStore::iterator GetTemplatesEnd()
bool WriteBit(uint32 bit)
void PutBits(size_t pos, T value, uint32 bitCount)
void WriteBits(T value, size_t bits)
virtual void SaveToDB(SQLTransaction &trans)
static Item * CreateItem(uint32 itemEntry, uint32 count, Player const *player=NULL)
void SendMailTo(SQLTransaction &trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0)
MailDraft & AddItem(Item *item)
MailDraft & AddMoney(uint64 money)
static Player * FindPlayer(uint64)
uint32 GetGUIDLow() const
WorldSession * GetSession() const
void setUInt64(const uint8 index, const uint64 value)
void setUInt32(const uint8 index, const uint32 value)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
@ SMSG_BLACKMARKET_OUT_BID
@ SMSG_BLACKMARKET_BID_WON
@ CONFIG_BLACK_MARKET_AUCTION_DELAY_MOD
@ CONFIG_BLACK_MARKET_MAX_AUCTIONS
@ CONFIG_BLACK_MARKET_AUCTION_DELAY
void SetStartTime(uint32 startTime)
uint32 GetStartTime() const
void UpdateToDB(SQLTransaction &trans)
void SaveToDB(SQLTransaction &trans)
uint32 GetTemplateId() const
uint32 GetCurrentBidder() const
void SetCurrentBid(uint64 currentBid)
uint32 GetNumBids() const
std::string BuildAuctionMailBody(uint32 lowGuid)
void SetNumBids(uint32 numBids)
uint64 GetCurrentBid() const
void SetCurrentBidder(uint32 currentBidder)
void SetTemplateId(uint32 templateId)
BlackMarketAuctionTemplate * GetTemplate() const
uint32 GetAuctionId() const
void DeleteFromDB(SQLTransaction &trans)
void SetMinIncrement(uint64 minIncrement)
std::string BuildAuctionMailSubject(BMMailAuctionAnswers response)
uint64 GetMinIncrement() const
void SetAuctionId(uint32 auctionId)