本文整理汇总了C++中draft函数的典型用法代码示例。如果您正苦于以下问题:C++ draft函数的具体用法?C++ draft怎么用?C++ draft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draft函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_ctrl_change
virtual void on_ctrl_change()
{
if(m_benchmark.status())
{
int i;
on_draw();
update_window();
scanline_rasterizer ras;
pixfmt pixf(rbuf_window());
base_renderer rb(pixf);
solid_renderer solid(rb);
draft_renderer draft(rb);
char buf[256];
if(m_draft.status())
{
start_timer();
for(i = 0; i < 10; i++)
{
draw_scene(ras, solid, draft);
}
sprintf(buf, "%3.3f milliseconds", elapsed_time());
}
else
{
double times[5];
for(m_draw = 0; m_draw < 4; m_draw++)
{
start_timer();
for(i = 0; i < 10; i++)
{
draw_scene(ras, solid, draft);
}
times[m_draw] = elapsed_time();
}
m_draw = 3;
times[4] = times[3];
times[3] -= times[2];
times[2] -= times[1];
times[1] -= times[0];
FILE* fd = fopen(full_file_name("benchmark"), "a");
fprintf(fd, "%10.3f %10.3f %10.3f %10.3f %10.3f\n",
times[0], times[1], times[2], times[3], times[4]);
fclose(fd);
sprintf(buf, " pipeline add_path sort render total\n"
"%10.3f %10.3f %10.3f %10.3f %10.3f",
times[0], times[1], times[2], times[3], times[4]);
}
message(buf);
m_benchmark.status(false);
force_redraw();
}
}
示例2: UpdateAI
void UpdateAI(const uint32 diff)
{
if (SendTimer <= diff)
{
QueryResult result = CharacterDatabase.PQuery("SELECT idx,cguid,item_entry,item_stack FROM kc_item_mail WHERE flag = '0' LIMIT 1;");
if(result)
{
Field *fields = result->Fetch();
uint32 m_idx=fields[0].GetUInt32();
uint32 m_guid=fields[1].GetUInt32();
uint32 m_item_entry=fields[2].GetUInt32();
uint32 m_item_stack=fields[3].GetUInt32();
MailSender sender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM); // 보내는 사람이 GM으로 등록
Player *pPlayer = sObjectMgr->GetPlayerByLowGUID(m_guid); //guid 값을 넣으면 케릭터를 찾을수있다.
SQLTransaction trans = CharacterDatabase.BeginTransaction(); //메일관련 SQL을 등록
MailDraft draft("몽이 포인트샵","포인트샵에서 구입한 물품이 도착 했습니다.");
if (Item* item = Item::CreateItem(m_item_entry,m_item_stack,pPlayer))
{
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
draft.AddItem(item);
}
draft.SendMailTo(trans, MailReceiver(pPlayer, GUID_LOPART(m_guid)),sender);
CharacterDatabase.CommitTransaction(trans);
CharacterDatabase.PQuery("UPDATE kc_item_mail SET flag = '1' WHERE idx= '%d' ",m_idx);
}
SendTimer = 500000;
}
else SendTimer -= diff;
}
示例3: tr
bool WriteMail::sendStage()
{
if (!isComplete()) {
// The user must either complete the message, save as draft or explicitly cancel
return false;
}
if (buildMail(true)) {
if (largeAttachments()) {
// Ensure this is intentional
if (QMessageBox::question(qApp->activeWindow(),
tr("Large attachments"),
tr("The message has large attachments. Send now?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
draft();
QMessageBox::warning(qApp->activeWindow(),
tr("Message saved"),
tr("The message has been saved in the Drafts folder"),
QMessageBox::Ok);
return true;
}
}
emit enqueueMail(mail);
} else {
qMailLog(Messaging) << "Unable to build mail for transmission!";
}
// Prevent double deletion of composer textedit that leads to crash on exit
reset();
close();
return true;
}
示例4: 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...");
}
示例5: draft
void WorldSession::HandleMailReturnToSender(WorldPacket& recvData)
{
ObjectGuid mailbox;
uint32 mailId;
recvData >> mailId;
recvData.ReadGuidMask(mailbox, 2, 0, 4, 6, 3, 1, 7, 5);
recvData.ReadGuidBytes(mailbox, 5, 6, 2, 0, 3, 1, 4, 7);
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
//we can return mail now, so firstly delete the old one
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
stmt->setUInt32(0, mailId);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
stmt->setUInt32(0, mailId);
trans->Append(stmt);
player->RemoveMail(mailId);
// only return mail if the player exists (and delete if not existing)
if (m->messageType == MAIL_NORMAL && m->sender)
{
MailDraft draft(m->subject, m->body);
if (m->mailTemplateId)
draft = MailDraft(m->mailTemplateId, false); // items already included
if (m->HasItems())
{
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{
if (Item* const item = player->GetMItem(itr2->item_guid))
draft.AddItem(item);
player->RemoveMItem(itr2->item_guid);
}
}
draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
}
CharacterDatabase.CommitTransaction(trans);
delete m; //we can deallocate old mail
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
}
示例6: draft
void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
{
uint64 mailbox;
uint32 mailId;
recv_data >> mailbox;
recv_data >> mailId;
recv_data.read_skip<uint64>(); // original sender GUID for return to, not used
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
if (!GetPlayer()->GetNPCIfCanInteractWith(mailbox, UNIT_NPC_FLAG_MAILBOX))
return;
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
//we can return mail now
//so firstly delete the old one
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM mail WHERE id = '%u'", mailId); // needed?
trans->PAppend("DELETE FROM mail_items WHERE mail_id = '%u'", mailId);
player->RemoveMail(mailId);
// only return mail if the player exists (and delete if not existing)
if (m->messageType == MAIL_NORMAL && m->sender)
{
MailDraft draft(m->subject, m->body);
if (m->mailTemplateId)
draft = MailDraft(m->mailTemplateId, false); // items already included
if (m->HasItems())
{
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{
Item* item = player->GetMItem(itr2->item_guid);
if (item)
draft.AddItem(item);
else
{
//WTF?
}
player->RemoveMItem(itr2->item_guid);
}
}
draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
}
CharacterDatabase.CommitTransaction(trans);
delete m; //we can deallocate old mail
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
}
示例7: OnLevelChanged
void OnLevelChanged(Player* player, uint8 oldLevel)
{
if (player->IsGameMaster())
return;
uint32 money = 0;
switch (oldLevel)
{
case 9:
money = 150000;
break;
case 19:
money = 250000;
break;
case 29:
money = 400000;
break;
case 39:
money = 500000;
break;
case 49:
money = 600000;
break;
case 59:
money = 1000000;
break;
case 69:
money = 1500000;
break;
case 79:
money = 2000000;
break;
default:
return;
}
MailSender sender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM);
MailDraft draft("Herzlichen Glückwunsch", "Herzlichen Glückwünsch du bist auf MMOwning vorangekommen und verdienst eine Belohnung. :)");
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (money > 0)
draft.AddMoney(money);
/*
if (oldLevel == 79)
{
Item* item = Item::CreateItem(EMBLEM_OF_CONQUEST, 300, 0);
item->SaveToDB(trans);
draft.AddItem(item);
}
*/
draft.SendMailTo(trans, MailReceiver(player), sender);
CharacterDatabase.CommitTransaction(trans);
}
示例8: playTurn
void World::endTurn()
{
playTurn();
draft(m_age);
if (m_age >= NUMBER_OF_AGES && betweenTurns())
{
computeScores();
m_gameOver = true;
}
}
示例9: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
{
if(action == 1)
{
QueryResult result = CharacterDatabase.PQuery("SELECT SUM(IF(`flag`='1',0,1)) FROM `kc_item_mail`;");
Field *fields = result->Fetch();
uint32 notSendMailCount = fields[0].GetUInt32();
if(notSendMailCount < 1)
creature->MonsterWhisper("현재 대기중인 택배가 없습니다.", player->GetGUID());
else
{
char checkMSG[50];
snprintf(checkMSG, 50, "배송 대기중 택배수 : %u", notSendMailCount);
creature->MonsterWhisper(checkMSG, player->GetGUID());
}
}
else
{
QueryResult result = CharacterDatabase.PQuery("SELECT idx,cguid,item_entry,item_stack FROM kc_item_mail WHERE flag = '0' LIMIT 1;");
if(result)
{
Field *fields = result->Fetch();
uint32 m_idx=fields[0].GetUInt32();
uint32 m_guid=fields[1].GetUInt32();
uint32 m_item_entry=fields[2].GetUInt32();
uint32 m_item_stack=fields[3].GetUInt32();
MailSender sender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM); // 보내는 사람이 GM으로 등록
Player *pPlayer = sObjectMgr->GetPlayerByLowGUID(m_guid); //guid 값을 넣으면 케릭터를 찾을수있다.
SQLTransaction trans = CharacterDatabase.BeginTransaction(); //메일관련 SQL을 등록
MailDraft draft("몽이 포인트샵","포인트샵에서 구입한 물품이 도착 했습니다.");
if (Item* item = Item::CreateItem(m_item_entry,m_item_stack,pPlayer))
{
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
draft.AddItem(item);
}
draft.SendMailTo(trans, MailReceiver(pPlayer, GUID_LOPART(m_guid)),sender);
CharacterDatabase.CommitTransaction(trans);
CharacterDatabase.PQuery("UPDATE kc_item_mail SET flag = '1' WHERE idx= '%d' ",m_idx);
}
creature->MonsterWhisper("다음 배송예정 택배를 강제 배송 했습니다.", player->GetGUID());
}
player->CLOSE_GOSSIP_MENU();
return true;
}
示例10: draft
void WorldSession::HandleMailReturnToSender(WorldPackets::Mail::MailReturnToSender& packet)
{
//TODO: find a proper way to replace this check. Idea: Save Guid form MailGetList until CMSG_CLOSE_INTERACTION is sent
/*if (!CanOpenMailBox(mailbox))
return;*/
Player* player = _player;
Mail* m = player->GetMail(packet.MailID);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr) || m->sender != packet.SenderGUID.GetCounter())
{
player->SendMailResult(packet.MailID, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
//we can return mail now, so firstly delete the old one
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
stmt->setUInt32(0, packet.MailID);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
stmt->setUInt32(0, packet.MailID);
trans->Append(stmt);
player->RemoveMail(packet.MailID);
// only return mail if the player exists (and delete if not existing)
if (m->messageType == MAIL_NORMAL && m->sender)
{
MailDraft draft(m->subject, m->body);
if (m->mailTemplateId)
draft = MailDraft(m->mailTemplateId, false); // items already included
if (m->HasItems())
{
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{
if (Item* const item = player->GetMItem(itr2->item_guid))
draft.AddItem(item);
player->RemoveMItem(itr2->item_guid);
}
}
draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
}
CharacterDatabase.CommitTransaction(trans);
delete m; //we can deallocate old mail
player->SendMailResult(packet.MailID, MAIL_RETURNED_TO_SENDER, MAIL_OK);
}
示例11: QToolBar
void WriteMail::init()
{
m_toolbar = new QToolBar(this);
addToolBar(m_toolbar);
m_widgetStack = new QStackedWidget(this);
m_cancelAction = new QAction(Qtmail::icon("cancel"),tr("Close"),this);
connect( m_cancelAction, SIGNAL(triggered()), this, SLOT(discard()) );
addAction(m_cancelAction);
m_draftAction = new QAction(Qtmail::icon("saveToDraft"),tr("Save in drafts"),this);
connect( m_draftAction, SIGNAL(triggered()), this, SLOT(draft()) );
m_draftAction->setWhatsThis( tr("Save this message as a draft.") );
addAction(m_draftAction);
m_sendAction = new QAction(Qtmail::icon("sendmail"),tr("Send"),this);
connect( m_sendAction, SIGNAL(triggered()), this, SLOT(sendStage()) );
m_sendAction->setWhatsThis( tr("Send the message.") );
addAction(m_sendAction);
m_accountSelection = new QComboBox(m_toolbar);
connect( m_accountSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(accountSelectionChanged(int)) );
m_selectComposerWidget = new SelectComposerWidget(this);
m_selectComposerWidget->setObjectName("selectComposer");
connect(m_selectComposerWidget, SIGNAL(selected(QPair<QString,QMailMessage::MessageType>)),
this, SLOT(composerSelected(QPair<QString,QMailMessage::MessageType>)));
connect(m_selectComposerWidget, SIGNAL(cancel()), this, SLOT(discard()));
m_widgetStack->addWidget(m_selectComposerWidget);
setCentralWidget(m_widgetStack);
QMenuBar* mainMenuBar = new QMenuBar();
setMenuBar(mainMenuBar);
QMenu* file = mainMenuBar->addMenu("File");
file->addAction(m_sendAction);
file->addAction(m_draftAction);
file->addSeparator();
file->addAction(m_cancelAction);
m_toolbar->addAction(m_sendAction);
m_toolbar->addAction(m_draftAction);
m_toolbar->addWidget(m_accountSelection);
m_toolbar->addSeparator();
setWindowTitle(tr("Compose"));
setGeometry(0,0,defaultWidth,defaultHeight);
}
示例12: 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;
}
示例13: on_draw
//------------------------------------------------------------------------
virtual void on_draw()
{
scanline_rasterizer ras;
pixfmt pixf(rbuf_window());
base_renderer rb(pixf);
solid_renderer solid(rb);
draft_renderer draft(rb);
rb.clear(agg::rgba(1, 1, 1));
draw_scene(ras, solid, draft);
ras.filling_rule(agg::fill_non_zero);
agg::render_ctrl(ras, m_sl, rb, m_type);
agg::render_ctrl(ras, m_sl, rb, m_width);
agg::render_ctrl(ras, m_sl, rb, m_benchmark);
agg::render_ctrl(ras, m_sl, rb, m_draw_nodes);
agg::render_ctrl(ras, m_sl, rb, m_draw_edges);
agg::render_ctrl(ras, m_sl, rb, m_draft);
agg::render_ctrl(ras, m_sl, rb, m_translucent);
}
示例14: secsToTimeBitFields
// remove all invite sending ingame mail
void CalendarEvent::RemoveAllInvite(ObjectGuid const& removerGuid)
{
// build mail title
std::ostringstream title;
title << removerGuid << ':' << Title;
// build mail body
std::ostringstream body;
body << secsToTimeBitFields(time(NULL));
// creating mail draft
MailDraft draft(title.str(), body.str());
CalendarInviteMap::iterator itr = m_Invitee.begin();
while (itr != m_Invitee.end())
{
if (removerGuid != itr->second->InviteeGuid)
draft.SendMailTo(MailReceiver(itr->second->InviteeGuid), this, MAIL_CHECK_MASK_COPIED);
RemoveInviteByItr(itr++);
}
}
示例15: GetPlayer
//.........这里部分代码省略.........
return;
}
if (!item->CanBeTraded(true))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != receiverAccountId)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
return;
}
if ((item->GetTemplate()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
if (item->IsNotEmptyBag())
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
return;
}
items[i] = item;
}
player->SendMailResult(0, MAIL_SEND, MAIL_OK);
player->ModifyMoney(-int32(reqmoney));
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
bool needItemDelay = false;
MailDraft draft(subject, body);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (items_count > 0 || money > 0)
{
bool log = HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE);
if (items_count > 0)
{
for (uint8 i = 0; i < items_count; ++i)
{
Item* item = items[i];
if (log)
{
sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail item: %s (Entry: %u Count: %u) "
"to: %s (%s) (Account: %u)", GetPlayerName().c_str(), GetGUIDLow(), GetAccountId(),
item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount(),
receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
player->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
item->SetOwnerGUID(receiverGuid);
item->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
draft.AddItem(item);
}
// if item send to character at another account, then apply item delivery delay
needItemDelay = player->GetSession()->GetAccountId() != receiverAccountId;
}
if (log && money > 0)
{
sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail money: %u to: %s (%s) (Account: %u)",
GetPlayerName().c_str(), GetGUIDLow(), GetAccountId(), money, receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
}
// If theres is an item, there is a one hour delivery delay if sent to another account's character.
uint32 deliver_delay = needItemDelay ? sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// don't ask for COD if there are no items
if (items_count == 0)
COD = 0;
// will delete item or place to receiver mail list
draft
.AddMoney(money)
.AddCOD(COD)
.SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}