mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/PacketIO: Updated query opcodes
This commit is contained in:
@@ -58,7 +58,6 @@ void WorldSession::SendQueryTimeResponse()
|
||||
{
|
||||
WorldPackets::Query::QueryTimeResponse queryTimeResponse;
|
||||
queryTimeResponse.CurrentTime = time(nullptr);
|
||||
queryTimeResponse.TimeOutRequest = sWorld->GetNextDailyQuestsResetTime() - queryTimeResponse.CurrentTime;
|
||||
SendPacket(queryTimeResponse.Write());
|
||||
}
|
||||
|
||||
@@ -129,7 +128,6 @@ void WorldSession::HandleCreatureQuery(WorldPackets::Query::QueryCreature& packe
|
||||
void WorldSession::HandleGameObjectQueryOpcode(WorldPackets::Query::QueryGameObject& packet)
|
||||
{
|
||||
WorldPackets::Query::QueryGameObjectResponse response;
|
||||
|
||||
response.GameObjectID = packet.GameObjectID;
|
||||
|
||||
if (GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.GameObjectID))
|
||||
@@ -157,19 +155,20 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPackets::Query::QueryGameObj
|
||||
stats.Size = gameObjectInfo->size;
|
||||
|
||||
if (GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(packet.GameObjectID))
|
||||
for (uint32 item : *items)
|
||||
for (int32 item : *items)
|
||||
stats.QuestItems.push_back(item);
|
||||
|
||||
for (uint32 i = 0; i < MAX_GAMEOBJECT_DATA; i++)
|
||||
stats.Data[i] = gameObjectInfo->raw.data[i];
|
||||
memcpy(stats.Data, gameObjectInfo->raw.data, MAX_GAMEOBJECT_DATA * sizeof(int32));
|
||||
stats.Expansion = gameObjectInfo->unkInt32;
|
||||
}
|
||||
|
||||
SendPacket(response.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLocationFromClient& /*packet*/)
|
||||
void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLocationFromClient& queryCorpseLocation)
|
||||
{
|
||||
if (!_player->HasCorpse())
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(queryCorpseLocation.Player);
|
||||
if (!player || !player->HasCorpse() || !_player->IsInSameRaidWith(player))
|
||||
{
|
||||
WorldPackets::Query::CorpseLocation packet;
|
||||
packet.Valid = false; // corpse not found
|
||||
@@ -177,7 +176,7 @@ void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLoc
|
||||
return;
|
||||
}
|
||||
|
||||
WorldLocation corpseLocation = _player->GetCorpseLocation();
|
||||
WorldLocation corpseLocation = player->GetCorpseLocation();
|
||||
uint32 corpseMapID = corpseLocation.GetMapId();
|
||||
uint32 mapID = corpseLocation.GetMapId();
|
||||
float x = corpseLocation.GetPositionX();
|
||||
@@ -185,7 +184,7 @@ void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLoc
|
||||
float z = corpseLocation.GetPositionZ();
|
||||
|
||||
// if corpse at different map
|
||||
if (mapID != _player->GetMapId())
|
||||
if (mapID != player->GetMapId())
|
||||
{
|
||||
// search entrance map for proper show entrance
|
||||
if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapID))
|
||||
@@ -198,7 +197,7 @@ void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLoc
|
||||
mapID = corpseMapEntry->CorpseMapID;
|
||||
x = corpseMapEntry->CorpsePos.X;
|
||||
y = corpseMapEntry->CorpsePos.Y;
|
||||
z = entranceMap->GetHeight(GetPlayer()->GetPhaseMask(), x, y, MAX_HEIGHT);
|
||||
z = entranceMap->GetHeight(player->GetPhaseMask(), x, y, MAX_HEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,6 +205,7 @@ void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLoc
|
||||
|
||||
WorldPackets::Query::CorpseLocation packet;
|
||||
packet.Valid = true;
|
||||
packet.Player = queryCorpseLocation.Player;
|
||||
packet.MapID = corpseMapID;
|
||||
packet.ActualMapID = mapID;
|
||||
packet.Position = G3D::Vector3(x, y, z);
|
||||
@@ -244,55 +244,49 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPackets::Query::QueryNPCText& p
|
||||
/// Only _static_ data is sent in this packet !!!
|
||||
void WorldSession::HandleQueryPageText(WorldPackets::Query::QueryPageText& packet)
|
||||
{
|
||||
uint32 pageID = packet.PageTextID;
|
||||
WorldPackets::Query::QueryPageTextResponse response;
|
||||
response.PageTextID = packet.PageTextID;
|
||||
|
||||
uint32 pageID = packet.PageTextID;
|
||||
while (pageID)
|
||||
{
|
||||
PageText const* pageText = sObjectMgr->GetPageText(pageID);
|
||||
|
||||
WorldPackets::Query::QueryPageTextResponse response;
|
||||
response.PageTextID = pageID;
|
||||
|
||||
if (!pageText)
|
||||
{
|
||||
response.Allow = false;
|
||||
pageID = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
response.Allow = true;
|
||||
response.Info.ID = pageID;
|
||||
response.Info.NextPageID = pageText->NextPageID;
|
||||
response.Info.Text = pageText->Text;
|
||||
break;
|
||||
|
||||
LocaleConstant localeConstant = GetSessionDbLocaleIndex();
|
||||
if (localeConstant >= LOCALE_enUS)
|
||||
if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID))
|
||||
ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, response.Info.Text);
|
||||
WorldPackets::Query::QueryPageTextResponse::PageTextInfo page;
|
||||
page.ID = pageID;
|
||||
page.NextPageID = pageText->NextPageID;
|
||||
page.Text = pageText->Text;
|
||||
page.PlayerConditionID = pageText->PlayerConditionID;
|
||||
page.Flags = pageText->Flags;
|
||||
|
||||
pageID = pageText->NextPageID;
|
||||
}
|
||||
LocaleConstant locale = GetSessionDbLocaleIndex();
|
||||
if (locale >= LOCALE_enUS)
|
||||
if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID))
|
||||
ObjectMgr::GetLocaleString(pageTextLocale->Text, locale, page.Text);
|
||||
|
||||
SendPacket(response.Write());
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUERY_PAGE_TEXT_RESPONSE");
|
||||
response.Pages.push_back(page);
|
||||
pageID = pageText->NextPageID;
|
||||
}
|
||||
|
||||
response.Allow = !response.Pages.empty();
|
||||
|
||||
SendPacket(response.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleQueryCorpseTransport(WorldPackets::Query::QueryCorpseTransport& queryCorpseTransport)
|
||||
{
|
||||
Corpse* corpse = _player->GetCorpse();
|
||||
|
||||
WorldPackets::Query::CorpseTransportQuery response;
|
||||
if (!corpse || corpse->GetTransGUID().IsEmpty() || corpse->GetTransGUID() != queryCorpseTransport.Transport)
|
||||
response.Player = queryCorpseTransport.Player;
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(queryCorpseTransport.Player))
|
||||
{
|
||||
response.Position = G3D::Vector3(0.0f, 0.0f, 0.0f);
|
||||
response.Facing = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
response.Position = G3D::Vector3(corpse->GetTransOffsetX(), corpse->GetTransOffsetY(), corpse->GetTransOffsetZ());
|
||||
response.Facing = corpse->GetTransOffsetO();
|
||||
Corpse* corpse = player->GetCorpse();
|
||||
if (_player->IsInSameRaidWith(player) && corpse && !corpse->GetTransGUID().IsEmpty() && corpse->GetTransGUID() == queryCorpseTransport.Transport)
|
||||
{
|
||||
response.Position = G3D::Vector3(corpse->GetTransOffsetX(), corpse->GetTransOffsetY(), corpse->GetTransOffsetZ());
|
||||
response.Facing = corpse->GetTransOffsetO();
|
||||
}
|
||||
}
|
||||
|
||||
SendPacket(response.Write());
|
||||
|
||||
Reference in New Issue
Block a user