mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11560] Implement .mailbox command
Work semilar .bank for mailbox case.
This commit is contained in:
parent
e3463dca0d
commit
598c843548
10 changed files with 61 additions and 11 deletions
|
|
@ -36,6 +36,32 @@
|
|||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Chat.h"
|
||||
|
||||
bool WorldSession::CheckMailBox(ObjectGuid guid)
|
||||
{
|
||||
// GM case
|
||||
if (guid == GetPlayer()->GetObjectGuid())
|
||||
{
|
||||
// command case will return only if player have real access to command
|
||||
if (!ChatHandler(GetPlayer()).FindCommand("mailbox"))
|
||||
{
|
||||
DEBUG_LOG("%s attempt open mailbox in cheating way.", guid.GetString().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// mailbox case
|
||||
else
|
||||
{
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
{
|
||||
DEBUG_LOG("Mailbox %s not found or you can't interact with him.", guid.GetString().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the Packet sent by the client when sending a mail.
|
||||
|
|
@ -95,7 +121,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
|
||||
// packet read complete, now do check
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
if (receiver.empty())
|
||||
|
|
@ -295,7 +321,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
|
|||
recv_data >> mailboxGuid;
|
||||
recv_data >> mailId;
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player *pl = _player;
|
||||
|
|
@ -326,7 +352,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data )
|
|||
recv_data >> mailId;
|
||||
recv_data.read_skip<uint32>(); // mailTemplateId
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player* pl = _player;
|
||||
|
|
@ -362,7 +388,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
|
|||
recv_data >> mailId;
|
||||
recv_data.read_skip<uint64>(); // original sender GUID for return to, not used
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player *pl = _player;
|
||||
|
|
@ -421,7 +447,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
recv_data >> mailId;
|
||||
recv_data >> itemId; // item guid low
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player* pl = _player;
|
||||
|
|
@ -516,7 +542,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
|
|||
recv_data >> mailboxGuid;
|
||||
recv_data >> mailId;
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player *pl = _player;
|
||||
|
|
@ -551,7 +577,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
|
|||
ObjectGuid mailboxGuid;
|
||||
recv_data >> mailboxGuid;
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
// client can't work with packets > max int16 value
|
||||
|
|
@ -680,7 +706,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
|
|||
recv_data >> mailboxGuid;
|
||||
recv_data >> mailId;
|
||||
|
||||
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX))
|
||||
if (!CheckMailBox(mailboxGuid))
|
||||
return;
|
||||
|
||||
Player *pl = _player;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue