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*/)

View File

@@ -317,3 +317,32 @@ void WorldPackets::Character::QueryPlayerName::Read()
if (Hint.NativeRealmAddress.HasValue)
_worldPacket >> Hint.NativeRealmAddress;
}
WorldPacket const* WorldPackets::Character::PlayerNameResponse::Write()
{
_worldPacket << Result;
_worldPacket << Player;
if (Result == 0)
{
_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);
}
return &_worldPacket;
}

View File

@@ -25,18 +25,12 @@ namespace WorldPackets
{
namespace Character
{
struct PlayerGuidLookupHint
{
public Optional<uint32> VirtualRealmAddress; ///< current realm (?) (identifier made from the Index, BattleGroup and Region)
public Optional<uint32> NativeRealmAddress; ///< original realm (?) (identifier made from the Index, BattleGroup and Region)
};
struct CharacterCreateInfo
{
/// User specified variables
uint8 Race = 0;
uint8 Class = 0;
uint8 Sex = GENDER_NONE;
uint8 Race = RACE_NONE;
uint8 Class = CLASS_NONE;
uint8 Sex = GENDER_NONE;
uint8 Skin = 0;
uint8 Face = 0;
uint8 HairStyle = 0;
@@ -68,7 +62,7 @@ namespace WorldPackets
struct CharacterFactionChangeInfo : public CharacterCustomizeInfo
{
uint8 Race = 0;
uint8 Race = RACE_NONE;
};
struct CharacterUndeleteInfo
@@ -367,6 +361,27 @@ namespace WorldPackets
bool Showing = false;
};
struct PlayerGuidLookupHint
{
Optional<uint32> VirtualRealmAddress; ///< current realm (?) (identifier made from the Index, BattleGroup and Region)
Optional<uint32> NativeRealmAddress; ///< original realm (?) (identifier made from the Index, BattleGroup and Region)
};
struct PlayerGuidLookupData
{
bool IsDeleted = false;
ObjectGuid AccountID;
ObjectGuid BnetAccountID;
ObjectGuid GuidActual;
std::string Name;
uint32 VirtualRealmAddress = 0;
uint8 Race = RACE_NONE;
uint8 Sex = GENDER_NONE;
uint8 ClassID = CLASS_NONE;
uint8 Level = 0;
DeclinedName DeclinedNames;
};
class QueryPlayerName final : public ClientPacket
{
public:
@@ -377,6 +392,18 @@ namespace WorldPackets
ObjectGuid Player;
PlayerGuidLookupHint Hint;
};
class PlayerNameResponse final : public ServerPacket
{
public:
PlayerNameResponse() : ServerPacket(SMSG_NAME_QUERY_RESPONSE, 60) { }
WorldPacket const* Write() override;
ObjectGuid Player;
uint8 Result = -1; // 0 - full packet, != 0 - only guid
PlayerGuidLookupData Data;
};
}
}

View File

@@ -1112,7 +1112,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_UPDATE_WALK_SPEED, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_WATER_WALK, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MULTIPLE_PACKETS, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_NAME_QUERY_RESPONSE, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_NAME_QUERY_RESPONSE, STATUS_NEVER);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_NEW_TAXI_PATH, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_NEW_WORLD, STATUS_UNHANDLED);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_NEW_WORLD_ABORT, STATUS_UNHANDLED);

View File

@@ -569,7 +569,7 @@ class WorldSession
void HandleMeetingStoneInfo(WorldPacket& recPacket);
void HandleGameobjectReportUse(WorldPacket& recvPacket);
void HandleNameQueryOpcode(WorldPackets::Character::QueryPlayerName& queryPlayerName);
void HandleNameQueryOpcode(WorldPackets::Character::QueryPlayerName& packet);
void HandleQueryTimeOpcode(WorldPacket& recvPacket);