mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Core/Mail: Implemented sending battle.net account bound items
This commit is contained in:
@@ -73,6 +73,16 @@ uint32 Battlenet::AccountMgr::GetId(std::string const& username)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Battlenet::AccountMgr::GetIdByGameAccount(uint32 gameAccountId)
|
||||
{
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT);
|
||||
stmt->setUInt32(0, gameAccountId);
|
||||
if (PreparedQueryResult result = LoginDatabase.Query(stmt))
|
||||
return (*result)[0].GetUInt32();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Battlenet::AccountMgr::GetName(uint32 accountId, std::string& name)
|
||||
{
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_EMAIL_BY_ID);
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Battlenet
|
||||
|
||||
uint32 GetId(std::string const& username);
|
||||
bool GetName(uint32 accountId, std::string& name);
|
||||
uint32 GetIdByGameAccount(uint32 gameAccountId);
|
||||
|
||||
std::string CalculateShaPassHash(std::string const& name, std::string const& password);
|
||||
bool GetAccountIdAndIndex(std::string const& account, uint32* battlenetAccountId, uint8* battlenetAccountIndex);
|
||||
|
||||
@@ -231,6 +231,7 @@ class Item : public Object
|
||||
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, val); }
|
||||
bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND); }
|
||||
bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT) != 0; }
|
||||
bool IsBattlenetAccountBound() const { return GetTemplate()->Flags2 & ITEM_FLAGS_EXTRA_BNET_ACCOUNT_BOUND; }
|
||||
bool IsBindedNotWith(Player const* player) const;
|
||||
bool IsBoundByEnchant() const;
|
||||
virtual void SaveToDB(SQLTransaction& trans);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "DBCStores.h"
|
||||
#include "Item.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "BattlenetAccountMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
bool WorldSession::CanOpenMailBox(uint64 guid)
|
||||
@@ -192,6 +193,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
uint8 mailsCount = 0; //do not allow to send to one player more than 100 mails
|
||||
uint8 receiverLevel = 0;
|
||||
uint32 receiverAccountId = 0;
|
||||
uint32 receiverBnetAccountId = 0;
|
||||
|
||||
if (receiver)
|
||||
{
|
||||
@@ -199,6 +201,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
mailsCount = receiver->GetMailSize();
|
||||
receiverLevel = receiver->getLevel();
|
||||
receiverAccountId = receiver->GetSession()->GetAccountId();
|
||||
receiverBnetAccountId = receiver->GetSession()->GetBattlenetAccountId();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,6 +228,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
receiverAccountId = sObjectMgr->GetPlayerAccountIdByGUID(receiverGuid);
|
||||
receiverBnetAccountId = Battlenet::AccountMgr::GetIdByGameAccount(receiverAccountId);
|
||||
}
|
||||
|
||||
// do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
|
||||
@@ -288,8 +292,11 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
|
||||
if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != receiverAccountId)
|
||||
{
|
||||
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_NOT_SAME_ACCOUNT);
|
||||
return;
|
||||
if (!item->IsBattlenetAccountBound() || !player->GetSession()->GetBattlenetAccountId() || player->GetSession()->GetBattlenetAccountId() != receiverBnetAccountId)
|
||||
{
|
||||
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_NOT_SAME_ACCOUNT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
|
||||
|
||||
@@ -246,7 +246,7 @@ class WorldSession
|
||||
|
||||
AccountTypes GetSecurity() const { return _security; }
|
||||
uint32 GetAccountId() const { return _accountId; }
|
||||
uint32 GetBattlenetAccountId() const { return _accountId; }
|
||||
uint32 GetBattlenetAccountId() const { return _battlenetAccountId; }
|
||||
Player* GetPlayer() const { return _player; }
|
||||
std::string const& GetPlayerName() const;
|
||||
std::string GetPlayerInfo() const;
|
||||
|
||||
Reference in New Issue
Block a user