TrinityCore
Loading...
Searching...
No Matches
MailHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
19#include "AccountMgr.h"
20#include "CharacterCache.h"
21#include "DatabaseEnv.h"
22#include "DBCStores.h"
23#include "GameTime.h"
24#include "Item.h"
25#include "Language.h"
26#include "Log.h"
27#include "Mail.h"
28#include "MailPackets.h"
29#include "ObjectAccessor.h"
30#include "ObjectMgr.h"
31#include "Opcodes.h"
32#include "Player.h"
33#include "World.h"
34#include "WorldPacket.h"
35
37{
38 if (guid == _player->GetGUID())
39 {
41 {
42 TC_LOG_WARN("cheat", "{} attempted to open mailbox by using a cheat.", _player->GetName());
43 return false;
44 }
45 }
46 else if (guid.IsGameObject())
47 {
49 return false;
50 }
51 else if (guid.IsAnyTypeCreature())
52 {
54 return false;
55 }
56 else
57 return false;
58
59 return true;
60}
61
63{
64 if (!CanOpenMailBox(sendMail.Info.Mailbox))
65 return;
66
67 if (sendMail.Info.Target.empty())
68 return;
69
70 Player* player = _player;
71
72 if (_player->GetLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
73 {
75 return;
76 }
77
78 ObjectGuid receiverGuid;
79 if (normalizePlayerName(sendMail.Info.Target))
80 receiverGuid = sCharacterCache->GetCharacterGuidByName(sendMail.Info.Target);
81
82 if (!receiverGuid)
83 {
84 TC_LOG_INFO("network", "Player {} is sending mail to {} (GUID: non-existing!) with subject {} "
85 "and body {} includes {} items, {} copper and {} COD copper with StationeryID = {}, PackageID = {}",
86 GetPlayerInfo(), sendMail.Info.Target, std::string_view(sendMail.Info.Subject), std::string_view(sendMail.Info.Body),
87 sendMail.Info.Attachments.size(), sendMail.Info.SendMoney, sendMail.Info.Cod, sendMail.Info.StationeryID, sendMail.Info.PackageID);
89 return;
90 }
91
92 if (sendMail.Info.SendMoney < 0)
93 {
95 TC_LOG_WARN("cheat", "Player {} attempted to send mail to {} ({}) with negative money value (SendMoney: {})",
96 GetPlayerInfo(), sendMail.Info.Target, receiverGuid.ToString(), sendMail.Info.SendMoney);
97 return;
98 }
99
100 if (sendMail.Info.Cod < 0)
101 {
103 TC_LOG_WARN("cheat", "Player {} attempted to send mail to {} ({}) with negative COD value (Cod: {})",
104 GetPlayerInfo(), sendMail.Info.Target, receiverGuid.ToString(), sendMail.Info.Cod);
105 return;
106 }
107
108 TC_LOG_INFO("network", "Player {} is sending mail to {} ({}) with subject {} and body {} "
109 "including {} items, {} copper and {} COD copper with StationeryID = {}, PackageID = {}",
110 GetPlayerInfo(), sendMail.Info.Target, receiverGuid.ToString(), std::string_view(sendMail.Info.Subject),
111 std::string_view(sendMail.Info.Body), sendMail.Info.Attachments.size(), sendMail.Info.SendMoney, sendMail.Info.Cod, sendMail.Info.StationeryID, sendMail.Info.PackageID);
112
113 if (player->GetGUID() == receiverGuid)
114 {
116 return;
117 }
118
119 int32 cost = !sendMail.Info.Attachments.empty() ? 30 * sendMail.Info.Attachments.size() : 30; // price hardcoded in client
120
121 int32 reqmoney = cost + sendMail.Info.SendMoney;
122
123 // Check for overflow
124 if (reqmoney < sendMail.Info.SendMoney)
125 {
127 return;
128 }
129
130 auto mailCountCheckContinuation = [this, player = _player, receiverGuid, mailInfo = std::move(sendMail.Info), reqmoney, cost](uint32 receiverTeam, uint64 mailsCount, uint8 receiverLevel, uint32 receiverAccountId) mutable
131 {
132 if (_player != player)
133 return;
134
135 if (!player->HasEnoughMoney(reqmoney) && !player->IsGameMaster())
136 {
138 return;
139 }
140
141 // do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
142 if (mailsCount > 100)
143 {
145 return;
146 }
147
148 // test the receiver's Faction... or all items are account bound
149 bool accountBound = !mailInfo.Attachments.empty();
150 for (auto const& att : mailInfo.Attachments)
151 {
152 if (Item* item = player->GetItemByGuid(att.ItemGUID))
153 {
154 ItemTemplate const* itemProto = item->GetTemplate();
155 if (!itemProto || !itemProto->HasFlag(ITEM_FLAG_IS_BOUND_TO_ACCOUNT))
156 {
157 accountBound = false;
158 break;
159 }
160 }
161 }
162
163 if (!accountBound && player->GetTeam() != receiverTeam && !HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_MAIL))
164 {
166 return;
167 }
168
169 if (receiverLevel < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
170 {
172 return;
173 }
174
175 std::vector<Item*> items;
176
177 for (auto const& att : mailInfo.Attachments)
178 {
179 if (att.ItemGUID.IsEmpty())
180 {
182 return;
183 }
184
185 Item* item = player->GetItemByGuid(att.ItemGUID);
186
187 // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
188 if (!item)
189 {
191 return;
192 }
193
194 // handle empty bag before CanBeTraded, since that func already has that check
195 if (item->IsNotEmptyBag())
196 {
198 return;
199 }
200
201 if (!item->CanBeTraded(true))
202 {
204 return;
205 }
206
207 if (item->IsBoundAccountWide() && item->IsSoulBound() && GetAccountId() != receiverAccountId)
208 {
210 return;
211 }
212
214 {
216 return;
217 }
218
219 if (mailInfo.Cod && item->IsWrapped())
220 {
222 return;
223 }
224
225 items.push_back(item);
226 }
227
228 player->SendMailResult(0, MAIL_SEND, MAIL_OK);
229
230 player->ModifyMoney(-int32(reqmoney));
232
233 bool needItemDelay = false;
234
235 MailDraft draft(mailInfo.Subject, mailInfo.Body);
236
237 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
238
239 if (!mailInfo.Attachments.empty() || mailInfo.SendMoney > 0)
240 {
242 if (!mailInfo.Attachments.empty())
243 {
244 for (Item* item : items)
245 {
246 if (log)
247 {
248 sLog->OutCommand(GetAccountId(), "GM {} ({}) (Account: {}) mail item: {} (Entry: {} Count: {}) "
249 "to: {} ({}) (Account: {})", GetPlayerName(), _player->GetGUID().ToString(), GetAccountId(),
250 item->GetTemplate()->Name1, item->GetEntry(), item->GetCount(),
251 mailInfo.Target, receiverGuid.ToString(), receiverAccountId);
252 }
253
254 item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
255 player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
256
257 item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
258 item->SetOwnerGUID(receiverGuid);
259 item->SetState(ITEM_CHANGED);
260 item->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
261
262 draft.AddItem(item);
263 }
264
265 // if item send to character at another account, then apply item delivery delay
266 needItemDelay = GetAccountId() != receiverAccountId;
267 }
268
269 if (log && mailInfo.SendMoney > 0)
270 {
271 sLog->OutCommand(GetAccountId(), "GM {} ({}) (Account: {}) mail money: {} to: {} ({}) (Account: {})",
272 GetPlayerName(), _player->GetGUID().ToString(), GetAccountId(), mailInfo.SendMoney, mailInfo.Target, receiverGuid.ToString(), receiverAccountId);
273 }
274 }
275
276 // If theres is an item, there is a one hour delivery delay if sent to another account's character.
277 uint32 deliver_delay = needItemDelay ? sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
278
279 // don't ask for COD if there are no items
280 if (mailInfo.Attachments.empty())
281 mailInfo.Cod = 0;
282
283 // will delete item or place to receiver mail list
284 draft
285 .AddMoney(mailInfo.SendMoney)
286 .AddCOD(mailInfo.Cod)
287 .SendMailTo(trans, MailReceiver(ObjectAccessor::FindConnectedPlayer(receiverGuid), receiverGuid.GetCounter()), MailSender(player), mailInfo.Body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
288
289 player->SaveInventoryAndGoldToDB(trans);
290 CharacterDatabase.CommitTransaction(trans);
291 };
292
293 if (Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid))
294 {
295 mailCountCheckContinuation(receiver->GetTeam(), receiver->GetMailSize(), receiver->GetLevel(), receiver->GetSession()->GetAccountId());
296 }
297 else
298 {
300 stmt->setUInt32(0, receiverGuid.GetCounter());
301
303 .WithPreparedCallback([continuation = std::move(mailCountCheckContinuation), receiverGuid](PreparedQueryResult result) mutable
304 {
305 if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(receiverGuid))
306 continuation(Player::TeamForRace(characterInfo->Race), result ? (*result)[0].GetUInt64() : UI64LIT(0), characterInfo->Level, characterInfo->AccountId);
307 }));
308 }
309}
310
311//called when mail is read
313{
314 if (!CanOpenMailBox(markAsRead.Mailbox))
315 return;
316
317 Player* player = _player;
318 Mail* m = player->GetMail(markAsRead.MailID);
319 if (m && m->state != MAIL_STATE_DELETED)
320 {
321 if (player->unReadMails)
322 --player->unReadMails;
324 player->m_mailsUpdated = true;
326 }
327}
328
329//called when client deletes mail
331{
332 if (!CanOpenMailBox(mailDelete.Mailbox))
333 return;
334
335 Mail* m = _player->GetMail(mailDelete.MailID);
336 Player* player = _player;
337 player->m_mailsUpdated = true;
338 if (m)
339 {
340 // delete shouldn't show up for COD mails
341 if (m->COD)
342 {
344 return;
345 }
346
348 }
349 player->SendMailResult(mailDelete.MailID, MAIL_DELETED, MAIL_OK);
350}
351
353{
354 if (!CanOpenMailBox(returnToSender.Mailbox))
355 return;
356
357 Player* player = _player;
358 Mail* m = player->GetMail(returnToSender.MailID);
360 {
362 return;
363 }
364 //we can return mail now, so firstly delete the old one
365 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
366
368 stmt->setUInt32(0, returnToSender.MailID);
369 trans->Append(stmt);
370
371 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
372 stmt->setUInt32(0, returnToSender.MailID);
373 trans->Append(stmt);
374
375 player->RemoveMail(returnToSender.MailID);
376
377 // only return mail if the player exists (and delete if not existing)
378 if (m->messageType == MAIL_NORMAL && m->sender)
379 {
380 MailDraft draft(m->subject, m->body);
381 if (m->mailTemplateId)
382 draft = MailDraft(m->mailTemplateId, false); // items already included
383
384 if (m->HasItems())
385 {
386 for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
387 {
388 if (Item* item = player->GetMItem(itr2->item_guid))
389 draft.AddItem(item);
390 player->RemoveMItem(itr2->item_guid);
391 }
392 }
393 draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
394 }
395
396 CharacterDatabase.CommitTransaction(trans);
397
398 delete m; //we can deallocate old mail
399 player->SendMailResult(returnToSender.MailID, MAIL_RETURNED_TO_SENDER, MAIL_OK);
400}
401
402//called when player takes item attached in mail
404{
405 if (!CanOpenMailBox(takeItem.Mailbox))
406 return;
407
408 Player* player = _player;
409
410 Mail* m = player->GetMail(takeItem.MailID);
412 {
414 return;
415 }
416
417 // verify that the mail has the item to avoid cheaters taking COD items without paying
418 if (std::find_if(m->items.begin(), m->items.end(), [attachId = uint32(takeItem.AttachID)](MailItemInfo info){ return info.item_guid == attachId; }) == m->items.end())
419 {
421 return;
422 }
423
424 // prevent cheating with skip client money check
425 if (!player->HasEnoughMoney(m->COD))
426 {
428 return;
429 }
430
431 Item* it = player->GetMItem(takeItem.AttachID);
432
433 ItemPosCountVec dest;
434 uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
435 if (msg == EQUIP_ERR_OK)
436 {
437 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
438 m->RemoveItem(takeItem.AttachID);
439 m->removedItems.push_back(takeItem.AttachID);
440
441 if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
442 {
443 ObjectGuid sender_guid = ObjectGuid::Create<HighGuid::Player>(m->sender);
444 Player* receiver = ObjectAccessor::FindConnectedPlayer(sender_guid);
445
446 uint32 sender_accId = 0;
447
449 {
450 std::string sender_name;
451 if (receiver)
452 {
453 sender_accId = receiver->GetSession()->GetAccountId();
454 sender_name = receiver->GetName();
455 }
456 else
457 {
458 // can be calculated early
459 sender_accId = sCharacterCache->GetCharacterAccountIdByGuid(sender_guid);
460
461 if (!sCharacterCache->GetCharacterNameByGuid(sender_guid, sender_name))
462 sender_name = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
463 }
464 sLog->OutCommand(GetAccountId(), "GM {} (Account: {}) receiver mail item: {} (Entry: {} Count: {}) and send COD money: {} to player: {} (Account: {})",
465 GetPlayerName(), GetAccountId(), it->GetTemplate()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name, sender_accId);
466 }
467 else if (!receiver)
468 sender_accId = sCharacterCache->GetCharacterAccountIdByGuid(sender_guid);
469
470 // check player existence
471 if (receiver || sender_accId)
472 {
473 MailDraft(m->subject, "")
474 .AddMoney(m->COD)
476 }
477
478 player->ModifyMoney(-int32(m->COD));
479 }
480 m->COD = 0;
482 player->m_mailsUpdated = true;
483 player->RemoveMItem(it->GetGUID().GetCounter());
484
485 uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
486 it->SetState(ITEM_UNCHANGED); // need to set this state, otherwise item cannot be removed later, if neccessary
487 player->MoveItemToInventory(dest, it, true);
488
489 player->SaveInventoryAndGoldToDB(trans);
490 player->_SaveMail(trans);
491 CharacterDatabase.CommitTransaction(trans);
492
493 player->SendMailResult(takeItem.MailID, MAIL_ITEM_TAKEN, MAIL_OK, 0, takeItem.AttachID, count);
494 }
495 else
497}
498
500{
501 if (!CanOpenMailBox(takeMoney.Mailbox))
502 return;
503
504 Player* player = _player;
505
506 Mail* m = player->GetMail(takeMoney.MailID);
508 {
510 return;
511 }
512
513 if (!player->ModifyMoney(m->money, false))
514 {
516 return;
517 }
518
519 m->money = 0;
521 player->m_mailsUpdated = true;
522
523 player->SendMailResult(takeMoney.MailID, MAIL_MONEY_TAKEN, MAIL_OK);
524
525 // save money and mail to prevent cheating
526 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
527 player->SaveGoldToDB(trans);
528 player->_SaveMail(trans);
529 CharacterDatabase.CommitTransaction(trans);
530}
531
532//called when player lists his received mails
534{
535 if (!CanOpenMailBox(getList.Mailbox))
536 return;
537
538 Player* player = _player;
539
541 time_t curTime = GameTime::GetGameTime();
542
543 for (Mail* m : player->GetMails())
544 {
545 // skip deleted or not delivered (deliver delay not expired) mails
546 if (m->state == MAIL_STATE_DELETED || curTime < m->deliver_time)
547 continue;
548
549 response.AddMail(m, _player);
550 }
551
552 SendPacket(response.Write());
553
554 // recalculate m_nextMailDelivereTime and unReadMails
556}
557
558//used when player copies mail body to his inventory
560{
561 if (!CanOpenMailBox(createTextItem.Mailbox))
562 return;
563
564 Player* player = _player;
565
566 Mail* m = player->GetMail(createTextItem.MailID);
567 if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime() || (m->checked & MAIL_CHECK_MASK_COPIED))
568 {
570 return;
571 }
572
573 Item* bodyItem = new Item; // This is not bag and then can be used new Item.
574 if (!bodyItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), MAIL_BODY_ITEM_TEMPLATE, player))
575 {
576 delete bodyItem;
577 return;
578 }
579
580 // in mail template case we need create new item text
581 if (m->mailTemplateId)
582 {
583 MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId);
584 ASSERT(mailTemplateEntry);
585 bodyItem->SetText(mailTemplateEntry->Body[GetSessionDbcLocale()]);
586 }
587 else
588 bodyItem->SetText(m->body);
589
590 if (m->messageType == MAIL_NORMAL)
591 bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(m->sender));
592
594
595 TC_LOG_INFO("network", "HandleMailCreateTextItem mailid={}", createTextItem.MailID);
596
597 ItemPosCountVec dest;
598 uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, bodyItem, false);
599 if (msg == EQUIP_ERR_OK)
600 {
603 player->m_mailsUpdated = true;
604
605 player->StoreItem(dest, bodyItem, true);
606 player->SendMailResult(createTextItem.MailID, MAIL_MADE_PERMANENT, MAIL_OK);
607 }
608 else
609 {
610 player->SendMailResult(createTextItem.MailID, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg);
611 delete bodyItem;
612 }
613}
614
616{
618
619 if (_player->unReadMails > 0)
620 {
621 result.NextMailTime = 0.0f;
622
623 time_t now = GameTime::GetGameTime();
624 std::set<ObjectGuid::LowType> sentSenders;
625 for (Mail* m : _player->GetMails())
626 {
627 // must be not checked yet
628 if (m->checked & MAIL_CHECK_MASK_READ)
629 continue;
630
631 // and already delivered
632 if (now < m->deliver_time)
633 continue;
634
635 // only send each mail sender once
636 if (sentSenders.count(m->sender))
637 continue;
638
639 result.Next.emplace_back(m);
640
641 sentSenders.insert(m->sender);
642
643 // do not send more than 2 mails
644 if (sentSenders.size() > 2)
645 break;
646 }
647 }
648 else
649 result.NextMailTime = -DAY;
650
651 SendPacket(result.Write());
652}
#define sCharacterCache
@ CHAR_DEL_MAIL_BY_ID
@ CHAR_DEL_MAIL_ITEM_BY_ID
@ CHAR_SEL_MAIL_COUNT
@ DAY
Definition Common.h:31
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL
Definition DBCEnums.h:190
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint64_t uint64
Definition Define.h:132
uint32_t uint32
Definition Define.h:133
#define ASSERT
Definition Errors.h:68
@ EQUIP_ERR_TOO_MUCH_GOLD
@ EQUIP_ERR_MAIL_BOUND_ITEM
Definition ItemDefines.h:98
@ EQUIP_ERR_DESTROY_NONEMPTY_BAG
Definition ItemDefines.h:57
@ EQUIP_ERR_OK
Definition ItemDefines.h:26
@ EQUIP_ERR_NOT_SAME_ACCOUNT
@ ITEM_FLAG_MAIL_TEXT_MASK
@ ITEM_FLAG_IS_BOUND_TO_ACCOUNT
@ ITEM_FLAG_CONJURED
@ ITEM_CHANGED
Definition Item.h:54
@ ITEM_UNCHANGED
Definition Item.h:53
@ LANG_UNKNOWN
Definition Language.h:77
@ LANG_MAIL_RECEIVER_REQ
Definition Language.h:1169
@ LANG_MAIL_SENDER_REQ
Definition Language.h:1168
#define TC_LOG_WARN(filterType__,...)
Definition Log.h:162
#define sLog
Definition Log.h:130
#define TC_LOG_INFO(filterType__,...)
Definition Log.h:159
@ MAIL_CHECK_MASK_HAS_BODY
Definition Mail.h:51
@ MAIL_CHECK_MASK_READ
Definition Mail.h:47
@ MAIL_CHECK_MASK_COD_PAYMENT
This mail was copied. Do not allow making a copy of items in mail.
Definition Mail.h:50
@ MAIL_CHECK_MASK_COPIED
This mail was returned. Do not allow returning mail back again.
Definition Mail.h:49
@ MAIL_STATE_DELETED
Definition Mail.h:70
@ MAIL_STATE_CHANGED
Definition Mail.h:69
#define MAIL_BODY_ITEM_TEMPLATE
Definition Mail.h:32
@ MAIL_NORMAL
Definition Mail.h:37
bool normalizePlayerName(std::string &name)
#define sObjectMgr
Definition ObjectMgr.h:1721
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:624
@ GAMEOBJECT_TYPE_MAILBOX
@ MAIL_MONEY_TAKEN
@ MAIL_DELETED
@ MAIL_RETURNED_TO_SENDER
@ MAIL_MADE_PERMANENT
@ MAIL_ITEM_TAKEN
@ MAIL_SEND
@ MAIL_ERR_NOT_ENOUGH_MONEY
@ MAIL_ERR_NOT_YOUR_TEAM
@ MAIL_ERR_CANT_SEND_WRAPPED_COD
@ MAIL_ERR_RECIPIENT_CAP_REACHED
@ MAIL_ERR_EQUIP_ERROR
@ MAIL_ERR_RECIPIENT_NOT_FOUND
@ MAIL_OK
@ MAIL_ERR_MAIL_ATTACHMENT_INVALID
@ MAIL_ERR_INTERNAL_ERROR
@ MAIL_ERR_CANNOT_SEND_TO_SELF
@ UNIT_NPC_FLAG_MAILBOX
@ NULL_BAG
Definition Unit.h:61
@ NULL_SLOT
Definition Unit.h:62
@ ITEM_FIELD_DURATION
@ ITEM_FIELD_FLAGS
@ ITEM_FIELD_CREATOR
Definition Item.h:62
void SetState(ItemUpdateState state, Player *forplayer=nullptr)
Definition Item.cpp:638
bool IsWrapped() const
Definition Item.h:100
void SetText(std::string const &text)
Definition Item.h:153
bool IsBoundAccountWide() const
Definition Item.h:82
bool CanBeTraded(bool mail=false, bool trade=false) const
Definition Item.cpp:721
ItemTemplate const * GetTemplate() const
Definition Item.cpp:535
bool IsSoulBound() const
Definition Item.h:81
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemId, Player const *owner)
Definition Item.cpp:267
bool IsNotEmptyBag() const
Definition Item.cpp:298
uint32 GetCount() const
Definition Item.h:119
MailDraft & AddMoney(uint32 money)
Definition Mail.h:137
void SendMailTo(CharacterDatabaseTransaction trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0)
Definition Mail.cpp:188
MailDraft & AddCOD(uint32 COD)
Definition Mail.h:138
void SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, CharacterDatabaseTransaction trans)
Definition Mail.cpp:145
MailDraft & AddItem(Item *item)
Definition Mail.cpp:90
LowType GetCounter() const
Definition ObjectGuid.h:156
std::string ToString() const
bool IsGameObject() const
Definition ObjectGuid.h:182
bool IsAnyTypeCreature() const
Definition ObjectGuid.h:178
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:249
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:760
void SetGuidValue(uint16 index, ObjectGuid value)
Definition Object.cpp:699
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetTeam() const
Definition Player.h:1832
void UpdateNextMailTimeAndUnreads()
Definition Player.cpp:2821
void SaveGoldToDB(CharacterDatabaseTransaction trans) const
Definition Player.cpp:19317
Item * GetMItem(ObjectGuid::LowType id)
Definition Player.cpp:20572
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap=false) const
Definition Player.cpp:9994
void SaveInventoryAndGoldToDB(CharacterDatabaseTransaction trans)
Definition Player.cpp:19311
GameObject * GetGameObjectIfCanInteractWith(ObjectGuid const &guid) const
Definition Player.cpp:2138
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, WorldObject *ref=nullptr)
Definition Player.cpp:24940
bool ModifyMoney(int32 amount, bool sendError=true)
Definition Player.cpp:22339
uint8 unReadMails
Definition Player.h:1445
void RemoveMail(uint32 id)
Definition Player.cpp:2788
bool m_mailsUpdated
Definition Player.h:1397
Item * StoreItem(ItemPosCountVec const &pos, Item *pItem, bool update)
Definition Player.cpp:11661
WorldSession * GetSession() const
Definition Player.h:1719
PlayerMails const & GetMails() const
Definition Player.h:1437
bool HasEnoughMoney(uint32 amount) const
Definition Player.h:1410
void MoveItemFromInventory(uint8 bag, uint8 slot, bool update)
Definition Player.cpp:12068
Creature * GetNPCIfCanInteractWith(ObjectGuid const &guid, NPCFlags npcFlags) const
Definition Player.cpp:2094
void MoveItemToInventory(ItemPosCountVec const &dest, Item *pItem, bool update, bool in_characterInventoryDB=false)
Definition Player.cpp:12085
void _SaveMail(CharacterDatabaseTransaction trans)
Definition Player.cpp:19570
void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError=0, ObjectGuid::LowType item_guid=0, uint32 item_count=0) const
Definition Player.cpp:2801
bool RemoveMItem(ObjectGuid::LowType id)
Definition Player.cpp:20585
bool IsGameMaster() const
Definition Player.h:998
Item * GetItemByGuid(ObjectGuid guid) const
Definition Player.cpp:9518
Mail * GetMail(uint32 id)
Definition Player.cpp:3782
void setUInt32(uint8 index, uint32 value)
uint8 GetLevel() const
Definition Unit.h:889
std::string const & GetName() const
Definition Object.h:382
size_type size() const
WorldPacket const * Write() override
void AddMail(::Mail const *mail, Player *player)
WorldPacket const * Write() override
std::vector< MailNextTimeEntry > Next
char const * GetTrinityString(uint32 entry) const
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
void SendNotification(const char *format,...) ATTR_PRINTF(2
LocaleConstant GetSessionDbcLocale() const
std::string GetPlayerInfo() const
void HandleSendMail(WorldPackets::Mail::SendMail &sendMail)
Player * GetPlayer() const
bool CanOpenMailBox(ObjectGuid guid)
void HandleMailDelete(WorldPackets::Mail::MailDelete &mailDelete)
QueryCallbackProcessor & GetQueryProcessor()
void HandleMailTakeItem(WorldPackets::Mail::MailTakeItem &takeItem)
void HandleQueryNextMailTime(WorldPackets::Mail::MailQueryNextMailTime &queryNextMailTime)
void HandleMailMarkAsRead(WorldPackets::Mail::MailMarkAsRead &markAsRead)
bool HasPermission(uint32 permissionId)
void HandleMailReturnToSender(WorldPackets::Mail::MailReturnToSender &returnToSender)
uint32 GetAccountId() const
Player * _player
void HandleMailCreateTextItem(WorldPackets::Mail::MailCreateTextItem &createTextItem)
void HandleMailTakeMoney(WorldPackets::Mail::MailTakeMoney &takeMoney)
void HandleGetMailList(WorldPackets::Mail::MailGetList &getList)
std::string const & GetPlayerName() const
#define sWorld
Definition World.h:900
@ CONFIG_MAIL_LEVEL_REQ
Definition World.h:304
@ CONFIG_MAIL_DELIVERY_DELAY
Definition World.h:268
time_t GetGameTime()
Definition GameTime.cpp:42
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
@ RBAC_PERM_TWO_SIDE_INTERACTION_MAIL
Definition RBAC.h:80
@ RBAC_PERM_COMMAND_MAILBOX
Definition RBAC.h:647
@ RBAC_PERM_LOG_GM_TRADE
Definition RBAC.h:64
std::string Name1
bool HasFlag(ItemFlags flag) const
char const * Body[16]
Definition Mail.h:167
bool HasItems() const
Definition Mail.h:206
ObjectGuid::LowType receiver
Definition Mail.h:173
uint8 messageType
Definition Mail.h:169
ObjectGuid::LowType sender
Definition Mail.h:172
std::string subject
Definition Mail.h:174
std::vector< ObjectGuid::LowType > removedItems
Definition Mail.h:177
std::string body
Definition Mail.h:175
std::vector< MailItemInfo > items
Definition Mail.h:176
bool RemoveItem(ObjectGuid::LowType item_guid)
Definition Mail.h:193
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
String< 255, Strings::NoHyperlinks > Subject
String< 7999, Strings::NoHyperlinks > Body
Array< MailAttachment, MAX_MAIL_ITEMS > Attachments