Core/Packets: SMSG_NAME_QUERY_RESPONSE (PlayerNameResponse) handler

This commit is contained in:
DDuarte
2014-11-10 06:44:43 +00:00
parent ec7923c2e6
commit ec60d64498
5 changed files with 94 additions and 35 deletions

View File

@@ -36,37 +36,40 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid);
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data << guid.WriteAsPacked();
if (!nameData)
{
data << uint8(1); // name unknown
SendPacket(&data);
return;
}
WorldPackets::Character::PlayerNameResponse response;
response.Player = guid;
data << uint8(0); // name known
data << nameData->m_name; // played name
data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
data << uint8(nameData->m_race);
data << uint8(nameData->m_gender);
data << uint8(nameData->m_class);
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL))
if (nameData)
{
data << uint8(1); // Name is declined
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << names->name[i];
uint32 accountId = player ? player->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(guid);
uint32 bnetAccountId = player ? player->GetSession()->GetBattlenetAccountId() : Battlenet::AccountMgr::GetIdByGameAccount(accountId);
response.Result = 0; // name known
response.Data.IsDeleted = false; // TODO: send deletes as well
response.Data.AccountID = ObjectGuid::Create<HighGuid::WowAccount>(accountId);
response.Data.BnetAccountID = ObjectGuid::Create<HighGuid::BNetAccount>(bnetAccountId);
response.Data.Name = nameData->m_name;
response.Data.VirtualRealmAddress = GetVirtualRealmAddress();
response.Data.Race = nameData->m_race;
response.Data.Sex = nameData->m_gender;
response.Data.ClassID = nameData->m_class;
response.Data.Level = nameData->m_level;
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : nullptr))
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
response.Data.DeclinedNames.name[i] = names[i];
}
else
data << uint8(0); // Name is not declined
{
response.Result = 1; // name unknown
}
SendPacket(&data);
SendPacket(response.Write());
}
void WorldSession::HandleNameQueryOpcode(WorldPackets::Character::QueryPlayerName& queryPlayerName)
void WorldSession::HandleNameQueryOpcode(WorldPackets::Character::QueryPlayerName& packet)
{
SendNameQueryOpcode(queryPlayerName.Player);
SendNameQueryOpcode(packet.Player);
}
void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recvData*/)