aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/MailHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/MailHandler.cpp')
-rw-r--r--src/server/game/Handlers/MailHandler.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp
index 10ef7810d1d..1270f4e6419 100644
--- a/src/server/game/Handlers/MailHandler.cpp
+++ b/src/server/game/Handlers/MailHandler.cpp
@@ -131,6 +131,13 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
uint32 reqmoney = cost + money;
+ // Check for overflow
+ if (reqmoney < money)
+ {
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
+ return;
+ }
+
if (!player->HasEnoughMoney(reqmoney) && !player->IsGameMaster())
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
@@ -315,6 +322,10 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
// If theres is an item, there is a one hour delivery delay if sent to another account's character.
uint32 deliver_delay = needItemDelay ? sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
+ // don't ask for COD if there are no items
+ if (items_count == 0)
+ COD = 0;
+
// will delete item or place to receiver mail list
draft
.AddMoney(money)
@@ -338,7 +349,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
- if (m)
+ if (m && m->state != MAIL_STATE_DELETED)
{
if (player->unReadMails)
--player->unReadMails;
@@ -462,6 +473,13 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
return;
}
+ // verify that the mail has the item to avoid cheaters taking COD items without paying
+ if (std::find_if(m->items.begin(), m->items.end(), [itemId](MailItemInfo info){ return info.item_guid == itemId; }) == m->items.end())
+ {
+ player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
+ return;
+ }
+
// prevent cheating with skip client money check
if (!player->HasEnoughMoney(m->COD))
{
@@ -710,7 +728,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
- if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
+ if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL) || (m->checked & MAIL_CHECK_MASK_COPIED))
{
player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
return;