本文整理汇总了C++中Mail::AddAllItems方法的典型用法代码示例。如果您正苦于以下问题:C++ Mail::AddAllItems方法的具体用法?C++ Mail::AddAllItems怎么用?C++ Mail::AddAllItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::AddAllItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendMailTo
void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 stationery, uint32 sender_guidlow_or_entry, uint32 receiver_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay, uint16 mailTemplateId)
{
uint32 mailId = objmgr.GenerateMailID();
time_t deliver_time = time(NULL) + deliver_delay;
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
uint32 expire_delay;
if(messageType == MAIL_AUCTION && !mi && !money) // auction mail without any items and money
expire_delay = HOUR;
else
expire_delay = (COD > 0) ? 3*DAY : 30*DAY;
time_t expire_time = deliver_time + expire_delay;
if(mailTemplateId && !sMailTemplateStore.LookupEntry(mailTemplateId))
{
sLog.outError( "WorldSession::SendMailTo - Mail have not existed MailTemplateId (%u), remove at send", mailTemplateId);
mailTemplateId = 0;
}
if(receiver)
{
receiver->AddNewMailDeliverTime(deliver_time);
if ( receiver->IsMailsLoaded() )
{
Mail * m = new Mail;
m->messageID = mailId;
m->messageType = messageType;
m->stationery = stationery;
m->mailTemplateId = mailTemplateId;
m->sender = sender_guidlow_or_entry;
m->receiver = receiver->GetGUIDLow();
m->subject = subject;
m->itemTextId = itemTextId;
if(mi)
m->AddAllItems(*mi);
m->expire_time = expire_time;
m->deliver_time = deliver_time;
m->money = money;
m->COD = COD;
m->checked = checked;
m->state = MAIL_STATE_UNCHANGED;
receiver->AddMail(m); //to insert new mail to beginning of maillist
if(mi)
{
for(MailItemMap::iterator mailItemIter = mi->begin(); mailItemIter != mi->end(); ++mailItemIter)
{
MailItem& mailItem = mailItemIter->second;
if(mailItem.item)
receiver->AddMItem(mailItem.item);
}
}
}
else if(mi)
mi->deleteIncludedItems();
}
else if(mi)
mi->deleteIncludedItems();
CharacterDatabase.BeginTransaction();
CharacterDatabase.escape_string(subject);
CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%u', '%u', '" I64FMTD "','" I64FMTD "', '%u', '%u', '%d')",
mailId, messageType, stationery, mailTemplateId, sender_guidlow_or_entry, receiver_guidlow, subject.c_str(), itemTextId, (mi && !mi->empty() ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, money, COD, checked);
if(mi)
{
for(MailItemMap::const_iterator mailItemIter = mi->begin(); mailItemIter != mi->end(); ++mailItemIter)
{
MailItem const& mailItem = mailItemIter->second;
CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", mailId, mailItem.item_guidlow, mailItem.item_template,receiver_guidlow);
}
}
CharacterDatabase.CommitTransaction();
}