2010-10-07 15:35:36 +02:00
|
|
|
/*
|
2015-01-01 00:27:46 +01:00
|
|
|
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:35:36 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "Common.h"
|
|
|
|
|
#include "Language.h"
|
2010-06-08 17:01:03 -06:00
|
|
|
#include "DatabaseEnv.h"
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "WorldSession.h"
|
|
|
|
|
#include "Opcodes.h"
|
|
|
|
|
#include "Log.h"
|
|
|
|
|
#include "World.h"
|
|
|
|
|
#include "ObjectMgr.h"
|
|
|
|
|
#include "Player.h"
|
|
|
|
|
#include "UpdateMask.h"
|
|
|
|
|
#include "NPCHandler.h"
|
|
|
|
|
#include "Pet.h"
|
2008-12-24 09:58:26 -06:00
|
|
|
#include "MapManager.h"
|
2014-11-10 07:46:15 +00:00
|
|
|
#include "CharacterPackets.h"
|
2014-11-14 01:55:29 +00:00
|
|
|
#include "QueryPackets.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-09-14 16:14:12 +02:00
|
|
|
void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-10-16 22:47:02 +02:00
|
|
|
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
2011-10-10 12:47:33 -04:00
|
|
|
|
2014-11-15 17:13:41 +02:00
|
|
|
WorldPackets::Query::QueryPlayerNameResponse response;
|
2014-11-10 06:44:43 +00:00
|
|
|
response.Player = guid;
|
|
|
|
|
|
2015-02-05 20:18:32 +01:00
|
|
|
if (response.Data.Initialize(guid, player))
|
|
|
|
|
response.Result = RESPONSE_SUCCESS; // name known
|
2012-05-30 08:01:02 +02:00
|
|
|
else
|
2014-11-12 19:16:14 +01:00
|
|
|
response.Result = RESPONSE_FAILURE; // name unknown
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-10 06:44:43 +00:00
|
|
|
SendPacket(response.Write());
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-15 17:13:41 +02:00
|
|
|
void WorldSession::HandleNameQueryOpcode(WorldPackets::Query::QueryPlayerName& packet)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-10 06:44:43 +00:00
|
|
|
SendNameQueryOpcode(packet.Player);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2015-01-19 18:24:03 +01:00
|
|
|
void WorldSession::HandleQueryTimeOpcode(WorldPackets::Query::QueryTime& /*queryTime*/)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2010-01-29 22:24:18 +01:00
|
|
|
SendQueryTimeResponse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WorldSession::SendQueryTimeResponse()
|
|
|
|
|
{
|
2015-01-19 18:24:03 +01:00
|
|
|
WorldPackets::Query::QueryTimeResponse queryTimeResponse;
|
|
|
|
|
queryTimeResponse.CurrentTime = time(nullptr);
|
|
|
|
|
queryTimeResponse.TimeOutRequest = sWorld->GetNextDailyQuestsResetTime() - queryTimeResponse.CurrentTime;
|
|
|
|
|
SendPacket(queryTimeResponse.Write());
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-04 15:14:15 +02:00
|
|
|
/// Only _static_ data is sent in this packet !!!
|
2014-11-14 01:55:29 +00:00
|
|
|
void WorldSession::HandleCreatureQuery(WorldPackets::Query::QueryCreature& packet)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-14 01:55:29 +00:00
|
|
|
WorldPackets::Query::QueryCreatureResponse response;
|
|
|
|
|
|
|
|
|
|
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(packet.CreatureID);
|
|
|
|
|
|
|
|
|
|
response.CreatureID = packet.CreatureID;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-06-21 22:40:03 +02:00
|
|
|
if (creatureInfo)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-14 01:55:29 +00:00
|
|
|
response.Allow = true;
|
|
|
|
|
|
|
|
|
|
WorldPackets::Query::CreatureStats& stats = response.Stats;
|
|
|
|
|
|
|
|
|
|
stats.Title = creatureInfo->SubName;
|
|
|
|
|
stats.CursorName = creatureInfo->IconName;
|
|
|
|
|
stats.CreatureType = creatureInfo->type;
|
|
|
|
|
stats.CreatureFamily = creatureInfo->family;
|
|
|
|
|
stats.Classification = creatureInfo->rank;
|
|
|
|
|
stats.HpMulti = creatureInfo->ModHealth;
|
|
|
|
|
stats.EnergyMulti = creatureInfo->ModMana;
|
|
|
|
|
stats.Leader = creatureInfo->RacialLeader;
|
2014-06-21 22:40:03 +02:00
|
|
|
for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
|
2014-11-14 01:55:29 +00:00
|
|
|
if (creatureInfo->questItems[i])
|
|
|
|
|
stats.QuestItems.push_back(creatureInfo->questItems[i]);
|
|
|
|
|
stats.CreatureMovementInfoID = creatureInfo->movementId;
|
|
|
|
|
stats.RequiredExpansion = creatureInfo->expansionUnknown;
|
|
|
|
|
stats.Flags[0] = creatureInfo->type_flags;
|
|
|
|
|
stats.Flags[1] = creatureInfo->type_flags2;
|
|
|
|
|
for (uint32 i = 0; i < MAX_KILL_CREDIT; ++i)
|
|
|
|
|
stats.ProxyCreatureID[i] = creatureInfo->KillCredit[i];
|
|
|
|
|
stats.CreatureDisplayID[0] = creatureInfo->Modelid1;
|
|
|
|
|
stats.CreatureDisplayID[1] = creatureInfo->Modelid2;
|
|
|
|
|
stats.CreatureDisplayID[2] = creatureInfo->Modelid3;
|
|
|
|
|
stats.CreatureDisplayID[3] = creatureInfo->Modelid4;
|
|
|
|
|
stats.Name[0] = creatureInfo->Name;
|
|
|
|
|
stats.NameAlt[0] = creatureInfo->FemaleName;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
else
|
2014-11-14 01:55:29 +00:00
|
|
|
response.Allow = false;
|
2014-06-21 22:40:03 +02:00
|
|
|
|
2014-11-14 01:55:29 +00:00
|
|
|
SendPacket(response.Write());
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-04 15:14:15 +02:00
|
|
|
/// Only _static_ data is sent in this packet !!!
|
2014-12-28 16:01:53 +00:00
|
|
|
void WorldSession::HandleGameObjectQueryOpcode(WorldPackets::Query::QueryGameObject& packet)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-12-28 16:01:53 +00:00
|
|
|
WorldPackets::Query::QueryGameObjectResponse response;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-12-29 01:00:16 +01:00
|
|
|
response.GameObjectID = packet.GameObjectID;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-12-29 01:00:16 +01:00
|
|
|
if (GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.GameObjectID))
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-12-28 16:01:53 +00:00
|
|
|
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.Expansion = 0;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2014-12-28 16:01:53 +00:00
|
|
|
else
|
|
|
|
|
response.Allow = false;
|
|
|
|
|
|
|
|
|
|
SendPacket(response.Write());
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2015-01-15 02:25:19 +01:00
|
|
|
void WorldSession::HandleQueryCorpseLocation(WorldPackets::Query::QueryCorpseLocationFromClient& /*packet*/)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2015-01-15 02:25:19 +01:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUERY_CORPSE_LOCATION_FROM_CLIENT");
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-15 14:08:17 +02:00
|
|
|
Corpse* corpse = GetPlayer()->GetCorpse();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!corpse)
|
2008-12-24 09:58:26 -06:00
|
|
|
{
|
2015-01-19 00:06:15 +00:00
|
|
|
WorldPackets::Query::CorpseLocation packet;
|
|
|
|
|
packet.Valid = false; // corpse not found
|
|
|
|
|
SendPacket(packet.Write());
|
2008-12-24 09:58:26 -06:00
|
|
|
return;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2015-01-15 02:25:19 +01:00
|
|
|
uint32 mapID = corpse->GetMapId();
|
2008-12-24 09:58:26 -06:00
|
|
|
float x = corpse->GetPositionX();
|
|
|
|
|
float y = corpse->GetPositionY();
|
|
|
|
|
float z = corpse->GetPositionZ();
|
2015-01-15 02:25:19 +01:00
|
|
|
uint32 corpseMapID = mapID;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-06-05 17:16:39 -05:00
|
|
|
// if corpse at different map
|
2015-01-15 02:25:19 +01:00
|
|
|
if (mapID != _player->GetMapId())
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-06-05 17:16:39 -05:00
|
|
|
// search entrance map for proper show entrance
|
2015-01-15 02:25:19 +01:00
|
|
|
if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapID))
|
2008-12-24 09:58:26 -06:00
|
|
|
{
|
2014-11-05 23:33:56 +02:00
|
|
|
if (corpseMapEntry->IsDungeon() && corpseMapEntry->CorpseMapID >= 0)
|
2009-06-05 17:16:39 -05:00
|
|
|
{
|
|
|
|
|
// if corpse map have entrance
|
2014-11-05 23:33:56 +02:00
|
|
|
if (Map const* entranceMap = sMapMgr->CreateBaseMap(corpseMapEntry->CorpseMapID))
|
2009-06-05 17:16:39 -05:00
|
|
|
{
|
2015-01-15 02:25:19 +01:00
|
|
|
mapID = corpseMapEntry->CorpseMapID;
|
2014-11-07 13:53:25 +02:00
|
|
|
x = corpseMapEntry->CorpsePos.X;
|
|
|
|
|
y = corpseMapEntry->CorpsePos.Y;
|
2012-02-03 16:03:52 -05:00
|
|
|
z = entranceMap->GetHeight(GetPlayer()->GetPhaseMask(), x, y, MAX_HEIGHT);
|
2009-06-05 17:16:39 -05:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-24 09:58:26 -06:00
|
|
|
}
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2015-01-19 00:06:15 +00:00
|
|
|
WorldPackets::Query::CorpseLocation packet;
|
|
|
|
|
packet.Valid = true;
|
|
|
|
|
packet.MapID = corpseMapID;
|
|
|
|
|
packet.ActualMapID = mapID;
|
|
|
|
|
packet.Position = G3D::Vector3(x, y, z);
|
2015-01-19 18:24:03 +01:00
|
|
|
packet.Transport = corpse->GetTransGUID();
|
2015-01-15 02:25:19 +01:00
|
|
|
SendPacket(packet.Write());
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
void WorldSession::HandleNpcTextQueryOpcode(WorldPackets::Query::QueryNPCText& packet)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-24 20:50:19 +02:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: CMSG_NPC_TEXT_QUERY TextId: %u", packet.TextID);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
GossipText const* gossip = sObjectMgr->GetGossipText(packet.TextID);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
WorldPackets::Query::QueryNPCTextResponse response;
|
|
|
|
|
response.TextID = packet.TextID;
|
2014-12-26 01:38:40 +01:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
if (gossip)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-04-25 23:24:29 +02:00
|
|
|
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-24 20:50:19 +02:00
|
|
|
response.Probabilities[i] = gossip->Options[i].Probability;
|
|
|
|
|
response.BroadcastTextID[i] = gossip->Options[i].BroadcastTextID;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
response.Allow = true;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
SendPacket(response.Write());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-11-08 10:50:51 +01:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_NPC_TEXT_UPDATE");
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-04 15:14:15 +02:00
|
|
|
/// Only _static_ data is sent in this packet !!!
|
2014-11-15 17:13:41 +02:00
|
|
|
void WorldSession::HandlePageTextQueryOpcode(WorldPackets::Query::QueryPageText& packet)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2013-11-08 10:50:51 +01:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PAGE_TEXT_QUERY");
|
2014-12-26 01:38:40 +01:00
|
|
|
|
2014-11-15 17:13:41 +02:00
|
|
|
uint32 pageID = packet.PageTextID;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
while (pageID)
|
|
|
|
|
{
|
2011-04-28 22:13:09 +02:00
|
|
|
PageText const* pageText = sObjectMgr->GetPageText(pageID);
|
2014-11-15 17:13:41 +02:00
|
|
|
|
|
|
|
|
WorldPackets::Query::QueryPageTextResponse response;
|
|
|
|
|
response.PageTextID = pageID;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-28 22:13:09 +02:00
|
|
|
if (!pageText)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2014-11-15 17:13:41 +02:00
|
|
|
response.Allow = false;
|
2008-10-02 16:23:55 -05:00
|
|
|
pageID = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-15 17:13:41 +02:00
|
|
|
response.Allow = true;
|
|
|
|
|
response.Info.ID = pageID;
|
2014-12-26 01:38:40 +01:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
int loc_idx = GetSessionDbLocaleIndex();
|
|
|
|
|
if (loc_idx >= 0)
|
2011-11-07 11:18:00 -06:00
|
|
|
if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID))
|
2014-11-15 17:13:41 +02:00
|
|
|
ObjectMgr::GetLocaleString(player->Text, loc_idx, response.Info.Text);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2014-11-15 17:13:41 +02:00
|
|
|
response.Info.NextPageID = pageText->NextPageID;
|
2014-10-24 23:23:12 -04:00
|
|
|
pageID = pageText->NextPageID;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2014-12-26 01:38:40 +01:00
|
|
|
|
2014-11-15 17:13:41 +02:00
|
|
|
SendPacket(response.Write());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-11-08 10:50:51 +01:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE");
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-02-17 20:07:49 -06:00
|
|
|
|
2015-01-15 02:25:19 +01:00
|
|
|
void WorldSession::HandleQueryCorpseTransport(WorldPackets::Query::QueryCorpseTransport& packet)
|
2009-12-17 12:13:33 +01:00
|
|
|
{
|
2015-01-15 02:25:19 +01:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Recv CMSG_QUERY_CORPSE_TRANSPORT");
|
2009-12-17 12:13:33 +01:00
|
|
|
|
2015-01-19 18:24:03 +01:00
|
|
|
Corpse* corpse = _player->GetCorpse();
|
|
|
|
|
|
2015-01-15 02:25:19 +01:00
|
|
|
WorldPackets::Query::CorpseTransportQuery response;
|
2015-01-19 18:24:03 +01:00
|
|
|
if (!corpse || corpse->GetTransGUID().IsEmpty() || corpse->GetTransGUID() != packet.Transport)
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 02:25:19 +01:00
|
|
|
SendPacket(response.Write());
|
2009-12-17 12:13:33 +01:00
|
|
|
}
|
2010-02-14 19:13:14 -07:00
|
|
|
|
2014-09-01 20:03:01 +01:00
|
|
|
void WorldSession::HandleQuestNPCQuery(WorldPacket& recvData)
|
|
|
|
|
{
|
|
|
|
|
uint32 count = recvData.ReadBits(24);
|
|
|
|
|
std::map<uint32, std::vector<uint32>> quests;
|
|
|
|
|
|
2014-09-02 18:45:22 +01:00
|
|
|
for (uint32 i = 0; i < count; ++i)
|
2014-09-01 20:03:01 +01:00
|
|
|
{
|
|
|
|
|
uint32 questId;
|
|
|
|
|
recvData >> questId;
|
|
|
|
|
|
2014-09-01 21:25:54 +01:00
|
|
|
if (!sObjectMgr->GetQuestTemplate(questId))
|
2014-09-01 20:03:01 +01:00
|
|
|
{
|
2015-02-16 17:47:04 +00:00
|
|
|
TC_LOG_DEBUG("network", "WORLD: Unknown quest %u in CMSG_QUERY_QUEST_COMPLETION_NPCS by %s", questId, _player->GetGUID().ToString().c_str());
|
2014-09-01 21:25:54 +01:00
|
|
|
continue;
|
2014-09-01 20:03:01 +01:00
|
|
|
}
|
2014-09-01 21:25:54 +01:00
|
|
|
|
|
|
|
|
auto creatures = sObjectMgr->GetCreatureQuestInvolvedRelationReverseBounds(questId);
|
|
|
|
|
for (auto it = creatures.first; it != creatures.second; ++it)
|
|
|
|
|
quests[questId].push_back(it->second);
|
|
|
|
|
|
|
|
|
|
auto gos = sObjectMgr->GetGOQuestInvolvedRelationReverseBounds(questId);
|
|
|
|
|
for (auto it = gos.first; it != gos.second; ++it)
|
|
|
|
|
quests[questId].push_back(it->second | 0x80000000); // GO mask
|
2014-09-01 20:03:01 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-16 17:47:04 +00:00
|
|
|
WorldPacket data(SMSG_QUEST_COMPLETION_NPC_RESPONSE, 3 + quests.size() * 14);
|
2014-09-01 20:03:01 +01:00
|
|
|
data.WriteBits(quests.size(), 23);
|
|
|
|
|
|
|
|
|
|
for (auto it = quests.begin(); it != quests.end(); ++it)
|
|
|
|
|
data.WriteBits(it->second.size(), 24);
|
|
|
|
|
|
|
|
|
|
for (auto it = quests.begin(); it != quests.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
data << uint32(it->first);
|
|
|
|
|
for (const auto& entry : it->second)
|
|
|
|
|
data << uint32(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SendPacket(&data);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-05 19:40:30 -05:00
|
|
|
void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
|
|
|
|
uint32 count;
|
2012-08-05 19:40:30 -05:00
|
|
|
recvData >> count; // quest count, max=25
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2014-06-01 13:33:46 +02:00
|
|
|
if (count > MAX_QUEST_LOG_SIZE)
|
2011-12-10 13:42:22 +01:00
|
|
|
{
|
2012-08-05 19:40:30 -05:00
|
|
|
recvData.rfinish();
|
2010-02-14 19:13:14 -07:00
|
|
|
return;
|
2011-12-10 13:42:22 +01:00
|
|
|
}
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2014-06-01 13:33:46 +02:00
|
|
|
// Read quest ids and add the in a unordered_set so we don't send POIs for the same quest multiple times
|
|
|
|
|
std::unordered_set<uint32> questIds;
|
2010-08-26 15:54:56 +06:00
|
|
|
for (uint32 i = 0; i < count; ++i)
|
2014-06-01 13:33:46 +02:00
|
|
|
questIds.insert(recvData.read<uint32>()); // quest id
|
|
|
|
|
|
|
|
|
|
WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4 + (4 + 4)*questIds.size());
|
|
|
|
|
data << uint32(questIds.size()); // count
|
|
|
|
|
|
|
|
|
|
for (auto itr = questIds.begin(); itr != questIds.end(); ++itr)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
2014-06-01 13:33:46 +02:00
|
|
|
uint32 questId = *itr;
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-02-14 19:13:14 -07:00
|
|
|
bool questOk = false;
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-02-14 19:13:14 -07:00
|
|
|
uint16 questSlot = _player->FindQuestSlot(questId);
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (questSlot != MAX_QUEST_LOG_SIZE)
|
2010-02-14 19:13:14 -07:00
|
|
|
questOk =_player->GetQuestSlotQuestId(questSlot) == questId;
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (questOk)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
2011-09-15 14:08:17 +02:00
|
|
|
QuestPOIVector const* POI = sObjectMgr->GetQuestPOIVector(questId);
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (POI)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
|
|
|
|
data << uint32(questId); // quest ID
|
|
|
|
|
data << uint32(POI->size()); // POI count
|
2010-03-20 21:26:29 +01:00
|
|
|
|
2010-04-07 19:12:44 +02:00
|
|
|
for (QuestPOIVector::const_iterator itr = POI->begin(); itr != POI->end(); ++itr)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
2010-03-20 21:26:29 +01:00
|
|
|
data << uint32(itr->Id); // POI index
|
|
|
|
|
data << int32(itr->ObjectiveIndex); // objective index
|
|
|
|
|
data << uint32(itr->MapId); // mapid
|
|
|
|
|
data << uint32(itr->AreaId); // areaid
|
2013-11-23 12:31:15 -03:30
|
|
|
data << uint32(itr->FloorId); // floorid
|
2010-02-14 19:13:14 -07:00
|
|
|
data << uint32(itr->Unk3); // unknown
|
|
|
|
|
data << uint32(itr->Unk4); // unknown
|
2010-03-20 21:26:29 +01:00
|
|
|
data << uint32(itr->points.size()); // POI points count
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-04-07 19:12:44 +02:00
|
|
|
for (std::vector<QuestPOIPoint>::const_iterator itr2 = itr->points.begin(); itr2 != itr->points.end(); ++itr2)
|
2010-02-14 19:13:14 -07:00
|
|
|
{
|
|
|
|
|
data << int32(itr2->x); // POI point x
|
|
|
|
|
data << int32(itr2->y); // POI point y
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data << uint32(questId); // quest ID
|
|
|
|
|
data << uint32(0); // POI count
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data << uint32(questId); // quest ID
|
|
|
|
|
data << uint32(0); // POI count
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-04-07 18:09:10 +02:00
|
|
|
|
2010-02-14 19:13:14 -07:00
|
|
|
SendPacket(&data);
|
2010-06-08 17:01:03 -06:00
|
|
|
}
|
2014-11-24 20:50:19 +02:00
|
|
|
|
|
|
|
|
void WorldSession::HandleDBQueryBulk(WorldPackets::Query::DBQueryBulk& packet)
|
|
|
|
|
{
|
2014-12-26 01:38:40 +01:00
|
|
|
DB2StorageBase const* store = sDB2Manager.GetStorage(packet.TableHash);
|
2014-11-24 20:50:19 +02:00
|
|
|
if (!store)
|
|
|
|
|
{
|
2014-11-27 13:44:51 +02:00
|
|
|
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: Received unknown hotfix type: %u", packet.TableHash);
|
2014-11-24 20:50:19 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-29 01:00:16 +01:00
|
|
|
for (WorldPackets::Query::DBQueryBulk::DBQueryRecord const& rec : packet.Queries)
|
2014-11-24 20:50:19 +02:00
|
|
|
{
|
|
|
|
|
WorldPackets::Query::DBReply response;
|
|
|
|
|
response.TableHash = packet.TableHash;
|
|
|
|
|
|
|
|
|
|
if (store->HasRecord(rec.RecordID))
|
|
|
|
|
{
|
|
|
|
|
response.RecordID = rec.RecordID;
|
2014-12-26 01:38:40 +01:00
|
|
|
response.Timestamp = sDB2Manager.GetHotfixDate(rec.RecordID, packet.TableHash);
|
2015-02-22 10:29:12 +01:00
|
|
|
store->WriteRecord(rec.RecordID, GetSessionDbcLocale(), response.Data);
|
2014-11-24 20:50:19 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-27 13:44:51 +02:00
|
|
|
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: Entry %u does not exist in datastore: %u", rec.RecordID, packet.TableHash);
|
2014-12-07 01:24:00 +01:00
|
|
|
response.RecordID = -int32(rec.RecordID);
|
2014-11-24 20:50:19 +02:00
|
|
|
response.Timestamp = time(NULL);
|
|
|
|
|
}
|
2014-12-26 01:38:40 +01:00
|
|
|
|
2014-11-24 20:50:19 +02:00
|
|
|
SendPacket(response.Write());
|
|
|
|
|
}
|
|
|
|
|
}
|