|
35 | 35 |
|
36 | 36 | void WorldSession::SendNameQueryOpcode(ObjectGuid guid) |
37 | 37 | { |
38 | | - Player* player = ObjectAccessor::FindConnectedPlayer(guid); |
39 | | - CharacterCacheEntry const* nameData = sCharacterCache->GetCharacterCacheByGuid(guid); |
| 38 | + WorldPackets::Query::QueryPlayerNameResponse response; |
| 39 | + response.Player = guid; |
40 | 40 |
|
41 | | - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10)); |
42 | | - data << guid.WriteAsPacked(); |
43 | | - if (!nameData) |
| 41 | + if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(guid)) |
44 | 42 | { |
45 | | - data << uint8(1); // name unknown |
46 | | - SendPacket(&data); |
47 | | - return; |
48 | | - } |
| 43 | + response.Result = RESPONSE_SUCCESS; // name known |
49 | 44 |
|
50 | | - data << uint8(0); // name known |
51 | | - data << nameData->Name; // played name |
52 | | - data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds) |
53 | | - data << uint8(nameData->Race); |
54 | | - data << uint8(nameData->Sex); |
55 | | - data << uint8(nameData->Class); |
| 45 | + WorldPackets::Query::PlayerGuidLookupData& data = response.Data.emplace(); |
| 46 | + data.Name = characterInfo->Name; |
| 47 | + data.Race = characterInfo->Race; |
| 48 | + data.Sex = characterInfo->Sex; |
| 49 | + data.ClassID = characterInfo->Class; |
56 | 50 |
|
57 | | - if (DeclinedName const* names = (player ? player->GetDeclinedNames() : nullptr)) |
58 | | - { |
59 | | - data << uint8(1); // Name is declined |
60 | | - for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) |
61 | | - data << names->name[i]; |
| 51 | + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) |
| 52 | + data.DeclinedNames = player->GetDeclinedNames(); |
62 | 53 | } |
63 | 54 | else |
64 | | - data << uint8(0); // Name is not declined |
| 55 | + response.Result = RESPONSE_FAILURE; // name unknown |
65 | 56 |
|
66 | | - SendPacket(&data); |
| 57 | + SendPacket(response.Write()); |
67 | 58 | } |
68 | 59 |
|
69 | 60 | void WorldSession::HandleNameQueryOpcode(WorldPackets::Query::QueryPlayerName& queryPlayerName) |
|
0 commit comments