Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Update SMSG_QUEST_NPC_QUERY_RESPONSE and CMSG_QUEST_NPC_QUERY
Browse files Browse the repository at this point in the history
Signed-off-by: AlterEgo <admin@projectskyfire.org>
  • Loading branch information
SkyFire committed Oct 29, 2023
1 parent 567b4b2 commit 03d2e1b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/server/game/Globals/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ typedef UNORDERED_MAP<uint32, GossipMenuItemsLocale> GossipMenuItemsLocaleContai
typedef UNORDERED_MAP<uint32, PointOfInterestLocale> PointOfInterestLocaleContainer;
typedef UNORDERED_MAP<uint32, QuestObjectiveLocale> QuestObjectiveLocaleContainer;

typedef std::multimap<uint32, uint32> QuestRelations;
typedef std::multimap<uint32, uint32> QuestRelations; // unit/go -> quest
typedef std::multimap<uint32, uint32> QuestRelationsReverse; // quest -> unit/go
typedef std::pair<QuestRelations::const_iterator, QuestRelations::const_iterator> QuestRelationBounds;
typedef std::pair<QuestRelationsReverse::const_iterator, QuestRelationsReverse::const_iterator> QuestRelationReverseBounds;

struct PetLevelInfo
{
Expand Down Expand Up @@ -919,6 +921,11 @@ class ObjectMgr
return _goQuestInvolvedRelations.equal_range(go_entry);
}

QuestRelationReverseBounds GetGOQuestInvolvedRelationReverseBounds(uint32 questId)
{
return _goQuestInvolvedRelationsReverse.equal_range(questId);
}

QuestRelations* GetCreatureQuestRelationMap()
{
return &_creatureQuestRelations;
Expand All @@ -934,6 +941,11 @@ class ObjectMgr
return _creatureQuestInvolvedRelations.equal_range(creature_entry);
}

QuestRelationReverseBounds GetCreatureQuestInvolvedRelationReverseBounds(uint32 questId)
{
return _creatureQuestInvolvedRelationsReverse.equal_range(questId);
}

void LoadEventScripts();
void LoadSpellScripts();
void LoadWaypointScripts();
Expand Down Expand Up @@ -1465,8 +1477,10 @@ class ObjectMgr

QuestRelations _goQuestRelations;
QuestRelations _goQuestInvolvedRelations;
QuestRelationsReverse _goQuestInvolvedRelationsReverse;
QuestRelations _creatureQuestRelations;
QuestRelations _creatureQuestInvolvedRelations;
QuestRelationsReverse _creatureQuestInvolvedRelationsReverse;

//character reserved names
typedef std::set<std::wstring> ReservedNamesContainer;
Expand Down
42 changes: 42 additions & 0 deletions src/server/game/Handlers/QueryHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,48 @@ void WorldSession::HandleCorpseMapPositionQuery(WorldPacket& recvData)
SendPacket(&data);
}

void WorldSession::HandleQuestNPCQuery(WorldPacket& recvData)
{
std::map<uint32, std::vector<uint32>> quests;
for (int i = 0; i < 50; ++i)
{
uint32 questId;
recvData >> questId;

/// @todo verify if we should only send completed quests questgivers
if (sObjectMgr->GetQuestTemplate(questId) && _player->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
{
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
}
}

uint32 count;
recvData >> count;

WorldPacket data(SMSG_QUEST_NPC_QUERY_RESPONSE, 3 + count * 14);
data.WriteBits(quests.size(), 21);

for (auto it = quests.begin(); it != quests.end(); ++it)
data.WriteBits(it->second.size(), 22);

data.FlushBits();

for (auto it = quests.begin(); it != quests.end(); ++it)
{
data << uint32(it->first);
for (const auto& entry : it->second)
data << uint32(entry);
}

SendPacket(&data);
}

void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData)
{
uint32 count = recvData.ReadBits(22);
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Server/Protocol/Opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ void OpcodeTable::InitializeClientTable()
DEFINE_OPCODE_HANDLER(CMSG_QUEST_GIVER_STATUS_QUERY, 0x036A, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestgiverStatusQueryOpcode ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_QUESTLOG_REMOVE_QUEST, 0x0779, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestLogRemoveQuest ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_QUEST_CONFIRM_ACCEPT, 0x124B, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestConfirmAccept ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_QUEST_NPC_QUERY, 0x1DAE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestNPCQuery ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_QUEST_POI_QUERY, 0x10C2, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestPOIQuery ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_QUEST_QUERY, 0x02D5, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestQueryOpcode ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(CMSG_RAID_READY_CHECK, 0x0817, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleRaidReadyCheckOpcode ); // 5.4.8 18414
Expand Down Expand Up @@ -583,7 +584,6 @@ void OpcodeTable::InitializeClientTable()
DEFINE_OPCODE_HANDLER(CMSG_QUERY_GUILD_MEMBERS_FOR_RECIPE, 0x0000, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_QUERY_GUILD_MEMBER_RECIPES, 0x0000, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_QUERY_GUILD_RECIPES, 0x0000, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_QUEST_NPC_QUERY, 0x1DAE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_REDIRECTION_AUTH_PROOF, 0x0000, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_REQUEST_INSPECT_RATED_BG_STATS, 0x0882, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER(CMSG_REQUEST_RESEARCH_HISTORY, 0x15E2, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
Expand Down Expand Up @@ -962,6 +962,7 @@ void OpcodeTable::InitializeServerTable()
DEFINE_OPCODE_HANDLER(SMSG_QUEST_POI_QUERY_RESPONSE, 0x067F, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_QUEST_PUSH_RESULT, 0x074D, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_QUEST_QUERY_RESPONSE, 0x0276, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_QUEST_NPC_QUERY_RESPONSE, 0x036D, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_RAID_INSTANCE_INFO, 0x16BF, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_RAID_READY_CHECK, 0x1C8E, STATUS_NEVER ); // 5.4.8 18414
DEFINE_OPCODE_HANDLER(SMSG_RAID_READY_CHECK_COMPLETED, 0x15C2, STATUS_NEVER ); // 5.4.8 18414
Expand Down Expand Up @@ -1312,7 +1313,6 @@ void OpcodeTable::InitializeServerTable()
DEFINE_OPCODE_HANDLER(SMSG_PLAY_TIME_WARNING, 0x062A, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_QUESTUPDATE_FAILED, 0x07DD, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_QUEST_FORCE_REMOVE, 0x07C5, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_QUEST_NPC_QUERY_RESPONSE, 0x036D, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_RAID_MARKERS_CHANGED, 0x008A, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_RAID_READY_CHECK_THROTTLED_ERROR, 0x0000, STATUS_UNHANDLED); // NYI
DEFINE_OPCODE_HANDLER(SMSG_RAID_SUMMON_FAILED, 0x108A, STATUS_UNHANDLED); // NYI
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Server/Protocol/Opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ enum Opcodes
CMSG_QUESTLOG_REMOVE_QUEST,
CMSG_QUESTLOG_SWAP_QUEST,
CMSG_QUEST_CONFIRM_ACCEPT,
CMSG_QUEST_NPC_QUERY,
CMSG_QUEST_POI_QUERY,
CMSG_QUEST_PUSH_RESULT,
CMSG_QUEST_QUERY,
Expand Down Expand Up @@ -992,6 +993,7 @@ enum Opcodes
SMSG_QUEST_POI_QUERY_RESPONSE,
SMSG_QUEST_PUSH_RESULT,
SMSG_QUEST_QUERY_RESPONSE,
SMSG_QUEST_NPC_QUERY_RESPONSE,
SMSG_RAID_GROUP_ONLY,
SMSG_RAID_INSTANCE_INFO,
SMSG_RAID_INSTANCE_MESSAGE,
Expand Down Expand Up @@ -1193,7 +1195,6 @@ enum Opcodes
CMSG_QUERY_GUILD_MEMBERS_FOR_RECIPE,
CMSG_QUERY_GUILD_MEMBER_RECIPES,
CMSG_QUERY_GUILD_RECIPES,
CMSG_QUEST_NPC_QUERY,
CMSG_REDIRECTION_AUTH_PROOF,
CMSG_REQUEST_INSPECT_RATED_BG_STATS,
CMSG_REQUEST_RESEARCH_HISTORY,
Expand Down Expand Up @@ -1374,7 +1375,6 @@ enum Opcodes
SMSG_PLAY_TIME_WARNING,
SMSG_QUESTUPDATE_FAILED,
SMSG_QUEST_FORCE_REMOVE,
SMSG_QUEST_NPC_QUERY_RESPONSE,
SMSG_RAID_MARKERS_CHANGED,
SMSG_RAID_READY_CHECK_THROTTLED_ERROR,
SMSG_RAID_SUMMON_FAILED,
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ class WorldSession
void HandleEquipmentSetUse(WorldPacket& recvData);
void HandleWorldStateUITimerUpdate(WorldPacket& recvData);
void HandleReadyForAccountDataTimes(WorldPacket& recvData);
void HandleQuestNPCQuery(WorldPacket& recvData);
void HandleQueryQuestsCompleted(WorldPacket& recvData);
void HandleQuestPOIQuery(WorldPacket& recvData);
void HandleEjectPassenger(WorldPacket& data);
Expand Down

0 comments on commit 03d2e1b

Please sign in to comment.