aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/MailHandler.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
committerShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
commita0e50ea35fca61447bf07fc45d93c98234ba59f7 (patch)
treeb4ee69a63866f42e466a3c03fc031ce0710ac762 /src/server/game/Handlers/MailHandler.cpp
parentce67a097bf3c0c3241f4441a808e32639ddbaafb (diff)
Core/Entities: Use ObjectGuid class in game project
Diffstat (limited to 'src/server/game/Handlers/MailHandler.cpp')
-rw-r--r--src/server/game/Handlers/MailHandler.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp
index 1270f4e6419..6ea3ae69786 100644
--- a/src/server/game/Handlers/MailHandler.cpp
+++ b/src/server/game/Handlers/MailHandler.cpp
@@ -29,7 +29,7 @@
#include "Item.h"
#include "AccountMgr.h"
-bool WorldSession::CanOpenMailBox(uint64 guid)
+bool WorldSession::CanOpenMailBox(ObjectGuid guid)
{
if (guid == _player->GetGUID())
{
@@ -39,12 +39,12 @@ bool WorldSession::CanOpenMailBox(uint64 guid)
return false;
}
}
- else if (IS_GAMEOBJECT_GUID(guid))
+ else if (guid.IsGameObject())
{
if (!_player->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX))
return false;
}
- else if (IS_CRE_OR_VEH_OR_PET_GUID(guid))
+ else if (guid.IsAnyTypeCreature())
{
if (!_player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_MAILBOX))
return false;
@@ -57,14 +57,14 @@ bool WorldSession::CanOpenMailBox(uint64 guid)
void WorldSession::HandleSendMail(WorldPacket& recvData)
{
- uint64 mailbox, unk3;
+ ObjectGuid mailbox, unk3;
std::string receiverName, subject, body;
- uint32 unk1, unk2, money, COD;
+ uint32 stationery, package, money, COD;
uint8 unk4;
uint8 items_count;
recvData >> mailbox >> receiverName >> subject >> body
- >> unk1 // stationery?
- >> unk2 // 0x00000000
+ >> stationery // stationery?
+ >> package // 0x00000000
>> items_count; // attached items count
if (items_count > MAX_MAIL_ITEMS) // client limit
@@ -74,7 +74,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
return;
}
- uint64 itemGUIDs[MAX_MAIL_ITEMS];
+ ObjectGuid itemGUIDs[MAX_MAIL_ITEMS];
for (uint8 i = 0; i < items_count; ++i)
{
@@ -102,7 +102,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
return;
}
- uint64 receiverGuid = 0;
+ ObjectGuid receiverGuid;
if (normalizePlayerName(receiverName))
receiverGuid = sObjectMgr->GetPlayerGUIDByName(receiverName);
@@ -111,15 +111,15 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
TC_LOG_INFO("network", "Player %u is sending mail to %s (GUID: not existed!) with subject %s "
"and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
player->GetGUIDLow(), receiverName.c_str(), subject.c_str(), body.c_str(),
- items_count, money, COD, unk1, unk2);
+ items_count, money, COD, stationery, package);
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return;
}
- TC_LOG_INFO("network", "Player %u is sending mail to %s (GUID: %u) with subject %s and body %s "
+ TC_LOG_INFO("network", "Player %u is sending mail to %s (%s) with subject %s and body %s "
"includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
- player->GetGUIDLow(), receiverName.c_str(), GUID_LOPART(receiverGuid), subject.c_str(),
- body.c_str(), items_count, money, COD, unk1, unk2);
+ player->GetGUIDLow(), receiverName.c_str(), receiverGuid.ToString().c_str(), subject.c_str(),
+ body.c_str(), items_count, money, COD, stationery, package);
if (player->GetGUID() == receiverGuid)
{
@@ -163,7 +163,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
receiverTeam = sObjectMgr->GetPlayerTeamByGUID(receiverGuid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT);
- stmt->setUInt32(0, GUID_LOPART(receiverGuid));
+ stmt->setUInt32(0, receiverGuid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
@@ -173,7 +173,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_LEVEL);
- stmt->setUInt32(0, GUID_LOPART(receiverGuid));
+ stmt->setUInt32(0, receiverGuid.GetCounter());
result = CharacterDatabase.Query(stmt);
if (result)
@@ -293,9 +293,9 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (log)
{
sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail item: %s (Entry: %u Count: %u) "
- "to player: %s (GUID: %u) (Account: %u)", GetPlayerName().c_str(), GetGuidLow(), GetAccountId(),
+ "to: %s (%s) (Account: %u)", GetPlayerName().c_str(), GetGuidLow(), GetAccountId(),
item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount(),
- receiverName.c_str(), GUID_LOPART(receiverGuid), receiverAccountId);
+ receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
@@ -314,8 +314,8 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (log && money > 0)
{
- sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail money: %u to player: %s (GUID: %u) (Account: %u)",
- GetPlayerName().c_str(), GetGuidLow(), GetAccountId(), money, receiverName.c_str(), GUID_LOPART(receiverGuid), receiverAccountId);
+ sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail money: %u to: %s (%s) (Account: %u)",
+ GetPlayerName().c_str(), GetGuidLow(), GetAccountId(), money, receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
}
@@ -330,7 +330,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
draft
.AddMoney(money)
.AddCOD(COD)
- .SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
+ .SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
@@ -339,7 +339,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
//called when mail is read
void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
recvData >> mailbox;
recvData >> mailId;
@@ -362,7 +362,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData)
//called when client deletes mail
void WorldSession::HandleMailDelete(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
recvData >> mailbox;
recvData >> mailId;
@@ -390,7 +390,7 @@ void WorldSession::HandleMailDelete(WorldPacket& recvData)
void WorldSession::HandleMailReturnToSender(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
recvData >> mailbox;
recvData >> mailId;
@@ -454,7 +454,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recvData)
//called when player takes item attached in mail
void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
uint32 itemId;
recvData >> mailbox;
@@ -499,7 +499,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
{
- uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
+ ObjectGuid sender_guid(HIGHGUID_PLAYER, m->sender);
Player* receiver = ObjectAccessor::FindPlayer(sender_guid);
uint32 sender_accId = 0;
@@ -557,7 +557,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
void WorldSession::HandleMailTakeMoney(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
recvData >> mailbox;
recvData >> mailId;
@@ -596,7 +596,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recvData)
//called when player lists his received mails
void WorldSession::HandleGetMailList(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
recvData >> mailbox;
if (!CanOpenMailBox(mailbox))
@@ -649,7 +649,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData)
switch ((*itr)->messageType)
{
case MAIL_NORMAL: // sender guid
- data << uint64(MAKE_NEW_GUID((*itr)->sender, 0, HIGHGUID_PLAYER));
+ data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender);
break;
case MAIL_CREATURE:
case MAIL_GAMEOBJECT:
@@ -716,7 +716,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData)
//used when player copies mail body to his inventory
void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData)
{
- uint64 mailbox;
+ ObjectGuid mailbox;
uint32 mailId;
recvData >> mailbox;
@@ -756,7 +756,9 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData)
else
bodyItem->SetText(m->body);
- bodyItem->SetUInt32Value(ITEM_FIELD_CREATOR, m->sender);
+ if (m->messageType == MAIL_NORMAL)
+ bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HIGHGUID_PLAYER, m->sender));
+
bodyItem->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_MAIL_TEXT_MASK);
TC_LOG_INFO("network", "HandleMailCreateTextItem mailid=%u", mailId);
@@ -810,7 +812,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recvData*/)
if (sentSenders.count(m->sender))
continue;
- data << uint64(m->messageType == MAIL_NORMAL ? m->sender : 0); // player guid
+ data << uint64(m->messageType == MAIL_NORMAL ? ObjectGuid(HIGHGUID_PLAYER, m->sender) : ObjectGuid::Empty); // player guid
data << uint32(m->messageType != MAIL_NORMAL ? m->sender : 0); // non-player entries
data << uint32(m->messageType);
data << uint32(m->stationery);