[10970] Implement mass mail send infrastructure.

It expected to be used in 2 case: some gameevent must send mails at start/end,
and this can be useful in game commands. Both case wil implemented in later commits.

* New MassMailMgr can accept tasks for send mass mails in safe way for map update threads context/etc.
* It work in way:
   - By provided race mask or more generic SQL query string in async query selected affected characters
   - At query result ready at next world tick update in safe common part of tick code some from mails
     from queued mas mail tasks send.
   - Amount mails limited MassMailer.SendPerTick confir option (10 by default). This done for prevent
     high server load/lags at send too many mails in one tick (mail send all existed characters in DB
     who match to seelction criteria)
   - Manager not persistant for server shutdowns so any not send mails in queue lost at shutdown.
     But with default setting 10K mail send in 20 secs (10000/50/10). Adding more safe execution
     for this case will make related code lot more slow and req. many DB tables and code support.
This commit is contained in:
VladimirMangos 2011-01-06 05:48:35 +03:00
parent 231c6d77ce
commit 5f2aef756a
13 changed files with 331 additions and 2 deletions

View file

@ -918,6 +918,33 @@ void MailDraft::deleteIncludedItems( bool inDB /**= false*/ )
m_items.clear();
}
/**
* Clone MailDraft from another MailDraft.
*
* @param draft Point to source for draft cloning.
*/
void MailDraft::CloneFrom(MailDraft const& draft)
{
m_mailTemplateId = draft.GetMailTemplateId();
m_mailTemplateItemsNeed = draft.m_mailTemplateItemsNeed;
m_subject = draft.GetSubject();
m_body = draft.GetBody();
m_money = draft.GetMoney();
m_COD = draft.GetCOD();
for(MailItemMap::const_iterator mailItemIter = draft.m_items.begin(); mailItemIter != draft.m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
if(Item* newitem = item->CloneItem(item->GetCount()))
{
newitem->SaveToDB();
AddItem(newitem);
}
}
}
/*
* Returns a mail to its sender.
* @param sender_acc The id of the account of the sender.