diff options
author | et65 <et65@ashbringer.fr> | 2014-12-28 19:50:19 +0100 |
---|---|---|
committer | et65 <et65@ashbringer.fr> | 2014-12-28 19:50:19 +0100 |
commit | e46921748d9173f0dcaa32f8a53626c21cf4a2a2 (patch) | |
tree | e9467c092c4c9189b34ac10e95bc684c7d77ce3e /src/server/game/Handlers/QueryHandler.cpp | |
parent | 4f557347ce26dcb3d7ce697ecd203ff92da5198a (diff) | |
parent | 27137ca06e99209bd1a47a0ff7082ff14fcae8c9 (diff) |
Merge remote-tracking branch 'trinitycore/6.x' into 6.x
Diffstat (limited to 'src/server/game/Handlers/QueryHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/QueryHandler.cpp | 77 |
1 files changed, 28 insertions, 49 deletions
diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 4beddd757da..6cd8acf08dd 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -132,60 +132,39 @@ void WorldSession::HandleCreatureQuery(WorldPackets::Query::QueryCreature& packe } /// Only _static_ data is sent in this packet !!! -void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recvData) +void WorldSession::HandleGameObjectQueryOpcode(WorldPackets::Query::QueryGameObject& packet) { - uint32 entry; - recvData >> entry; - ObjectGuid guid; - recvData >> guid; + WorldPackets::Query::QueryGameObjectResponse response; + GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.Entry); - const GameObjectTemplate* info = sObjectMgr->GetGameObjectTemplate(entry); - if (info) - { - std::string Name; - std::string IconName; - std::string CastBarCaption; - - Name = info->name; - IconName = info->IconName; - CastBarCaption = info->castBarCaption; + response.Entry = packet.Entry; - int loc_idx = GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - if (GameObjectLocale const* gl = sObjectMgr->GetGameObjectLocale(entry)) - { - ObjectMgr::GetLocaleString(gl->Name, loc_idx, Name); - ObjectMgr::GetLocaleString(gl->CastBarCaption, loc_idx, CastBarCaption); - } - } - TC_LOG_DEBUG("network", "WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name.c_str(), entry); - WorldPacket data (SMSG_GAMEOBJECT_QUERY_RESPONSE, 150); - data << uint32(entry); - data << uint32(info->type); - data << uint32(info->displayId); - data << Name; - data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 - data << IconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword) - data << CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting") - data << info->unk1; // 2.0.3, string - data.append(info->raw.data, MAX_GAMEOBJECT_DATA); - data << float(info->size); // go size - for (uint32 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) - data << uint32(info->questItems[i]); // itemId[6], quest drop - data << int32(info->unkInt32); // 4.x, unknown - SendPacket(&data); - TC_LOG_DEBUG("network", "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE"); - } - else + if (gameObjectInfo) { - TC_LOG_DEBUG("network", "WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (%s, ENTRY: %u)", - guid.ToString().c_str(), entry); - WorldPacket data (SMSG_GAMEOBJECT_QUERY_RESPONSE, 4); - data << uint32(entry | 0x80000000); - SendPacket(&data); - TC_LOG_DEBUG("network", "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE"); + response.Allow = true; + WorldPackets::Query::GameObjectStats& stats = response.Stats; + + stats.CastBarCaption = gameObjectInfo->castBarCaption; + stats.DisplayID = gameObjectInfo->displayId; + stats.IconName = gameObjectInfo->IconName; + stats.Name[0] = gameObjectInfo->name; + + for (uint8 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; i++) + if (gameObjectInfo->questItems[i]) + stats.QuestItems.push_back(gameObjectInfo->questItems[i]); + for (uint32 i = 0; i < MAX_GAMEOBJECT_DATA; i++) + stats.Data[i] = gameObjectInfo->raw.data[i]; + + stats.Size = gameObjectInfo->size; + stats.Type = gameObjectInfo->type; + stats.UnkString = gameObjectInfo->unk1; + stats.UnkInt32 = gameObjectInfo->unkInt32; + stats.Expansion = 0; } + else + response.Allow = false; + + SendPacket(response.Write()); } void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/) |