Core/Packets:
- updated who packets - fixed typos from previous commits
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "QueryPackets.h"
|
||||
#include "BattlenetAccountMgr.h"
|
||||
#include "Player.h"
|
||||
#include "World.h"
|
||||
|
||||
void WorldPackets::Query::QueryCreature::Read()
|
||||
{
|
||||
@@ -103,31 +106,81 @@ void WorldPackets::Query::QueryPlayerName::Read()
|
||||
_worldPacket >> Hint.NativeRealmAddress.Value;
|
||||
}
|
||||
|
||||
bool WorldPackets::Query::PlayerGuidLookupData::Initialize(ObjectGuid const& guid, Player const* player /*= nullptr*/)
|
||||
{
|
||||
CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid);
|
||||
if (!characterInfo)
|
||||
return false;
|
||||
|
||||
if (player)
|
||||
{
|
||||
ASSERT(player->GetGUID() == guid);
|
||||
|
||||
AccountID = player->GetSession()->GetAccountGUID();
|
||||
BnetAccountID = player->GetSession()->GetBattlenetAccountGUID();
|
||||
Name = player->GetName();
|
||||
Race = player->getRace();
|
||||
Sex = player->getGender();
|
||||
ClassID = player->getClass();
|
||||
Level = player->getLevel();
|
||||
|
||||
if (DeclinedName const* names = player->GetDeclinedNames())
|
||||
DeclinedNames = *names;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 accountId = ObjectMgr::GetPlayerAccountIdByGUID(guid);
|
||||
uint32 bnetAccountId = Battlenet::AccountMgr::GetIdByGameAccount(accountId);
|
||||
|
||||
AccountID = ObjectGuid::Create<HighGuid::WowAccount>(accountId);
|
||||
BnetAccountID = ObjectGuid::Create<HighGuid::BNetAccount>(bnetAccountId);
|
||||
Name = characterInfo->Name;
|
||||
Race = characterInfo->Race;
|
||||
Sex = characterInfo->Sex;
|
||||
ClassID = characterInfo->Class;
|
||||
Level = characterInfo->Level;
|
||||
}
|
||||
|
||||
IsDeleted = characterInfo->IsDeleted;
|
||||
GuidActual = guid;
|
||||
VirtualRealmAddress = GetVirtualRealmAddress();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Query::PlayerGuidLookupData const& lookupData)
|
||||
{
|
||||
data.WriteBit(lookupData.IsDeleted);
|
||||
data.WriteBits(lookupData.Name.length(), 6);
|
||||
|
||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
data.WriteBits(lookupData.DeclinedNames.name[i].length(), 7);
|
||||
|
||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
data.WriteString(lookupData.DeclinedNames.name[i]);
|
||||
|
||||
data << lookupData.AccountID;
|
||||
data << lookupData.BnetAccountID;
|
||||
data << lookupData.GuidActual;
|
||||
data << uint32(lookupData.VirtualRealmAddress);
|
||||
data << uint8(lookupData.Race);
|
||||
data << uint8(lookupData.Sex);
|
||||
data << uint8(lookupData.ClassID);
|
||||
data << uint8(lookupData.Level);
|
||||
data.WriteString(lookupData.Name);
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Query::QueryPlayerNameResponse::Write()
|
||||
{
|
||||
_worldPacket << Result;
|
||||
_worldPacket << Player;
|
||||
|
||||
if (Result == RESPONSE_SUCCESS)
|
||||
{
|
||||
_worldPacket.WriteBits(Data.Name.length(), 7);
|
||||
|
||||
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
_worldPacket.WriteBits(Data.DeclinedNames.name[i].length(), 7);
|
||||
|
||||
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
_worldPacket.WriteString(Data.DeclinedNames.name[i]);
|
||||
|
||||
_worldPacket << Data.AccountID;
|
||||
_worldPacket << Data.BnetAccountID;
|
||||
_worldPacket << Data.GuidActual;
|
||||
_worldPacket << Data.VirtualRealmAddress;
|
||||
_worldPacket << Data.Race;
|
||||
_worldPacket << Data.Sex;
|
||||
_worldPacket << Data.ClassID;
|
||||
_worldPacket << Data.Level;
|
||||
_worldPacket.WriteString(Data.Name);
|
||||
}
|
||||
_worldPacket << Data;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user