本文整理汇总了C++中MailSender函数的典型用法代码示例。如果您正苦于以下问题:C++ MailSender函数的具体用法?C++ MailSender怎么用?C++ MailSender使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MailSender函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MailDraft
/*
* Processes the external mail queue
*/
void WorldSession::SendExternalMails()
{
sLog.outString("<EXTERNAL MAIL> Send Mails from Queue...");
QueryResult *result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
if(!result)
{
sLog.outString("<EXTERNAL MAIL> No Mails in Queue.");
delete result;
return;
}
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint64 receiver_guid = fields[1].GetUInt64();
std::string subject = fields[2].GetString();
std::string message = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 ItemID = fields[5].GetUInt32();
uint32 ItemCount = fields[6].GetUInt32();
if (Player *receiver = sObjectMgr.GetPlayer(receiver_guid))
{
sLog.outString("<EXTERNAL MAIL> Sending mail to %u, Item: %u", receiver_guid, ItemID);
if (ItemID && ItemCount < 1)
{
sLog.outString("<EXTERNAL MAIL> Warning: invalid ItemCount of %u, setting to 1", ItemCount);
ItemCount = 1;
}
Item* ToMailItem = ItemID ? Item::CreateItem(ItemID, ItemCount, receiver) : NULL;
if (ToMailItem)
{
ToMailItem->SaveToDB();
MailDraft(subject, message)
.AddItem(ToMailItem)
.SetMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, uint32(0), MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
}
else
{
MailDraft(subject, message)
.SetMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, uint32(0), MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
}
CharacterDatabase.PExecute("DELETE FROM mail_external WHERE id=%u", id);
}
else
sLog.outString("<EXTERNAL MAIL> Player %u not in game, skip mail!", receiver_guid);
} while(result->NextRow());
delete result;
sLog.outString("<EXTERNAL MAIL> All Mails Sent.");
}
示例2: SaveToDB
void WorldSession::SendExternalMails()
{
sLog.outDebug("External Mail - Send Mails from Queue...");
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
if (!result)
{
sLog.outDebug("External Mail - No Mails in Queue...");
return;
}
else
{
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint64 receiver_guid = fields[1].GetUInt64();
std::string subject = fields[2].GetString();
std::string message = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 ItemID = fields[5].GetUInt32();
uint32 ItemCount = fields[6].GetUInt32();
Player *receiver = objmgr.GetPlayer(receiver_guid);
if (receiver != 0)
{
sLog.outDebug("External Mail - Sending mail to %llu, Item:%u", receiver_guid, ItemID);
uint32 itemTextId = !message.empty() ? objmgr.CreateItemText(message) : 0;
if (ItemID != 0)
{
Item* ToMailItem = Item::CreateItem(ItemID, ItemCount, receiver);
ToMailItem -> SaveToDB();
MailDraft(subject, itemTextId)
.AddItem(ToMailItem)
.AddMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
}
else
{
MailDraft(subject, itemTextId)
.AddMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
}
CharacterDatabase.PExecute("DELETE FROM mail_external WHERE id=%u", id);
}
}
while(result -> NextRow());
}
sLog.outDebug("External Mail - All Mails Sent...");
}
示例3: GetTaskValue
bool GuildTaskMgr::SendItemAdvertisement(uint32 itemId, uint32 owner, uint32 guildId, uint32 validIn)
{
Guild *guild = sGuildMgr->GetGuildById(guildId);
Player* player = sObjectMgr->GetPlayerByLowGUID(owner);
Player* leader = sObjectMgr->GetPlayerByLowGUID(guild->GetLeaderGUID());
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
return false;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
ostringstream body;
body << "Hello, " << player->GetName() << ",\n";
body << "\n";
body << "We are in a great need of " << proto->Name1 << ". If you could sell us ";
uint32 count = GetTaskValue(owner, guildId, "itemCount");
if (count > 1)
body << "at least " << count << " of them ";
else
body << "some ";
body << "we'd really appreciate that and pay a high price.\n";
body << "The task will expire in " << formatTime(validIn) << "\n";
body << "\n";
body << "Best Regards,\n";
body << guild->GetName() << "\n";
body << leader->GetName() << "\n";
ostringstream subject;
subject << "Guild Task: " << proto->Name1;
MailDraft(subject.str(), body.str()).SendMailTo(trans, MailReceiver(player), MailSender(leader));
CharacterDatabase.CommitTransaction(trans);
return true;
}
示例4: data
void BlackMarketMgr::SendAuctionWon(BMAuctionEntry* auction, SQLTransaction& trans)
{
Player* bidder = sObjectAccessor->FindPlayer(MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER));
if (bidder)
{
WorldPacket data(SMSG_BLACK_MARKET_WON, 12);
data << uint32(1);
data << uint32(1);
data << uint32(auction->bmTemplate->itemEntry);
bidder->GetSession()->SendPacket(&data);
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(auction->bmTemplate->itemEntry);
if (!itemTemplate)
return;
Item* item = Item::CreateItem(auction->bmTemplate->itemEntry, auction->bmTemplate->itemCount);
if (!item)
return;
item->SaveToDB(trans);
MailDraft(auction->BuildAuctionMailSubject(BM_AUCTION_WON), auction->BuildAuctionMailBody(auction->bidder))
.AddItem(item)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), MailSender(auction), MAIL_CHECK_MASK_COPIED);
}
示例5: GetBattlemasterEntry
void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count)
{
uint32 bmEntry = GetBattlemasterEntry();
if (!bmEntry)
return;
ItemPrototype const* markProto = ObjectMgr::GetItemPrototype(mark);
if (!markProto)
return;
if (Item* markItem = Item::CreateItem(mark, count, plr))
{
// save new item before send
markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
// subject: item name
std::string subject = markProto->Name1;
sObjectMgr.GetItemLocaleStrings(markProto->ItemId, loc_idx, &subject);
// text
std::string textFormat = plr->GetSession()->GetMangosString(LANG_BG_MARK_BY_MAIL);
char textBuf[300];
snprintf(textBuf, 300, textFormat.c_str(), GetName(), GetName());
MailDraft(subject, textBuf)
.AddItem(markItem)
.SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry));
}
}
示例6: ObjectGuid
void WorldSession::SendExternalMails()
{
//sLog.outString("EXTERNAL MAIL> Sending mails in queue...");
QueryResult *result = CharacterDatabase.Query("SELECT id,sender,receiver,subject,message,money,stationery FROM mail_external WHERE sent='0'");
if (!result)
{
//sLog.outString("EXTERNAL MAIL> No mails in queue...");
delete result;
return;
}
else
{
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
ObjectGuid senderGuid = ObjectGuid(fields[1].GetUInt64());
ObjectGuid receiverGuid = ObjectGuid(fields[2].GetUInt64());
std::string subject = fields[3].GetString();
std::string message = fields[4].GetString();
uint32 money = fields[5].GetUInt32();
if (Player* Receiver = sObjectMgr.GetPlayer(receiverGuid))
{
//sLog.outString("EXTERNAL MAIL> Send Mail %u to Player %u...", id, receiverGuid.GetCounter());
message = !message.empty() ? message : "Support Message";
MailDraft draft(subject, message);
QueryResult *result2 = CharacterDatabase.PQuery("SELECT item,count FROM mail_external_items WHERE mail_id='%u'", id);
if (result2)
{
do
{
Field *itemfields = result2->Fetch();
uint32 ItemID = itemfields[0].GetUInt32();
uint32 ItemCount = itemfields[1].GetUInt32();
Item* ToMailItem = ItemID ? Item::CreateItem(ItemID, ItemCount, Receiver) : NULL;
if (ToMailItem)
{
ToMailItem->SaveToDB();
draft.AddItem(ToMailItem);
}
}while(result2->NextRow());
}
delete result2;
if (money)
draft.SetMoney(money);
draft.SendMailTo(MailReceiver(Receiver), MailSender(MAIL_NORMAL, senderGuid.GetCounter(), MAIL_STATIONERY_DEFAULT), MAIL_CHECK_MASK_RETURNED);
CharacterDatabase.PExecute("UPDATE mail_external SET sent='1' WHERE id='%u'", id);
}
//else
//sLog.outString("EXTERNAL MAIL> Player %u not in game, skip Mail!", receiverGuid.GetCounter());
}while(result->NextRow());
}
delete result;
//sLog.outString("EXTERNAL MAIL> End Load External Mails...");
}
示例7: receiverGuid
void WorldSession::SendExternalMails()
{
sLog->outCommand(0, "EXTERNAL MAIL> Sending mails in queue...");
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_EXTERNAL_MAIL);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
sLog->outCommand(0, "EXTERNAL MAIL> No mails in queue...");
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft* mail = NULL;
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 receiver_guid = fields[1].GetUInt32();
ObjectGuid receiverGuid(HIGHGUID_PLAYER, receiver_guid);
std::string subject = fields[2].GetString();
std::string body = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 itemId = fields[5].GetUInt32();
uint32 itemCount = fields[6].GetUInt32();
Player *receiver = ObjectAccessor::FindPlayer(receiverGuid);
mail = new MailDraft(subject, body);
if (money)
{
sLog->outCommand(0, "EXTERNAL MAIL> Adding money");
mail->AddMoney(money);
}
if (itemId)
{
sLog->outCommand(0, "EXTERNAL MAIL> Adding %u of item with id %u", itemCount, itemId);
Item* mailItem = Item::CreateItem(itemId, itemCount);
mailItem->SaveToDB(trans);
mail->AddItem(mailItem);
}
mail->SendMailTo(trans, receiver ? receiver : MailReceiver(receiver_guid), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
delete mail;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXTERNAL_MAIL);
stmt->setUInt32(0, id);
trans->Append(stmt);
sLog->outCommand(0, "EXTERNAL MAIL> Mail sent");
}
while (result->NextRow());
CharacterDatabase.CommitTransaction(trans);
sLog->outCommand(0, "EXTERNAL MAIL> All Mails Sent...");
}
示例8: MAKE_NEW_GUID
void BlackMarketMgr::SendAuctionWon(BMAuctionEntry* auction, SQLTransaction& trans)
{
uint64 bidderGUID = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
Player* bidder = sObjectAccessor->FindPlayer(bidderGUID);
if (bidder)
{
WorldPacket data(SMSG_BLACKMARKET_WON, 12);
data << uint32(1);
data << uint32(1);
data << uint32(auction->bm_template->itemEntry);
bidder->GetSession()->SendPacket(&data);
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(auction->bm_template->itemEntry);
if (!itemTemplate)
return;
Item* pItem = Item::CreateItem(auction->bm_template->itemEntry, auction->bm_template->itemCount, bidder);
// Create new item in the database
//SQLTransaction trans2 = CharacterDatabase.BeginTransaction();
pItem->SetOwnerGUID(bidderGUID);
pItem->SaveToDB(trans);
//CharacterDatabase.CommitTransaction(trans2);
MailDraft(auction->BuildAuctionMailSubject(BM_AUCTION_WON), auction->BuildAuctionMailBody(auction->bidder))
.AddItem(pItem)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), MailSender(auction), MAIL_CHECK_MASK_COPIED);
}
示例9: formatTime
bool GuildTaskMgr::SendKillAdvertisement(uint32 creatureId, uint32 owner, uint32 guildId, uint32 validIn)
{
Guild *guild = sGuildMgr->GetGuildById(guildId);
Player* player = sObjectMgr->GetPlayerByLowGUID(owner);
Player* leader = sObjectMgr->GetPlayerByLowGUID(guild->GetLeaderGUID());
CreatureTemplate const* proto = sObjectMgr->GetCreatureTemplate(creatureId);
if (!proto)
return false;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
ostringstream body;
body << "Hello, " << player->GetName() << ",\n";
body << "\n";
body << "As you probably know " << proto->Name << " is wanted dead for the crimes it did against our guild. If you should kill it ";
body << "we'd really appreciate that.\n";
body << "The task will expire in " << formatTime(validIn) << "\n";
body << "\n";
body << "Best Regards,\n";
body << guild->GetName() << "\n";
body << leader->GetName() << "\n";
ostringstream subject;
subject << "Guild Task: " << proto->Name;
MailDraft(subject.str(), body.str()).SendMailTo(trans, MailReceiver(player), MailSender(leader));
CharacterDatabase.CommitTransaction(trans);
return true;
}
示例10: deleteIncludedItems
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid )
{
Player *receiver = sObjectMgr.GetPlayer(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
uint32 rc_account = 0;
if(!receiver)
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
if(!receiver && !rc_account) // sender not exist
{
deleteIncludedItems(true);
return;
}
// prepare mail and send in other case
bool needItemDelay = false;
if(!m_items.empty())
{
// if item send to character at another account, then apply item delivery delay
needItemDelay = sender_acc != rc_account;
// set owner to new receiver (to prevent delete item with sender char deleting)
CharacterDatabase.BeginTransaction();
for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
item->SaveToDB(); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_guid, item->GetGUIDLow());
}
CharacterDatabase.CommitTransaction();
}
// If theres is an item, there is a one hour delivery delay.
uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
if (sender_guid == auctionbot.GetAHBplayerGUID())
{
SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_CREATURE, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
}
else
{
SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
}
}
示例11: MailDraft
void WorldSession::SendExternalMails()
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_EXTERNAL_MAIL);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft* mail = NULL;
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 receiver_guid = fields[1].GetUInt32();
std::string subject = fields[2].GetString();
std::string body = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 itemId = fields[5].GetUInt32();
uint32 itemCount = fields[6].GetUInt32();
Player *receiver = sObjectMgr->GetPlayerByLowGUID(receiver_guid);
mail = new MailDraft(subject, body);
if (money)
{
mail->AddMoney(money);
}
if (itemId)
{
Item* mailItem = Item::CreateItem(itemId, itemCount);
mailItem->SaveToDB(trans);
mail->AddItem(mailItem);
}
mail->SendMailTo(trans, receiver ? receiver : MailReceiver(receiver_guid), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
delete mail;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXTERNAL_MAIL);
stmt->setUInt32(0, id);
trans->Append(stmt);
}
while (result->NextRow());
CharacterDatabase.CommitTransaction(trans);
}
示例12: fixgutschein
void fixgutschein(Player* player, uint32 belohnung, uint32 anzahl, std::string grund ){
CharacterDatabase.PExecute("INSERT INTO item_codes (code,belohnung,anzahl,benutzt,name,benutztbar) Values ('%s','%u','%u','%u','%s','%u')", grund, belohnung, anzahl, 1, player->GetName(),1);
Item* item = Item::CreateItem(belohnung, anzahl);
player->GetSession()->SendNotification("Dein Code wurde generiert und die Belohnung zugesendet!");
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->SaveToDB(trans);
MailDraft("Dein Gutscheincode", "Dein Code wurde erfolgreich eingeloest. Wir wuenschen dir weiterhin viel Spass auf MMOwning. Dein MMOwning-Team").AddItem(item)
.SendMailTo(trans, MailReceiver(player, player->GetGUID()), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM));
CharacterDatabase.CommitTransaction(trans);
DBeintrag(player->GetSession()->GetPlayer(), "fixgutschein");
return;
}
示例13: MailDraft
void GameEventMgr::SendEventMails(int16 event_id)
{
int32 internal_event_id = mGameEvent.size() + event_id - 1;
MailList const& mails = mGameEventMails[internal_event_id];
for (MailList::const_iterator itr = mails.begin(); itr != mails.end(); ++itr)
{
if (itr->questId)
{
// need special query
std::ostringstream ss;
ss << "SELECT characters.guid FROM characters, character_queststatus "
"WHERE (1 << (characters.race - 1)) & "
<< itr->raceMask
<< " AND characters.deleteDate IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = "
<< itr->questId
<< " AND character_queststatus.rewarded <> 0";
sMassMailMgr.AddMassMailTask(new MailDraft(itr->mailTemplateId), MailSender(MAIL_CREATURE, itr->senderEntry), ss.str().c_str());
}
else
sMassMailMgr.AddMassMailTask(new MailDraft(itr->mailTemplateId), MailSender(MAIL_CREATURE, itr->senderEntry), itr->raceMask);
}
}
示例14: MAKE_NEW_GUID
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid,
uint32 receiver_guid, SQLTransaction& trans) {
Player *receiver = sObjectMgr->GetPlayer(
MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
uint32 rc_account = 0;
if (!receiver)
rc_account = sObjectMgr->GetPlayerAccountIdByGUID(
MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
if (!receiver && !rc_account) // sender not exist
{
deleteIncludedItems(trans, true);
return;
}
// prepare mail and send in other case
bool needItemDelay = false;
if (!m_items.empty()) {
// if item send to character at another account, then apply item delivery delay
needItemDelay = sender_acc != rc_account;
// set owner to new receiver (to prevent delete item with sender char deleting)
for (MailItemMap::iterator mailItemIter = m_items.begin();
mailItemIter != m_items.end(); ++mailItemIter) {
Item* item = mailItemIter->second;
item->SaveToDB(trans); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(
CHAR_SET_ITEM_OWNER);
stmt->setUInt32(0, receiver_guid);
stmt->setUInt32(1, item->GetGUIDLow());
trans->Append(stmt);
}
}
// If theres is an item, there is a one hour delivery delay.
uint32 deliver_delay =
needItemDelay ?
sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
SendMailTo(trans, MailReceiver(receiver, receiver_guid),
MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED,
deliver_delay);
}
示例15: OnCheck
bool OnCheck(Player* player, Unit* target)
{
if (!player)
return false;
// this is a duplicated criteria check but we need it since we are not
// really doing any check here but just use this as a hook to send out
// the achievement related mails.
if (!player->GetQuestRewardStatus(_questEntry))
return false;
// if we are here we need to create the mail for the stupid brew of the year club
uint32 brew_of_the_month_beers[12] = {37496, 37497, 37498, 37499, 37488, 37489, 37490, 37491, 37492, 37493, 37494, 37495}; // sep-aug
uint32 delay = 0;
for (uint8 iter = 0; iter < 12; ++iter)
{
Item* item = brew_of_the_month_beers[iter] ? Item::CreateItem(brew_of_the_month_beers[iter], 1, player) : NULL;
// subject and text
std::string subject = "Bräu des Monats!";
std::string text = "Deine monatliche Bier-Lieferung befindet sich im Anhang.$B$BProst!";
MailDraft draft(subject, text);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (item)
{
// save new item before send
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
// item
draft.AddItem(item);
}
draft.SendMailTo(trans, player, MailSender(MAIL_CREATURE, 28329), MAIL_CHECK_MASK_HAS_BODY, delay);
CharacterDatabase.CommitTransaction(trans);
// TODO calculate correct send times
delay += 30*86400;
}
sLog->outInfo(LOG_FILTER_TSCR, "Player %s achieved Brew of the Month Club and has 12 mails added with beer over the next 12 month.", player->GetName());
return true;
}