本文整理汇总了C++中draft函数的典型用法代码示例。如果您正苦于以下问题:C++ draft函数的具体用法?C++ draft怎么用?C++ draft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draft函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:Bashakov,项目名称:agg,代码行数:60,代码来源:graph_test.cpp
示例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;
}
开发者ID:Kimbanjang,项目名称:Mong2Core,代码行数:34,代码来源:Mong2_SystemNPC.cpp
示例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;
}
开发者ID:qt-labs,项目名称:messagingframework,代码行数:34,代码来源:writemail.cpp
示例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...");
}
开发者ID:xXNembiXx,项目名称:mangos_335,代码行数:60,代码来源:Mail.cpp
示例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);
}
开发者ID:JunkyBulgaria,项目名称:mop548,代码行数:58,代码来源:MailHandler.cpp
示例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);
}
开发者ID:JunkyBulgaria,项目名称:avalon_core_v1,代码行数:56,代码来源:MailHandler.cpp
示例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);
}
开发者ID:Finest,项目名称:MMOCoreEvo,代码行数:56,代码来源:level_rewards.cpp
示例8: playTurn
void World::endTurn()
{
playTurn();
draft(m_age);
if (m_age >= NUMBER_OF_AGES && betweenTurns())
{
computeScores();
m_gameOver = true;
}
}
开发者ID:dseerutt,项目名称:7Wonders,代码行数:10,代码来源:World.cpp
示例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;
}
开发者ID:Kimbanjang,项目名称:Mong2Core,代码行数:51,代码来源:Mong2_SystemNPC.cpp
示例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);
}
开发者ID:Regigicas,项目名称:TrinityCore,代码行数:50,代码来源:MailHandler.cpp
示例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);
}
开发者ID:qt-labs,项目名称:messagingframework,代码行数:50,代码来源:writemail.cpp
示例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;
}
开发者ID:Marchmalo,项目名称:TrinityElron103,代码行数:43,代码来源:achievement_scripts.cpp
示例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);
}
开发者ID:Bashakov,项目名称:agg,代码行数:22,代码来源:graph_test.cpp
示例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++);
}
}
开发者ID:OrAlien,项目名称:server,代码行数:22,代码来源:Calendar.cpp
示例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);
}
开发者ID:kemlg,项目名称:trinitycore-conciens,代码行数:101,代码来源:MailHandler.cpp
示例16: DETAIL_LOG
//.........这里部分代码省略.........
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && GetSecurity() == SEC_PLAYER)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
}
uint32 rc_account = receive
? receive->GetSession()->GetAccountId()
: sObjectMgr.GetPlayerAccountIdByGUID(rc);
Item* item = NULL;
if (itemGuid)
{
item = pl->GetItemByGuid(itemGuid);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if ((item->GetProto()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
}
pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
// pl->ModifyMoney(-int32(reqmoney));
bool needItemDelay = false;
MailDraft draft(subject, body);
if (itemGuid || money > 0)
{
uint32 rc_account = 0;
if (receive)
rc_account = receive->GetSession()->GetAccountId();
else
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(rc);
if (item)
{
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
}
pl->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(); // deletes item from character's inventory
item->SaveToDB(); // recursive and not have transaction guard into self, 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'", rc.GetCounter(), item->GetGUIDLow());
CharacterDatabase.CommitTransaction();
draft.AddItem(item);
// if item send to character at another account, then apply item delivery delay
needItemDelay = pl->GetSession()->GetAccountId() != rc_account;
}
if (money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account);
}
}
// If theres is an item, there is a one hour delivery delay if sent to another account's character.
uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_UINT32_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
draft
.SetMoney(money)
.SetCOD(COD)
.SendMailTo(MailReceiver(receive, rc), pl, body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
CharacterDatabase.BeginTransaction();
pl->SaveInventoryAndGoldToDB();
CharacterDatabase.CommitTransaction();
}
开发者ID:Lillecarl,项目名称:mangos-classic,代码行数:101,代码来源:MailHandler.cpp
示例17: HandleSendItemsCommand
// Send items by mail
static bool HandleSendItemsCommand(ChatHandler* handler, char const* args)
{
// format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
Player* receiver;
uint64 receiverGuid;
std::string receiverName;
if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
return false;
char* tail1 = strtok(NULL, "");
if (!tail1)
return false;
char const* msgSubject = handler->extractQuotedArg(tail1);
if (!msgSubject)
return false;
char* tail2 = strtok(NULL, "");
if (!tail2)
return false;
char const* msgText = handler->extractQuotedArg(tail2);
if (!msgText)
return false;
// msgSubject, msgText isn't NUL after prev. check
std::string subject = msgSubject;
std::string text = msgText;
// extract items
typedef std::pair<uint32, uint32> ItemPair;
typedef std::list< ItemPair > ItemPairs;
ItemPairs items;
// get all tail string
char* tail = strtok(NULL, "");
// get from tail next item str
while (char* itemStr = strtok(tail, " "))
{
// and get new tail
tail = strtok(NULL, "");
// parse item str
char const* itemIdStr = strtok(itemStr, ":");
char const* itemCountStr = strtok(NULL, " ");
uint32 itemId = atoi(itemIdStr);
if (!itemId)
return false;
ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(itemId);
if (!item_proto)
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
handler->SetSentErrorMessage(true);
return false;
}
uint32 itemCount = itemCountStr ? atoi(itemCountStr) : 1;
if (itemCount < 1 || (item_proto->MaxCount > 0 && itemCount > uint32(item_proto->MaxCount)))
{
handler->PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, itemCount, itemId);
handler->SetSentErrorMessage(true);
return false;
}
while (itemCount > item_proto->GetMaxStackSize())
{
items.push_back(ItemPair(itemId, item_proto->GetMaxStackSize()));
itemCount -= item_proto->GetMaxStackSize();
}
items.push_back(ItemPair(itemId, itemCount));
if (items.size() > MAX_MAIL_ITEMS)
{
handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
handler->SetSentErrorMessage(true);
return false;
}
}
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
// fill mail
MailDraft draft(subject, text);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
{
if (Item* item = Item::CreateItem(itr->first, itr->second, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0))
{
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
draft.AddItem(item);
}
}
//.........这里部分代码省略.........
开发者ID:mynew2,项目名称:trinitycore-1,代码行数:101,代码来源:cs_send.cpp
示例18: GetPlayer
//.........这里部分代码省略.........
Item* item = player->GetItemByGuid(itemGUIDs[i]);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
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() && GetAccountId() != rc_account)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
return;
}
if (item->GetTemplate()->Flags & ITEM_PROTO_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_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)
{
if (items_count > 0)
{
for (uint8 i = 0; i < items_count; ++i)
{
Item* item = items[i];
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
if (item->GetState() == ITEM_UNCHANGED)
item->FSetState(ITEM_CHANGED); // pussywizard: so the item will be saved and owner will be updated in database
item->SetOwnerGUID(rc);
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 = GetAccountId() != rc_account;
}
if( money >= 10*GOLD )
{
CleanStringForMysqlQuery(subject);
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<MAIL> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str());
}
}
// 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(receive, GUID_LOPART(rc)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
开发者ID:DevQuad,项目名称:SunWellCore,代码行数:101,代码来源:MailHandler.cpp
示例19: draft
|
请发表评论