feat(Core/Mail): call CanSendMail() when returning to sender (#15553)

This commit is contained in:
Axel Cocat
2023-03-23 22:56:48 +01:00
committed by GitHub
parent c7fbf89e96
commit 5e9b88a9a9

View File

@@ -415,6 +415,25 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recvData)
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
if (m->HasItems())
{
for (MailItemInfoVec::iterator itr = m->items.begin(); itr != m->items.end(); ++itr)
{
Item* item = player->GetMItem(itr->item_guid);
if (item && !sScriptMgr->CanSendMail(player, ObjectGuid(HighGuid::Player, m->sender), mailbox, m->subject, m->body, m->money, m->COD, item))
{
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
}
}
else if (!sScriptMgr->CanSendMail(player, ObjectGuid(HighGuid::Player, m->sender), mailbox, m->subject, m->body, m->money, m->COD, nullptr))
{
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
//we can return mail now
//so firstly delete the old one
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();