186{
187 sScriptMgr->OnBeforeMailDraftSendMailTo(
this, receiver, sender, checked, deliver_delay, custom_expiration, deleteMailItemsFromDB, sendMail);
188
189 if (deleteMailItemsFromDB)
191
192 if (!sendMail)
193 return;
194
195 Player* pReceiver = receiver.GetPlayer();
196
197 if (pReceiver)
199
201
203
204
206
207
210
213
215 expire_delay = 3 *
DAY;
216 else if (custom_expiration > 0)
217 expire_delay = custom_expiration *
DAY;
218 else
219 {
222 }
223
224 time_t expire_time = deliver_time + expire_delay;
225
226
230 stmt->
SetData(++index,
uint8(sender.GetMailMessageType()));
231 stmt->
SetData(++index,
int8(sender.GetStationery()));
233 stmt->
SetData(++index, sender.GetSenderId());
234 stmt->
SetData(++index, receiver.GetPlayerGUIDLow());
243 trans->Append(stmt);
244
245 for (MailItemMap::const_iterator mailItemIter =
m_items.begin(); mailItemIter !=
m_items.end(); ++mailItemIter)
246 {
249 stmt->
SetData(1, mailItemIter->second->GetGUID().GetCounter());
250 stmt->
SetData(2, receiver.GetPlayerGUIDLow());
251 trans->Append(stmt);
252 }
253
255
256
257 if (pReceiver)
258 {
260
268
269 for (MailItemMap::const_iterator mailItemIter =
m_items.begin(); mailItemIter !=
m_items.end(); ++mailItemIter)
270 {
271 Item* item = mailItemIter->second;
273 }
274
277 m->
sender = sender.GetSenderId();
278 m->
receiver = receiver.GetPlayerGUIDLow();
283
285
287 {
288 for (MailItemMap::iterator mailItemIter =
m_items.begin(); mailItemIter !=
m_items.end(); ++mailItemIter)
289 {
290 pReceiver->
AddMItem(mailItemIter->second);
291 }
292 }
293 }
295 {
297 }
298}
constexpr auto DAY
Definition: Common.h:49
std::uint8_t uint8
Definition: Define.h:109
std::int8_t int8
Definition: Define.h:105
@ BATTLEGROUND_TYPE_NONE
Definition: SharedDefines.h:3480
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ CONFIG_MAIL_DELIVERY_DELAY
Definition: IWorld.h:263
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:186
#define sCharacterCache
Definition: CharacterCache.h:83
@ MAIL_STATE_UNCHANGED
Definition: Mail.h:68
@ MAIL_AUCTION
Definition: Mail.h:38
@ MAIL_CREATURE
Definition: Mail.h:39
#define sScriptMgr
Definition: ScriptMgr.h:709
@ CHAR_INS_MAIL_ITEM
Definition: CharacterDatabase.h:111
@ CHAR_INS_MAIL
Definition: CharacterDatabase.h:109
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
#define sWorld
Definition: World.h:443
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:251
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 GetEntry() const
Definition: Object.h:115
Definition: ObjectGuid.h:118
Definition: Player.h:1081
void AddNewMailDeliverTime(time_t deliver_time)
Definition: Player.cpp:2904
void AddMItem(Item *it)
Definition: Player.h:1681
WorldSession * GetSession() const
Definition: Player.h:1998
void AddMail(Mail *mail)
Definition: Player.h:1656
void deleteIncludedItems(CharacterDatabaseTransaction trans, bool inDB=false)
Definition: Mail.cpp:132
uint32 GetCOD() const
Definition: Mail.h:132
uint32 GetMoney() const
Definition: Mail.h:131
std::string const & GetSubject() const
Definition: Mail.h:130
uint16 GetMailTemplateId() const
Definition: Mail.h:129
void prepareItems(Player *receiver, CharacterDatabaseTransaction trans)
Definition: Mail.cpp:99
std::string const & GetBody() const
Definition: Mail.h:133
ObjectGuid::LowType receiver
Definition: Mail.h:173
uint8 messageType
Definition: Mail.h:169
uint32 messageID
Definition: Mail.h:168
time_t expire_time
Definition: Mail.h:178
uint32 sender
Definition: Mail.h:172
uint8 stationery
Definition: Mail.h:170
std::string subject
Definition: Mail.h:174
std::string body
Definition: Mail.h:175
void AddItem(ObjectGuid::LowType itemGuidLow, uint32 item_template)
Definition: Mail.h:185
time_t deliver_time
Definition: Mail.h:179
uint32 COD
Definition: Mail.h:181
uint32 checked
Definition: Mail.h:182
MailState state
Definition: Mail.h:183
uint32 money
Definition: Mail.h:180
uint16 mailTemplateId
Definition: Mail.h:171
AccountTypes GetSecurity() const
Definition: WorldSession.h:359